-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Improve source code for highlight.rs
#146992
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
Conversation
|
Also need to check the impact on performance (likely slower). @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Improve source code for `highlight.rs`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Code reads much better IMHO! |
|
Finished benchmarking commit (6020c97): comparison URL. Overall result: ❌ regressions - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 0.4%, secondary 12.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.8%, secondary 5.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 471.213s -> 470.794s (-0.09%) |
Agreed (unsurprisingly 😆), but sadly I think this solution is unlikely to get much better performance-wise so unlikely it'll be merged. However I now have a much cleaner code, so I think I'll go back to the original "streaming content" but with a much cleaner approach. |
|
If I had to guess the reason for the perf regression, I would say it probably has to do with all the extra intermediate string allocations. I feel like if we had a way to delay formatting (maybe using an enum, or with |
|
Possibly. Want to give a try pushing it even further before I try to turn this back into a streaming algorithm? Same question for you @yotamofek. 😉 Start from my branch and open PRs with your commits so we can run perf check on them. |
|
I'll give it a go, but my gut says the extra string allocations aren't causing the lion's share of the regressions. Worth a shot though |
|
☔ The latest upstream changes (presumably #147037) made this pull request unmergeable. Please resolve the merge conflicts. |
dfcb725 to
957ca47
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #147397) made this pull request unmergeable. Please resolve the merge conflicts. |
957ca47 to
2ae1bf4
Compare
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Applied suggestions and rebased. |
This comment has been minimized.
This comment has been minimized.
… `closing_tags` Improve documentation Improve code
e8f2462 to
ab1dcee
Compare
|
Arf, english typo, my nemesis. Convenient check. Anyway, the typo checker should be happy now. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, but see this comment: #146992 (comment)
Nothing I can think of other than that.
Really cool change!
|
Thanks for the review. Considering it's fixing bugs, gonna improve the code in a follow-up. @bors r=yotamofek,lolbinarycat rollup |
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 2888098 (parent) -> f977dfc (this PR) Test differencesShow 5 test diffs5 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard f977dfc388ea39c9886b7f8c49abce26e6918df6 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (f977dfc): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.2%, secondary -0.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 476.488s -> 473.751s (-0.57%) |
|
perf triage: Small regressions were expected base from the pre-merge run and following comment: #146992 (comment). Overall the impact is not big and looks partially like noise, since the results got better in next PR (which is unrelated). @rustbot label: +perf-regression-triaged |
…ht, r=yotamofek,lolbinarycat Simplify code to generate line numbers in highlight Follow-up of rust-lang#146992. cc `@yotamofek` r? `@lolbinarycat`
…ht, r=yotamofek,lolbinarycat Simplify code to generate line numbers in highlight Follow-up of rust-lang#146992. cc ``@yotamofek`` r? ``@lolbinarycat``
…ht, r=yotamofek,lolbinarycat Simplify code to generate line numbers in highlight Follow-up of rust-lang#146992. cc ```@yotamofek``` r? ```@lolbinarycat```
…ht, r=yotamofek,lolbinarycat Simplify code to generate line numbers in highlight Follow-up of rust-lang#146992. cc ````@yotamofek```` r? ````@lolbinarycat````
…ht, r=yotamofek,lolbinarycat Simplify code to generate line numbers in highlight Follow-up of rust-lang#146992. cc `````@yotamofek````` r? `````@lolbinarycat`````

I was very bothered by the complexity of this file, in particular the handling of
pending_elemswhich was very tricky to follow.So instead, here comes a more sane approach: the content is store in a stack-like type which handles "levels" of HTML (ie, a macro expansion can contain other HTML tags which can themselves contain other, etc). Making it much simpler to keep track of what's going on.
r? @lolbinarycat