Skip to content

[PERF EXPERIMENT] Use a SmallVec for item paths (Vec<Symbol>s) - #157629

Draft
yotamofek wants to merge 1 commit into
rust-lang:mainfrom
yotamofek:pr/rustdoc/item-path
Draft

[PERF EXPERIMENT] Use a SmallVec for item paths (Vec<Symbol>s)#157629
yotamofek wants to merge 1 commit into
rust-lang:mainfrom
yotamofek:pr/rustdoc/item-path

Conversation

@yotamofek

Copy link
Copy Markdown
Contributor

Checked the average size of all dropped ItemPaths when x perf is run, the average is 3.1 elements.
So use a SmallVec with room for 4 inline elems, since it takes up 24 bytes for either 3 or 4.

Checked the average size of all dropped `ItemPath`s when `x perf` is run,
the average is 3.1 elements.
So use a `SmallVec` with room for 4 inline elems, since it takes up 24 bytes for either 3 or 4.
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 8, 2026
@yotamofek

Copy link
Copy Markdown
Contributor 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 Jun 8, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 8, 2026
[PERF EXPERIMENT] Use a `SmallVec` for item paths (`Vec<Symbol>`s)
@rust-bors

rust-bors Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 6b15d7d (6b15d7d71225907d86d254aad345c7f8526ab55e, parent: cb46fbb8c6ea799c6fba9188ed889275c35a8c28)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (6b15d7d): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 517.707s -> 517.743s (0.01%)
Artifact size: 400.82 MiB -> 400.85 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 9, 2026
@yotamofek

Copy link
Copy Markdown
Contributor Author

@GuillaumeGomez probably not worth it, right?

@GuillaumeGomez

Copy link
Copy Markdown
Member

Not really indeed. ^^'

Isn't there a way to have a similar approach without the need for all the conversions?

@yotamofek

Copy link
Copy Markdown
Contributor Author

We could just use SmallVec<[Symbol; 4]> directly (or through an alias) instead of new-typing it, and that'll allow us to get rid of some .into()s.
But then if we do have a newtype, we could do nice things such as give it inherent methods, e.g. for joining the path parts with :: etc...

}
}

impl<'a> IntoIterator for &'a ItemPath {

@GuillaumeGomez GuillaumeGomez Jun 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we have deref implemented already, do we need to have this IntoIterator implementation?

View changes since the review

@GuillaumeGomez

Copy link
Copy Markdown
Member

Hum... Maybe build a bit more on top of this to see if we can get more out of this newtype? If the performance improvement is bigger, it's much simpler to accept this newtype with its implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants