Open gdevanla opened 2 years ago
Note that I have also take the brute force approach for now and make most of values strict. Here is the memory profile:
time .stack-work/dist/x86_64-linux/Cabal-3.2.1.0/build/scanner-exe-1/scanner-exe-1 t1.lox +RTS -hy -p
35.0
9227465.0
.stack-work/dist/x86_64-linux/Cabal-3.2.1.0/build/scanner-exe-1/scanner-exe-1 160.45s user 22.78s system 361% cpu 50.708 total
$ stack exec -- hp2ps -e8in -c scanner-exe-1.hp && xdg-open scanner-exe-1.ps
(base)
# ~/fsf/haskell-lox on git:functions x
Remove the lines - -threaded
and - -with-rtsopts=-N
from your package.yaml
file for a significant performance boost. Run the executable with +RTS -sstderr
and compare the productivity precentage.
Thanks, @soupi . I see a lot of improvement. But, it is still slower that what you would like. Here are the numbers:
$ time .stack-work/dist/x86_64-linux/Cabal-3.2.1.0/build/scanner-exe-1/scanner-exe-1 t1.lox
40.0
1.02334155e8
.stack-work/dist/x86_64-linux/Cabal-3.2.1.0/build/scanner-exe-1/scanner-exe-1 165.00s user 0.53s system 99% cpu 2:45.80 total
Update: I INLINED
a bunch of functions and that had reduced the time for n=35
to around 12s. But, n=40
is still slow.
Where is the java code you are comparing against?
The java code is gradually built up in each chapter. You are probably looking for this code:
Currently, the Interpreter is too slow compared to the speed of the corresponding Java interpreter as listed here: https://craftinginterpreters.com/chunks-of-bytecode.html. The Java version takes around 72 seconds,
But, the current Haskell version takes a lot longer. Some details follow:
Here is the corresponding
lox
code:t1.lox
You see that the Haskell version takes much longer.
Here are some performance stats that I collected so far for n=35.
Here is the entire listing of the profile. As expected, the
interpreter
is the highest cost center. I feel like I could some how reduce the cost of some operations I am doing whileapplyCompOpToDouble
orlookupEnv
orinsertEnv
. I believe the too much cycles are spent creating new versions of theMap
. scanner-exe-1.prof.txt