Skip to content
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

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

GuillaumeGomez
Copy link
Member

It's cleaner and is also easier to manipulate Map rather than Object types.

r? @notriddle

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 13, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 13, 2023

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -488,7 +488,7 @@ pub(crate) fn build_index<'tcx>(

// Collect the index into a string
format!(
r#""{}":{}"#,
r#"["{}",{}]"#,
Copy link
Contributor

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));
}

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense.

Copy link
Member Author

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. ^^'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

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!

Copy link
Contributor

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.

@notriddle
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 13, 2023
@bors
Copy link
Contributor

bors commented Dec 13, 2023

⌛ Trying commit 7502c44 with merge f359997...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 13, 2023
…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`
@bors
Copy link
Contributor

bors commented Dec 13, 2023

☀️ Try build successful - checks-actions
Build commit: f359997 (f359997bbe4cfd8cc0fdd406ce2e41f755e7e03a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f359997): comparison URL.

Overall result: no relevant changes - no action needed

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 may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
1.0% [0.5%, 2.0%] 3
Regressions ❌
(secondary)
3.5% [3.3%, 3.6%] 2
Improvements ✅
(primary)
-1.8% [-1.8%, -1.8%] 1
Improvements ✅
(secondary)
-3.4% [-4.7%, -2.2%] 2
All ❌✅ (primary) 0.3% [-1.8%, 2.0%] 4

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.5%, -0.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.5%, 0.6%] 3

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 673.56s -> 672.051s (-0.22%)
Artifact size: 312.39 MiB -> 312.40 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 14, 2023
@GuillaumeGomez
Copy link
Member Author

Fixed the merge conflict and thanks in advance for the JS checks. :)

@notriddle
Copy link
Contributor

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

@bors
Copy link
Contributor

bors commented Dec 14, 2023

📌 Commit fc72216 has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 14, 2023
@GuillaumeGomez
Copy link
Member Author

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 Map is just that much faster.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 14, 2023
…=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`
@notriddle
Copy link
Contributor

notriddle commented Dec 14, 2023

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.

@GuillaumeGomez
Copy link
Member Author

One can hope. ;)

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2023
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2023
…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
@bors bors merged commit 9ec6205 into rust-lang:master Dec 14, 2023
11 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Dec 14, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2023
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");
Copy link
Contributor

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.

@GuillaumeGomez GuillaumeGomez deleted the js-object-to-map branch December 15, 2023 10:27
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 15, 2023
…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
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 19, 2023
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
Folyd added a commit to huhu/rust-search-extension that referenced this pull request Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants