Skip to content

Conversation

@alexheretic
Copy link
Contributor

@alexheretic alexheretic commented Nov 11, 2025

This is an interesting performance trade-off. We can significantly improve inline SmolStr::clone performance at the expense of heap performance if we use #[cold] & #[inline(never)] hints against the latter.

This is a better result for users that care most about inline variant performance. If we think that represents most users it may be worth it.

Benchmarks

  • inline clones 4.1ns -> 0.8ns 🙂
  • heap clones 2.8ns -> 5.8ns 🙁
group                      master                  pr
-----                      ------                  --
SmolStr::clone len=12      4.86      4.1±0.00ns    1.00      0.8±0.00ns
SmolStr::clone len=50      1.00      2.8±0.02ns    2.05      5.8±0.01ns
SmolStr::clone len=1000    1.00      2.8±0.01ns    2.04      5.8±0.02ns

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants