-
Notifications
You must be signed in to change notification settings - Fork 51
Notes on performance #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thread about Tail Call Elimination |
Would refactoring the |
https://discord.com/channels/864614189094928394/938814730439655535
|
Note that I recently revamped language-cst internals to be a bit faster and simpler by switching to CPS with uncurried functions and a trampoline eliminator. For ParserT, it might look like: newtype ParserT s m a = ParserT
( forall r
. Fn5
(ParserState s) -- State argument
(m (Unit -> r) -> r) -- Trampoline/lift
(Fn2 (ParserState s) ParseError r) -- Fail
(Fn2 (ParserState s) a r) -- Succeed
r
) I think the would also give you the flexibility to run your parser in any MonadRec without having to write your parser in terms of MonadRec. I'd expect that this would help close the performance gap significantly (and provide stack safety by default). |
Thanks @natefaubion that is extremely helpful. |
Link #154 |
Some other notes on string internals in particular:
|
|
This was done by @natefaubion in #154 |
This is what the benchmarks currently look like:
Text.Parsing.StringParser.CodeUnits
Text.Parsing.Parser.String
Data.String.Regex
I would like to reduce that 4× slowness between Parser.String and StringParser.CodeUnits .
The difference could be due to:
CodePoint
rather thanChar
. Everything goes through theanyCodePoint
parser since Unicode correctness #119 , but I benchmarked it at the time and it didn't make any difference.uncons
the input string and save the tail as the new state. I tried changing that to only keeping a codeunit index into the input string on this branch and it didn't make any difference. https://github.com/jamesdbrock/purescript-parsing/tree/cursorPos { line :: Int, column :: Int}
. I tried changing that toPos Int
on this branch and it didn't make any difference. https://github.com/jamesdbrock/purescript-parsing/tree/cursorControl.Monad.State.Trans.bind
andText.Parsing.Parser.Combinators.tryRethrow
. So this might be the entire problem, but improving this won't be easy.The text was updated successfully, but these errors were encountered: