Replace error Vec
with a linked list of slab Vec
s
#75
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You mentioned that you wanted to take some stabs at performance. While I am not familiar enough with the codebase to suggest any structural changes (and sadly don't have the time to change that, as interesting as
chumsky
is), I had a look at the benchmarks and alsoperf
ed them. The flamegraph has the usual problem of recursive and/or deeply layered parsing function that any parser expectedly consists mostly of its sub-parsers and it's hard to make out problematic areas. One part that showed up repeatedly wasVec::push
andVec::append
.If I saw correctly, some parsers like
Seq
use aVec
as output as well, but on top-level I noticed all of the parsing errors are returned in aVec
, so many of the parsers copy them from outputs of their constituents into an aggregated resultVec
. I replaced that with a wrapper aroundLinkedList<Vec<T>>
to obtain theO(1)
characteristics of itsappend
. It doesn't have everything thatVec
has (in particular, no methods to remove elements), but everything that you use inchumsky
plusiter
andinto_iter
, so it's possible to get back to aVec
after parsing . On the Linux machine I tested this, making this change through all the parsers and also the recoveryStrategy
s made about a 10% difference. This depends heavily on the presence of errors, obviously.Notables:
PResult
unwrap_unchecked
though, so if you want to support earlier versions that's an easy change