-
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
rustdoc: use a template to generate Hrefs #109616
Conversation
r? @notriddle (rustbot has picked a reviewer for you, use r? to override) |
|
Some changes occurred in src/librustdoc/clean/types.rs cc @camelid |
3365c0c
to
fb5a92a
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit fb5a92a9576a41666183124a42a066464ee53e78 with merge ec9ce33518e7a69ce272577490eb0cff0c04247c... |
☀️ Try build successful - checks-actions |
1 similar comment
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (ec9ce33518e7a69ce272577490eb0cff0c04247c): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
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.
CyclesResultsThis 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.
|
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.
Hmm, based on the perf results, it seems like using templates for this might not be worth it. I agree that the existing code is not great both for perf and readability reasons though.
I think what could potentially help on both fronts is collecting all the data for the href using structured types (rather than passing strings around). Then we could have a relatively simple formatting function that would take that data and generate the href. What do you think?
The structured types approach is pretty much what this PR does. The Href struct is: struct Href<'a, P>
where
P: fmt::Display,
{
root: &'a str,
parent_directories: ParentDirectories,
path_components: P,
filename_prefix: &'a str,
filename_base: Cow<'a, str>,
fragment: &'a str,
} And in terms of performance of the templates, askama just generates a series of I've been trying to get rustc-perf benchmarking set up locally so I can test various hypotheses and see where the issue is. For instance in a few places I replaced At any rate, I'm having trouble with rustc-perf right now because when I run the doc benchmarks locally, it fails to build stm32f4 (and several other crates), seemingly because of a build script that can't determine the rust version based on my local binary. |
This comment has been minimized.
This comment has been minimized.
44c43ae
to
98c4065
Compare
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit ecfcd356b45c366206b69a84b508fc72fa0d3661 with merge ee1012a52be4db4a2dcf676b195c25a83089aaa0... |
(pushed an update to resolve a merge conflict. no substantive changes) |
@bors r+ rollup=never |
⌛ Testing commit ae1a1ef with merge db3c527cbfab37706414b16370b660c11c7ed6ae... |
💔 Test failed - checks-actions |
The job Click to see the possible cause of the failure (guessed by this bot)
|
rustdoc: use a template to generate Hrefs Previously, href always returned a string, so each link incurred at least one allocation. We were also using `"../".repeat()`, and `.collect()` into strings to generate part of the paths. This abstracts away those repetitions into a couple of helper structs, ParentDirectories and PathComponents, and puts them together into an `Href` template, which should save some allocations. As a side benefit, I think it makes the logic of constructing links a little clearer. This removes the only call sites for certain methods of UrlPartsBuilder, so it also removes those methods. Also, remove the ItemType return value from `href` and friends; it was basically unused. Part of rust-lang#108868
☔ The latest upstream changes (presumably #111358) made this pull request unmergeable. Please resolve the merge conflicts. |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
@jsha any updates on this? |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
(I had to synchronize the queue) |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Previously, href always returned a string, so each link incurred at least one allocation. We were also using
"../".repeat()
, and.collect()
into strings to generate part of the paths. This abstracts away those repetitions into a couple of helper structs, ParentDirectories and PathComponents, and puts them together into anHref
template, which should save some allocations. As a side benefit, I think it makes the logic of constructing links a little clearer.This removes the only call sites for certain methods of UrlPartsBuilder, so it also removes those methods.
Also, remove the ItemType return value from
href
and friends; it was basically unused.Part of #108868