Repository navigation
Allocate the AST in an arena - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Builds the whole AST in a bump arena (
bumpalo), the way mago-syntax does, to remove the malloc/free and drop cost that took ~43% of CPU time in aperfprofile.What changes
parse(&arena, source, config)- the caller owns anArena; dropping it frees the tree at onceNodevariants hold&'a mut Tinstead ofBox<T>, lists are arenaVecsTokenisCopy: its value is a plain&[u8]and free-floating tokens are an arena slice.node(arena)instead of.into()Attributeshold strings only (the resolved name was the only user) and live in the arenaFormatter::new(&arena),NamespaceResolver::new(&arena),resolve_names(&arena, ..),Registry::collect(&arena, ..)Same output
The dump stays byte-identical to the Go parser: Laravel at 8.4 and 7.4, Symfony at 8.4 and 7.4, a PHP 7.4-era Laravel at 7.4 and 5.6, and all fixtures.
Speed
Laravel (18157 files) on 4 cores in CI, average over 5 runs:
Benchmark workflow fix
The benchmark step piped into
teewithoutpipefail, so it passed even whenbench/compare.shfailed. That happened once the Rust cache restored a pruned Go checkout. The step now fails on errors and the script reclones the checkout.