-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Less TokenTree
cloning
#114115
Less TokenTree
cloning
#114115
Conversation
The existing code is a very complex and inefficient way to the get the span of the last token.
There's no need for token tree cloning here.
This avoids cloning some token trees. A couple of `clone` calls were inserted, but only on some paths, and the next commit will remove them.
Making it similar to `Token::uninterpolate`. This avoids some more token tree cloning.
Now the cloning only happens on some paths, instead of all paths.
By changing `into_trees` into `trees`. Some of the subsequent paths require explicit clones, but not all.
Token tree cloning is only needed in one place.
This is surprising, but the new comment explains why. It's a logical conclusion in the drive to avoid `TokenTree` clones. `TokenTreeCursor` is now only used within `Parser`. It's still needed due to `replace_prev_and_rewind`.
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
Best reviewed one commit at a time. The last commit is quite aggressive, and I could be talked out of it. I was seeing what was the limit of the possibilities here. Local measurements suggest no significant perf effect, let's confirm that here: @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 4ebf2be with merge 028e606494c3e231dcbd3f8fb891d1709ea275cd... |
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Nice improvement for rustdoc. 👍 |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (0699d99): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 652.994s -> 653.092s (0.02%) |
… r=petrochenkov Less `TokenTree` cloning `TokenTreeCursor` has this comment on it: ``` // FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones. ``` This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that. r? `@petrochenkov`
TokenTreeCursor
has this comment on it:This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that.
r? @petrochenkov