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

Lazy-page Symbol interner #136401

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Mark-Simulacrum
Copy link
Member

This is a simple and only semi-correct impl that works well only on 64-bit platforms where we can lazily allocate zeroed pages (i.e., not actually use up memory for zeroed pages), meaning that we can grab a 4GB chunk of memory for all interned strings and then just offset allocate into that.

This already fixes unsoundness in the Symbol::as_str by leaking that 4gb memory chunk, but could also be faster (TBD).

A rewrite supporting ~any platform should be pretty straightforward by sharding the allocation and manually lazily allocating it in chunks.

r? @ghost -- this impl can't land due to being non-workable on Windows, opening for initial perf run

@rustbot rustbot added 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 Feb 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 1, 2025

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@Mark-Simulacrum
Copy link
Member Author

@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 Feb 1, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2025
…try>

Lazy-page Symbol interner

This is a simple and only semi-correct impl that works well only on 64-bit platforms where we can lazily allocate zeroed pages (i.e., not actually use up memory for zeroed pages), meaning that we can grab a 4GB chunk of memory for all interned strings and then just offset allocate into that.

This already fixes unsoundness in the Symbol::as_str by leaking that 4gb memory chunk, but could also be faster (TBD).

A rewrite supporting ~any platform should be pretty straightforward by sharding the allocation and manually lazily allocating it in chunks.

r? `@ghost` -- this impl can't land due to being non-workable on Windows, opening for initial perf run
@bors
Copy link
Contributor

bors commented Feb 1, 2025

⌛ Trying commit e6f870b with merge 085fad86adba2eafccd19c18a6c7ed5d3fbecbab...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 1, 2025

☀️ Try build successful - checks-actions
Build commit: 085fad8 (085fad86adba2eafccd19c18a6c7ed5d3fbecbab)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (085fad8): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
0.4% [0.2%, 0.8%] 7
Improvements ✅
(primary)
-0.5% [-0.8%, -0.2%] 4
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.1%] 20
All ❌✅ (primary) -0.4% [-0.8%, 0.2%] 5

Max RSS (memory usage)

Results (primary -0.2%, secondary -3.0%)

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)
3.5% [3.2%, 3.8%] 3
Regressions ❌
(secondary)
2.4% [1.7%, 3.4%] 3
Improvements ✅
(primary)
-2.1% [-3.5%, -1.0%] 6
Improvements ✅
(secondary)
-3.7% [-10.1%, -0.8%] 24
All ❌✅ (primary) -0.2% [-3.5%, 3.8%] 9

Cycles

Results (secondary 1.4%)

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.9% [2.3%, 3.3%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.1%] 2
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 777.851s -> 776.705s (-0.15%)
Artifact size: 328.84 MiB -> 328.88 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 2, 2025
This is a simple impl that works well only on 64-bit platforms where we
can lazily allocate zeroed pages (i.e., not actually use up memory for
zeroed pages), meaning that we can grab a 4GB chunk of memory for all
interned strings and then just offset allocate into that.

This already fixes unsoundness in the Symbol::as_str by leaking that 4gb
memory chunk, but could also be faster (TBD).

A rewrite supporting ~any platform should be pretty straightforward by
sharding the allocation and manually lazily allocating it in chunks.
@Mark-Simulacrum
Copy link
Member Author

@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 Feb 2, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
…try>

Lazy-page Symbol interner

This is a simple and only semi-correct impl that works well only on 64-bit platforms where we can lazily allocate zeroed pages (i.e., not actually use up memory for zeroed pages), meaning that we can grab a 4GB chunk of memory for all interned strings and then just offset allocate into that.

This already fixes unsoundness in the Symbol::as_str by leaking that 4gb memory chunk, but could also be faster (TBD).

A rewrite supporting ~any platform should be pretty straightforward by sharding the allocation and manually lazily allocating it in chunks.

r? `@ghost` -- this impl can't land due to being non-workable on Windows, opening for initial perf run
@bors
Copy link
Contributor

bors commented Feb 2, 2025

⌛ Trying commit b120ca9 with merge bad4b51...

@bors
Copy link
Contributor

bors commented Feb 2, 2025

☀️ Try build successful - checks-actions
Build commit: bad4b51 (bad4b5105a2fc0c2d704f0d02aac6fd34ec7b4a9)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bad4b51): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.7% [0.2%, 3.9%] 223
Regressions ❌
(secondary)
1.2% [0.1%, 3.9%] 142
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.2%] 14
All ❌✅ (primary) 0.7% [0.2%, 3.9%] 223

Max RSS (memory usage)

Results (primary -0.2%, secondary -3.2%)

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)
3.2% [2.8%, 3.5%] 2
Regressions ❌
(secondary)
3.0% [2.1%, 3.7%] 4
Improvements ✅
(primary)
-1.6% [-2.5%, -0.6%] 5
Improvements ✅
(secondary)
-4.4% [-10.1%, -1.0%] 21
All ❌✅ (primary) -0.2% [-2.5%, 3.5%] 7

Cycles

Results (primary 2.0%, secondary 1.3%)

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)
2.0% [0.9%, 3.1%] 25
Regressions ❌
(secondary)
2.9% [1.8%, 4.3%] 34
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.3%, -2.1%] 13
All ❌✅ (primary) 2.0% [0.9%, 3.1%] 25

Binary size

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

Bootstrap: 777.275s -> 777.884s (0.08%)
Artifact size: 328.69 MiB -> 328.73 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 2, 2025
@Mark-Simulacrum
Copy link
Member Author

@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 Feb 2, 2025
@bors
Copy link
Contributor

bors commented Feb 2, 2025

⌛ Trying commit 79a6cff with merge ad08842...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 2, 2025
…try>

Lazy-page Symbol interner

This is a simple and only semi-correct impl that works well only on 64-bit platforms where we can lazily allocate zeroed pages (i.e., not actually use up memory for zeroed pages), meaning that we can grab a 4GB chunk of memory for all interned strings and then just offset allocate into that.

This already fixes unsoundness in the Symbol::as_str by leaking that 4gb memory chunk, but could also be faster (TBD).

A rewrite supporting ~any platform should be pretty straightforward by sharding the allocation and manually lazily allocating it in chunks.

r? `@ghost` -- this impl can't land due to being non-workable on Windows, opening for initial perf run
@bors
Copy link
Contributor

bors commented Feb 2, 2025

☀️ Try build successful - checks-actions
Build commit: ad08842 (ad088427a5424ba3008dd911900b7aff41db7be2)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad08842): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 3
Regressions ❌
(secondary)
0.4% [0.2%, 0.8%] 9
Improvements ✅
(primary)
-0.4% [-0.7%, -0.2%] 4
Improvements ✅
(secondary)
-0.3% [-0.6%, -0.1%] 20
All ❌✅ (primary) -0.1% [-0.7%, 0.2%] 7

Max RSS (memory usage)

Results (primary -0.3%, secondary -3.0%)

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)
2.8% [2.6%, 3.1%] 2
Regressions ❌
(secondary)
3.2% [0.9%, 8.0%] 5
Improvements ✅
(primary)
-1.6% [-2.2%, -1.0%] 5
Improvements ✅
(secondary)
-4.7% [-10.1%, -1.6%] 18
All ❌✅ (primary) -0.3% [-2.2%, 3.1%] 7

Cycles

Results (secondary -3.4%)

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)
- - 0
Improvements ✅
(secondary)
-3.4% [-4.2%, -2.8%] 5
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 778.659s -> 777.495s (-0.15%)
Artifact size: 328.72 MiB -> 328.71 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants