perf: Speed up compile times with nom #402
Merged
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.
This is using a short-lived fork
nom
until we can get the changes upstreamed. Note thatcombine
requires usingattempt
to backtrack whilenom
backtracks by default and requirescut
to not backtrack.I find the straight functions much easier to understand what is happening and this allows us to intermix procedural with declarative logic (e.g. in string processing I skipped combinators to make it easier to not require an allocation).
Regarding that allocation, we still do it but this opens the door for us to use
InternalString
for user values which might give us more of a performance boost (previously, the forced allocation made it a moot point to measure it).Running
cargo clean -p toml_edit && time cargo check
, I get 3s for buildingtoml_edit
withcombine
and 0.5s fornom
.For runtime performance
cargo init
s generated manifest took 4% less timecargo
s manifest took 2% less time(some of this might be because we use
dispatch
more than before and some because our error reporting is less allocation heavy)This is with Rust 1.66 on a i9-12900H processor under WSL2
Fixes #327