Uh oh!
There was an error while loading. Please reload this page.
Hasten macro parsing - #68848
Conversation
nnethercote
commented
Feb 5, 2020
This is a hacky but easy change that gets some of the wins that #68836 would get. |
nnethercote
commented
Feb 5, 2020
@bors try @rust-timer queue |
rust-timer
commented
Feb 5, 2020
Awaiting bors try build completion |
bors
commented
Feb 5, 2020
⌛ Trying commit e30f495ecec1a30ac97215bee2107b4fdaa1a884 with merge 0c7ea93de45e21ba54a804998b0b7563386ba795... |
Centril
commented
Feb 5, 2020
bors
commented
Feb 5, 2020
☀️ Try build successful - checks-azure |
rust-timer
commented
Feb 5, 2020
Queued 0c7ea93de45e21ba54a804998b0b7563386ba795 with parent 002287d, future comparison URL. |
nnethercote
commented
Feb 5, 2020
As expected, the perf results are excellent for |
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Feb 5, 2020
I like this, the idea is pretty simple and I wouldn't even call it a hack. |
Uh oh!
There was an error while loading. Please reload this page.
e30f495 to
2a13b24CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Feb 8, 2020
The
The change is justified if the directory cloning is so relatively cheap that it is lost in the noise from the whole parser cloning. |
nnethercote
commented
Feb 9, 2020
Parser cloning is very rare on this code path, so much so that there is no measurable benefit to making it cheaper. I previously made Does that help? I'm not sure how else to explain it. |
nnethercote
commented
Feb 10, 2020
@petrochenkov are you happy to r+ this instead of @eddyb? |
petrochenkov
commented
Feb 10, 2020
Yes, r? @petrochenkov I left a couple of comments, r=me after addressing them. |
Currently, every iteration of the main loop in `generic_extension` instantiates a `Parser`, which is expensive because `Parser` is a large type. Many of those instantiations are only used immutably, particularly for simple-but-repetitive macros of the sort seen in `html5ever` and PR 68836. This commit initializes a single parser outside the loop, and then uses `Cow` to avoid cloning it except for the mutating iterations. This speeds up `html5ever` runs by up to 15%.
The previous commit wrapped `Parser` within a `Cow` for the hot macro parsing path. As a result, there's no need for the `Cow` within `Directory`, because it lies within `Parser`.
This is a small win, because `Failure` is much more common than `Success`.
2a13b24 to
6851f9aCompareI addressed the comments, and added a trivial commit fixing a typo in a variable name. @bors r=petrochenkov |
bors
commented
Feb 10, 2020
📌 Commit 2a13b24 has been approved by |
…=petrochenkov Hasten macro parsing r? @eddyb
…=petrochenkov Hasten macro parsing r? @eddyb
Rollup of 9 pull requests Successful merges: - #67642 (Relax bounds on HashMap/HashSet) - #68848 (Hasten macro parsing) - #69008 (Properly use parent generics for opaque types) - #69048 (Suggestion when encountering assoc types from hrtb) - #69049 (Optimize image sizes) - #69050 (Micro-optimize the heck out of LEB128 reading and writing.) - #69068 (Make the SGX arg cleanup implementation a NOP) - #69082 (When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`) - #69104 (bootstrap: Configure cmake when building sanitizer runtimes) Failed merges: r? @ghost
bors
commented
Feb 13, 2020
☔ The latest upstream changes (presumably #69118) made this pull request unmergeable. Please resolve the merge conflicts. |
nnethercote
commented
Feb 13, 2020
Something weird happened here. Somehow an old version of this branch got merged. I will have to put the orphaned changes in a separate PR. |
nnethercote
commented
Feb 14, 2020
#69150 is the PR. |
…ochenkov Follow-up to rust-lang#68848 This PR contains some late changes to rust-lang#68848 that somehow didn't get included when that PR was merged in a roll-up. r? @petrochenkov
Rollup of 7 pull requests Successful merges: - #68129 (Correct inference of primitive operand type behind binary operation) - #68475 (Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`) - #68856 (typeck: clarify def_bm adjustments & add tests for or-patterns) - #69051 (simplify_try: address some of eddyb's comments) - #69128 (Fix extra subslice lowering) - #69150 (Follow-up to #68848) - #69164 (Update pulldown-cmark dependency) Failed merges: r? @ghost
r? @eddyb