eignnx / eignnx/funlang

Parsing is SLOWWWW

Open
#7 0 comments 0 reactions 0 assignees View on GitHub
bug performance
Dominant language
Haskell
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Changing the `main` function to this:
```haskell
main :: IO ()
main = do
opts <- getOpts
ast <- parseFile opts
let Ast.ModF name items :@: loc = ast
print $ head items
return ()
-- tast <- astToTypedAst opts ast
-- hir <- tastToHir opts tast
-- lir <- hirToLir opts hir
-- execVmProgram opts lir
```
and running `$ .\Main.exe .\ex\tree-eval.rb` (compiled without optimizations, though I've found `-O2` doesn't help *that* much), the parsing ALONE takes around 8 seconds 😬

The regular `main` function is really not much slower at all:
```haskell
main :: IO ()
main = do
opts <- getOpts
ast <- parseFile opts
-- let Ast.ModF name items :@: loc = ast
-- print $ head items
-- return ()
tast <- astToTypedAst opts ast
hir <- tastToHir opts tast
lir <- hirToLir opts hir
execVmProgram opts lir
```

The same test using this `main` function takes about 9 seconds.

I'm not sure why the Parsec parser is so slow. Might be good to rewrite it at some point.

The bright side of this realization is that type checking and compilation are not the bottleneck at this point!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.