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

Create a query cache for DefId #108649

Closed
wants to merge 1 commit into from
Closed

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 2, 2023

This adds a specialized cache for DefId which stores a IndexVec of hashmaps reducing the size of the stored hashmap key.

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check1.6924s1.6879s -0.26%
🟣 hyper:check0.2522s0.2527s 0.21%
🟣 regex:check0.9573s0.9542s -0.32%
🟣 syn:check1.5345s1.5265s -0.52%
🟣 syntex_syntax:check5.8742s5.8500s -0.41%
Total10.3105s10.2714s -0.38%
Summary1.0000s0.9974s -0.26%

@rustbot
Copy link
Collaborator

rustbot commented Mar 2, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 2, 2023
@WaffleLapkin
Copy link
Member

@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 Mar 2, 2023
@bors
Copy link
Contributor

bors commented Mar 2, 2023

⌛ Trying commit 18a3ca059d4a99fa0430a44d3d0b48547e038032 with merge 8775a3d31421b553c1b7985b0ef0bb31e2ab121e...

@bors
Copy link
Contributor

bors commented Mar 2, 2023

☀️ Try build successful - checks-actions
Build commit: 8775a3d31421b553c1b7985b0ef0bb31e2ab121e (8775a3d31421b553c1b7985b0ef0bb31e2ab121e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8775a3d31421b553c1b7985b0ef0bb31e2ab121e): comparison URL.

Overall result: ❌ regressions - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.9%] 97
Regressions ❌
(secondary)
0.5% [0.2%, 1.0%] 48
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.2%, 0.9%] 97

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)
- - 0
Regressions ❌
(secondary)
2.7% [1.9%, 4.9%] 6
Improvements ✅
(primary)
-0.8% [-1.4%, -0.4%] 8
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) -0.8% [-1.4%, -0.4%] 8

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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.8%, -1.2%] 8
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) -2.1% [-2.8%, -1.2%] 8

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 2, 2023
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 3, 2023

The bootstrap regressions are a bit high, so it probably make sense to re-evaluate this if #108638 lands.

I also ran unchanged incremental benchmarks locally to see if any of the instruction regressions turned into wall time regressions. They seem to be reasonably neutral.

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check:unchanged0.4674s0.4676s 0.04%
🟣 hyper:check:unchanged0.1323s0.1324s 0.10%
🟣 regex:check:unchanged0.3281s0.3289s 0.25%
🟣 syn:check:unchanged0.6412s0.6369s -0.66%
🟣 syntex_syntax:check:unchanged1.8809s1.8759s -0.27%
Total3.4499s3.4418s -0.23%
Summary1.0000s0.9989s -0.11%

@oli-obk
Copy link
Contributor

oli-obk commented Mar 8, 2023

@rustbot blocked #108638

edit: hmm... i was sure rustbot knew that command

@oli-obk oli-obk added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 8, 2023
@cjgillot
Copy link
Contributor

Do you have a measurement of the data pattern in this cache? Which proportion of local/non-local def-ids? Could you explain why you chose to shard along CrateNum, instead of a IndexVec for local def-ids and a FxHashMap for non-local ones?

@Zoxc
Copy link
Contributor Author

Zoxc commented May 14, 2023

This no longer seems to be an improvement:

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check1.6371s1.6392s 0.13%
🟣 hyper:check0.2519s0.2520s 0.02%
🟣 regex:check0.9170s0.9186s 0.18%
🟣 syn:check1.4787s1.4804s 0.11%
🟣 syntex_syntax:check5.6790s5.6898s 0.19%
Total9.9637s9.9800s 0.16%
Summary1.0000s1.0013s 0.13%

I don't have data on non-local vs. local def-ids, but I did previously try specializing only the storage for local def-ids, which wasn't an improvement.

@Zoxc Zoxc closed this May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) perf-regression Performance regression. S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants