rust icon indicating copy to clipboard operation
rust copied to clipboard

Specialize `ToString` implementation on `u128` and `i128`

Open GuillaumeGomez opened this issue 6 months ago • 1 comments

Part of https://github.com/rust-lang/rust/issues/135543.

Follow-up of rust-lang/rust#136264.

When working on https://github.com/rust-lang/rust/pull/142098, I realized that i128 and u128 could also benefit from the ToString specialization so here it.

The last commit is just me realizing that I forgot to add the format tests for usize and isize.

GuillaumeGomez avatar Jun 10 '25 13:06 GuillaumeGomez

r? @workingjubilee

rustbot has assigned @workingjubilee. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar Jun 10 '25 13:06 rustbot

:umbrella: The latest upstream changes (presumably #136594) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Jun 12 '25 05:06 bors

Fixed merge conflicts.

GuillaumeGomez avatar Jun 13 '25 12:06 GuillaumeGomez

Having done code review of things that use Rust's feature(min_specialization), I now consider "specialization" a dirty word.

workingjubilee avatar Jun 13 '25 19:06 workingjubilee

Noted, thanks for the title update then. :)

GuillaumeGomez avatar Jun 13 '25 19:06 GuillaumeGomez

@tgross35 I added the comparison in the first comment with the code I use to get the performance comparison.

GuillaumeGomez avatar Jun 16 '25 09:06 GuillaumeGomez

Thanks!

I don't think this needs a pre-merge perf run since we didn't see any perf-visible impact in https://github.com/rust-lang/rust/pull/136594, but it wouldn't hurt to get one after so

@bors r+ rollup=never

Fyi @pascaldekloe since you did the last round of perf boosts for these methods

tgross35 avatar Jun 16 '25 21:06 tgross35

:pushpin: Commit 9b09948897886541bc4f31a9d07bf4a2e1680171 has been approved by tgross35

It is now in the queue for this repository.

bors avatar Jun 16 '25 21:06 bors

:hourglass: Testing commit 9b09948897886541bc4f31a9d07bf4a2e1680171 with merge 5b74275f89b6041bf2e9dc2abcf332e206d4cfca...

bors avatar Jun 20 '25 02:06 bors

:sunny: Test successful - checks-actions Approved by: tgross35 Pushing 5b74275f89b6041bf2e9dc2abcf332e206d4cfca to master...

bors avatar Jun 20 '25 05:06 bors

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 255aa220821c05c3eac7605fce4ea1c9ab2cbdb4 (parent) -> 5b74275f89b6041bf2e9dc2abcf332e206d4cfca (this PR)

Test differences

Show 26 test diffs

Stage 1

  • num::test_isize_to_string: [missing] -> pass (J0)
  • num::test_usize_to_string: [missing] -> pass (J0)

Additionally, 24 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 5b74275f89b6041bf2e9dc2abcf332e206d4cfca --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 4689.2s -> 6379.9s (36.1%)
  2. x86_64-apple-2: 3543.9s -> 4546.3s (28.3%)
  3. dist-x86_64-apple: 9048.3s -> 7868.7s (-13.0%)
  4. mingw-check-tidy: 77.1s -> 69.0s (-10.5%)
  5. x86_64-apple-1: 6181.5s -> 6732.2s (8.9%)
  6. x86_64-rust-for-linux: 2603.2s -> 2819.3s (8.3%)
  7. i686-gnu-1: 7677.0s -> 7174.4s (-6.5%)
  8. x86_64-gnu-llvm-20-3: 6777.2s -> 6353.4s (-6.3%)
  9. dist-aarch64-linux: 8178.3s -> 7691.0s (-6.0%)
  10. dist-x86_64-netbsd: 4763.9s -> 5035.2s (5.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance that executed the job, system noise, invalidated caches, etc. The table above is provided mostly for t-infra members, for simpler debugging of potential CI slow-downs.

github-actions[bot] avatar Jun 20 '25 05:06 github-actions[bot]

Finished benchmarking commit (5b74275f89b6041bf2e9dc2abcf332e206d4cfca): comparison URL.

Overall result: ✅ improvements - no action needed

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

Max RSS (memory usage)

Results (primary -1.9%, secondary -2.4%)

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)
2.8% [2.8%, 2.8%] 1
Improvements ✅
(primary)
-1.9% [-2.4%, -1.3%] 5
Improvements ✅
(secondary)
-2.6% [-6.8%, -1.0%] 23
All ❌✅ (primary) -1.9% [-2.4%, -1.3%] 5

Cycles

Results (secondary 4.3%)

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)
5.2% [2.0%, 10.5%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-3.9%, -3.9%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 692.261s -> 692.705s (0.06%) Artifact size: 371.96 MiB -> 372.00 MiB (0.01%)

rust-timer avatar Jun 20 '25 07:06 rust-timer