Uh oh!
There was an error while loading. Please reload this page.
Migrate rustdoc from Tera to Askama - #92526
Conversation
rust-highfive
commented
Jan 3, 2022
(rust-highfive has picked a reviewer for you, use r? to override) |
GuillaumeGomez
commented
Jan 3, 2022
Let's check perf. @bors try @rust-timer queue |
rust-timer
commented
Jan 3, 2022
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
bors
commented
Jan 3, 2022
⌛ Trying commit 05465c2f5081b3d866854d74745029f0bace4b63 with merge e9be93a5f7d0a32ad8a9f6a1794ee49ef250d8fa... |
Uh oh!
There was an error while loading. Please reload this page.
jsha
left a comment
There was a problem hiding this comment.
Thanks for working on this! Overall looks great. A few questions below.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bors
commented
Jan 3, 2022
☀️ Try build successful - checks-actions |
rust-timer
commented
Jan 3, 2022
Queued e9be93a5f7d0a32ad8a9f6a1794ee49ef250d8fa with parent ddabe07, future comparison URL. |
There was a problem hiding this comment.
A further performance improvement here would be to make sure that Buffer impls core::fmt::Write, in which case we could use render_into(buf) rather than render(), avoiding the allocation of a temporary String here. Buffer internally seems to just hold a String and it has write_str() and write_fmt() methods already, so perhaps it would make sense to implement that trait? I'm not sure how big/relevant the performance improvement would be.
rust-timer
commented
Jan 3, 2022
Finished benchmarking commit (e9be93a5f7d0a32ad8a9f6a1794ee49ef250d8fa): comparison url. Summary: This change led to very large relevant improvements 🎉 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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 led to changes in compiler perf. @bors rollup=never |
Looks like this easily wins back performance from #89695 and thus fixes #89732:
It looks like it's even substantially better than the situation before using Tera. |
So performance is great, code changes look good. Can you confirm that the generated HTML files size doesn't change (before and after this PR) please? |
Can you recommend an easy way/entry point on how/where to check that? |
GuillaumeGomez
commented
Jan 3, 2022
Sure! So first, use |
There was a problem hiding this comment.
Is there a way to get Askama to automatically strip the extra space rather than having to use {#- -#} all over the place? This is one of my annoyances with templates, and it seems like it should theoretically be solvable.
There was a problem hiding this comment.
There is not currently. Askama is a general-purpose text templating mechanism, and the "extra space" is only useless in the particular context of writing out HTML. I don't know the exact details of how reducing whitespace in a string serialization of the HTML DOM will affect that DOM, but if there is a reliable algorithm to implement that, I'd suggest you open an issue against Askama to discuss how we might support that.
(For example, one way I might imagine doing it is by stripping any whitespace after a newline, but that doesn't remove all the whitespace the {#- -#} currently remove because it leaves the newlines themselves. However, if you strip the newlines themselves you would invalidate content like <img src="foo"\nalt="foo">. So solving this optimally seems like a decently hard problem.)
There was a problem hiding this comment.
At least stripping the extra spaces after the newline seems like it'd be good enough to me. Sometimes the newlines can be helpful for debugging the HTML too.
There was a problem hiding this comment.
I don't think I will have time to write code for this, but I'm happy to discuss how it could be implemented and review the code.
There was a problem hiding this comment.
One of the Askama team members submitted a PR for something like this today: askama-rs/askama-old#598.
camelid
commented
Jan 4, 2022
What do the errors look like when a template parameter is used incorrectly? E.g., what's the error when you try to iterate over an integer in a template? |
djc
commented
Jan 4, 2022
The errors are somewhat painful: you get a normal compiler error but with the span pointing to the |
djc
commented
Jan 4, 2022
Building the std docs this way errors out for me: |
GuillaumeGomez
commented
Jan 4, 2022
Ah right, sometimes for whatever reason it just doesn't build. Use I was sure that this issue was fixed though... So weird. |
jyn514
commented
Jan 4, 2022
That looks like you haven't built the standard library yet, which is strange since I thought x.py should build it before building rustdoc ... does |
GuillaumeGomez
commented
Jan 4, 2022
It's in the build requirements normally as you can see here. |
camelid
commented
Jan 4, 2022
Hmm... I wonder if there's a way you could attach the spans to non-Rust code by doing something like const _:&str = include_str!("the_template.html");Then, the template source code would be part of the |
camelid
commented
Jan 4, 2022
Why did you move the templates from |
bors
commented
Jan 12, 2022
⌛ Testing commit ef96d57 with merge e038d9166b04292cd4f8f0ed1091ae0163dfa25b... |
rust-log-analyzer
commented
Jan 12, 2022
bors
commented
Jan 12, 2022
💔 Test failed - checks-actions |
GuillaumeGomez
commented
Jan 12, 2022
@bors retry |
matthiaskrgr
commented
Jan 13, 2022
bors
commented
Jan 13, 2022
bors
commented
Jan 13, 2022
☀️ Test successful - checks-actions |
rust-timer
commented
Jan 13, 2022
Finished benchmarking commit (e916815): comparison url. Summary: This change led to very large relevant improvements 🎉 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Fix a missing dot in the main item heading This pull-request fix a missing `·` in the item header ~~and also make use of ` ` to explicit that the spaces are mandatory~~. | Before | After | | --- | --- | |  |  | PS: This was introduce yesterday by rust-lang#92526 (the migration from Tera to Askama) and is not currently observable in the nightly doc.
Fix a missing dot in the main item heading This pull-request fix a missing `·` in the item header ~~and also make use of ` ` to explicit that the spaces are mandatory~~. | Before | After | | --- | --- | |  |  | PS: This was introduce yesterday by rust-lang#92526 (the migration from Tera to Askama) and is not currently observable in the nightly doc.
Fix a missing dot in the main item heading This pull-request fix a missing `·` in the item header ~~and also make use of ` ` to explicit that the spaces are mandatory~~. | Before | After | | --- | --- | |  |  | PS: This was introduce yesterday by rust-lang#92526 (the migration from Tera to Askama) and is not currently observable in the nightly doc.
…=notriddle Move back templates into html folder Follow-up of rust-lang#92526. r? `@notriddle`
See #84419.
Should probably get a benchmarking run to verify if it has the intended effect on rustdoc performance.
cc @jsha@jyn514.