-
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 Map instead of Object for source files and search index #118910
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
This comment has been minimized.
This comment has been minimized.
cd898ca
to
7030fb3
Compare
This comment has been minimized.
This comment has been minimized.
7030fb3
to
280da22
Compare
This comment has been minimized.
This comment has been minimized.
280da22
to
fb58181
Compare
This comment has been minimized.
This comment has been minimized.
fb58181
to
7502c44
Compare
@@ -488,7 +488,7 @@ pub(crate) fn build_index<'tcx>( | |||
|
|||
// Collect the index into a string | |||
format!( | |||
r#""{}":{}"#, | |||
r#"["{}",{}]"#, |
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.
I would prefer not to make changes that add more bytes to these files. Instead, could we keep the object representation in JSON and add a function to convert to a map at the end?
function rustdocObjectToMap(obj) {
return new Map(Object.entries(obj));
}
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.
Hum, that kinda kills the original point. Do you mind running a perf check on this already before I make the change please? Like that we'll be able to see if how we transform into a Map
changes anything.
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.
Yeah, that makes sense.
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.
Oh I meant on your JS perf check (I don't think there will be any change on the rust side). I couldn't find it on your profile. ^^'
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.
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.
I was looking on github so now I understand why I didn't find it... Thanks!
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.
There doesn’t seem to be any significant difference in doc bytes.
I’ll try running the performance test on it as soon as the merge conflicts are resolved.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
…try> [rustdoc] Use Map instead of Object for source files and search index It's cleaner and is also easier to manipulate `Map` rather than `Object` types. r? `@notriddle`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f359997): comparison URL. Overall result: no relevant changes - no 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. @bors rollup=never 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.
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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 673.56s -> 672.051s (-0.22%) |
7502c44
to
fc72216
Compare
Fixed the merge conflict and thanks in advance for the JS checks. :) |
Okay, here's the profile. http://notriddle.com/rustdoc-html-demo-8/profile-map/index.html There's also no noticeable change, so let's go with it. @bors r+ rollup |
It tends to be a little bit faster to build actually. Interesting. I wonder if this difference comes from the switch to an array in the JSON or that the |
…=notriddle [rustdoc] Use Map instead of Object for source files and search index It's cleaner and is also easier to manipulate `Map` rather than `Object` types. r? `@notriddle`
Tiny differences are pretty likely to not be real. This is running on my desktop, and isn't a very tightly controlled environment. I'm just happy not to see any order of magnitude blow-ups. |
One can hope. ;) |
…llaumeGomez Rollup of 4 pull requests Successful merges: - rust-lang#118770 (Fix cases where std accidentally relied on inline(never)) - rust-lang#118910 ([rustdoc] Use Map instead of Object for source files and search index) - rust-lang#118914 (Unconditionally register alias-relate in projection goal) - rust-lang#118935 (interpret: extend comment on the inhabitedness check in downcast) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 4 pull requests Successful merges: - rust-lang#118910 ([rustdoc] Use Map instead of Object for source files and search index) - rust-lang#118914 (Unconditionally register alias-relate in projection goal) - rust-lang#118935 (interpret: extend comment on the inhabitedness check in downcast) - rust-lang#118945 (rustc_codegen_ssa: Remove trailing spaces in Display impl for CguReuse) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118910 - GuillaumeGomez:js-object-to-map, r=notriddle [rustdoc] Use Map instead of Object for source files and search index It's cleaner and is also easier to manipulate `Map` rather than `Object` types. r? `@notriddle`
@@ -296,9 +297,9 @@ pub(super) fn write_shared( | |||
.replace("\\\"", "\\\\\"") | |||
)); | |||
all_sources.sort(); | |||
let mut v = String::from("var srcIndex = JSON.parse('{\\\n"); | |||
let mut v = String::from("const srcIndex = new Map(JSON.parse('[\\\n"); |
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.
Oh, crud.
The test cases pass, but this has a race condition. I'll open a PR to fix it in a few minutes.
…laumeGomez rustdoc-search: fix a race condition in search index loading `var` declare it in the global scope, and `const` does not. It needs to be declared in global scope. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const > const declarations do not create properties on [globalThis](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) when declared at the top level of a script. Fixes a regression introduced by rust-lang#118910
rustdoc-search: fix a race condition in search index loading `var` declare it in the global scope, and `const` does not. It needs to be declared in global scope. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const > const declarations do not create properties on [globalThis](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) when declared at the top level of a script. Fixes a regression introduced by rust-lang/rust#118910
It's cleaner and is also easier to manipulate
Map
rather thanObject
types.r? @notriddle