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

Support encoding spans with relative offsets #119302

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Dec 25, 2023

The relative offset is often smaller than the absolute offset, and with
the LEB128 encoding, this ends up cutting the overall metadata size
considerably (~1.5 megabytes on libcore). We can support both relative
and absolute encodings essentially for free since we already take a full
byte to differentiate between direct and indirect encodings (so an extra
variant is quite cheap).

@rustbot
Copy link
Collaborator

rustbot commented Dec 25, 2023

r? @WaffleLapkin

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

@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 Dec 25, 2023
@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 Dec 25, 2023
@bors
Copy link
Contributor

bors commented Dec 25, 2023

⌛ Trying commit 9aec3df with merge a32f9c5...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 25, 2023
Encode spans with relative offsets

The relative offset is always smaller than the absolute offset, and with the LEB128 encoding, this ends up cutting the overall metadata size considerably (~1.5 megabytes on libcore).
@bors
Copy link
Contributor

bors commented Dec 25, 2023

☀️ Try build successful - checks-actions
Build commit: a32f9c5 (a32f9c5c445f63284f8834ef40bd32c67196a1a1)

@rust-timer

This comment has been minimized.

@Mark-Simulacrum Mark-Simulacrum changed the title Encode spans with relative offsets Support encoding spans with relative offsets Dec 25, 2023
@Mark-Simulacrum
Copy link
Member Author

Pushed optionally-relative encoding -- it's strictly better than before now from a bytes-on-disk perspective, we can run another try + perf run but my sense is that it's probably not necessary if this one comes back clean.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a32f9c5): comparison URL.

Overall result: ✅ improvements - 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 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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.5%] 1
All ❌✅ (primary) - - 0

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)
1.5% [1.5%, 1.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.0% [-3.6%, -2.5%] 2
All ❌✅ (primary) - - 0

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)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.6% [1.6%, 1.6%] 1

Binary size

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)
-1.3% [-4.6%, -0.1%] 115
Improvements ✅
(secondary)
-2.0% [-4.0%, -0.0%] 59
All ❌✅ (primary) -1.3% [-4.6%, -0.1%] 115

Bootstrap: 670.163s -> 669.991s (-0.03%)
Artifact size: 312.56 MiB -> 312.44 MiB (-0.04%)

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

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

r=me with nits
@rustbot author

Entry::Occupied(o) => {
// If an offset is smaller than the absolute position, we encode with the offset.
// This saves space since smaller numbers encode in less bits.
let offset = s.opaque.position() - *o.get();
Copy link
Member

Choose a reason for hiding this comment

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

can this ever underflow? (if it can the code probably needs to account for that, if it can't, it would be nice to have a comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it shouldn't be possible. We write ~all metadata bytes strictly increasing positions in the buffer, so the current position must be larger than the position we saved into the HashMap.

I'll add a comment.

Entry::Occupied(o) => {
// If an offset is smaller than the absolute position, we encode with the offset.
// This saves space since smaller numbers encode in less bits.
let offset = s.opaque.position() - *o.get();
Copy link
Member

Choose a reason for hiding this comment

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

since *o.get() is used multiple times, it would be nicer to have a variable for it like let &addr = o.get();.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can do.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 27, 2023
The relative offset is often smaller than the absolute offset, and with
the LEB128 encoding, this ends up cutting the overall metadata size
considerably (~1.5 megabytes on libcore). We can support both relative
and absolute encodings essentially for free since we already take a full
byte to differentiate between direct and indirect encodings (so an extra
variant is quite cheap).
@Mark-Simulacrum
Copy link
Member Author

@bors r=WaffleLapkin

@bors
Copy link
Contributor

bors commented Dec 27, 2023

📌 Commit 9c5293c has been approved by WaffleLapkin

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 27, 2023
@bors
Copy link
Contributor

bors commented Dec 27, 2023

⌛ Testing commit 9c5293c with merge 2f92fd7...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 27, 2023
…ffleLapkin

Support encoding spans with relative offsets

The relative offset is often smaller than the absolute offset, and with
the LEB128 encoding, this ends up cutting the overall metadata size
considerably (~1.5 megabytes on libcore). We can support both relative
and absolute encodings essentially for free since we already take a full
byte to differentiate between direct and indirect encodings (so an extra
variant is quite cheap).
@rust-log-analyzer
Copy link
Collaborator

The job dist-armv7-linux failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@bors
Copy link
Contributor

bors commented Dec 27, 2023

💔 Test failed - checks-actions

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

lqd commented Dec 27, 2023

failed to get successful HTTP response from 'https://crates.io/api/v1/crates/bitmaps/2.1.0/download' (3.163.158.6), got 408

@bors retry network timeout issue

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

bors commented Dec 27, 2023

⌛ Testing commit 9c5293c with merge 15755f3...

@lqd
Copy link
Member

lqd commented Dec 27, 2023

There's a crates.io outage, currently in recovery, so we'll see if it works this time.

@bors
Copy link
Contributor

bors commented Dec 27, 2023

☀️ Test successful - checks-actions
Approved by: WaffleLapkin
Pushing 15755f3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 27, 2023
@bors bors merged commit 15755f3 into rust-lang:master Dec 27, 2023
@rustbot rustbot added this to the 1.77.0 milestone Dec 27, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (15755f3): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -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)
- - 0
Regressions ❌
(secondary)
1.2% [1.2%, 1.2%] 1
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.7% [-0.7%, -0.7%] 1

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)
1.0% [0.6%, 1.5%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.0% [0.6%, 1.5%] 3

Binary size

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)
-1.4% [-4.9%, -0.1%] 115
Improvements ✅
(secondary)
-2.0% [-4.4%, -0.0%] 58
All ❌✅ (primary) -1.4% [-4.9%, -0.1%] 115

Bootstrap: 671.868s -> 670.827s (-0.15%)
Artifact size: 312.43 MiB -> 312.33 MiB (-0.03%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants