Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fmt of non-decimal radix untangled #143730

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

Merged
bors merged 4 commits into rust-lang:master from pascaldekloe:fmt-radix-trim
Aug 19, 2025
Merged

Conversation

Copy link
Contributor

@pascaldekloe pascaldekloe commented Jul 10, 2025

Have the implementation match its decimal counterpart.

  • Digit table instead of conversion functions
  • Correct buffer size per radix
  • Elimination of dead code for negative
  • No trait abstraction for integers

Original Performance

 fmt::write_10ints_bin 393.03ns/iter +/- 1.41
 fmt::write_10ints_hex 316.84ns/iter +/- 1.49
 fmt::write_10ints_oct 327.16ns/iter +/- 0.46

Patched Performance

 fmt::write_10ints_bin 392.31ns/iter +/- 3.05
 fmt::write_10ints_hex 302.41ns/iter +/- 5.48
 fmt::write_10ints_oct 322.01ns/iter +/- 3.82

r? tgross35

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 10, 2025
Copy link
Contributor Author

This comment has been minimized.

This comment has been minimized.

Copy link
Collaborator

bors commented Jul 17, 2025

☔ The latest upstream changes (presumably #144044) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Contributor Author

Can you either have a look or reassign @tgross35? Got a followup pending on this one...

Copy link
Contributor

tgross35 commented Jul 18, 2025
edited
Loading

I'll reassign for now, but if nobody beats me to it I'll take a look on Monday

r? libs

(leaving myself assigned so it stays on my list)

pascaldekloe reacted with heart emoji

@tgross35 tgross35 self-assigned this Jul 18, 2025
Copy link
Contributor

By the way; if you are interested, we could use some int (and float) formatting and parsing benchmarks at https://github.com/rust-lang/rustc-perf/blob/2120e3b7b8996e96858b88edefea371679a3d415/collector/runtime-benchmarks/fmt/src/main.rs (I just learned that is possible), which would mean they get run as part of our pretty extensive perf infra rather than you needing to post the results of local runs.

Copy link
Contributor Author

Interesting indeed @tgross35. The specialized benchmarks we have at the moment (such as write_u8_min and write_u64_max) won't scale. Think about how many benchmarks we need for fmt::LowerExp with edge cases on alignment and precision. I am curious to hear what you think of the _10ints_ concept in this patch. The idea is to have a balanced mix of common cases.

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Few notes, haven't looked at patches 3 & 4 yet

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Guess it's still on me, but this looks pretty good! Just a few small things

pascaldekloe reacted with heart emoji

This comment has been minimized.

* correct buffer size
* no trait abstraction
* similar to decimal

This comment has been minimized.

Copy link
Contributor

@bors2 try jobs=x86_64-gnu-llvm-19-3

r=me with that passing

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 12, 2025
fmt of non-decimal radix untangled
try-job: x86_64-gnu-llvm-19-3
Copy link

rust-bors bot commented Aug 12, 2025

💔 Test for 59e4e19 failed: CI. Failed jobs:

This comment has been minimized.

Copy link
Contributor

Huh, does it get &T sometimes and just T others?

You can check that config locally with rust.std-features = ["optimize_for_size"] in your bootstrap.toml

pascaldekloe reacted with thumbs up emoji

This comment was marked as spam.

Copy link
Contributor Author

You can check that config locally with rust.std-features = ["optimize_for_size"] in your bootstrap.toml

Apparently such changes don't always get picked up by ./x test. I will dig in deeper into why at some point if time permits.

Copy link
Contributor

@bors2 try jobs=x86_64-gnu-llvm-19-3

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 18, 2025
fmt of non-decimal radix untangled
try-job: x86_64-gnu-llvm-19-3
Copy link

rust-bors bot commented Aug 18, 2025

☀️ Try build successful (CI)
Build commit: 054eb81 (054eb81f0211a6054e03c271809d347281601102, parent: 239e8b1b47b34120287ec36b33228c1e177f0c38)

Copy link
Contributor

Thanks for the fix!

@bors r+

Apparently such changes don't always get picked up by ./x test. I will dig in deeper into why at some point if time permits.

Maybe just bring this up the #t-infra/bootstrap Zulip, somebody may know a better idea of why

pascaldekloe reacted with thumbs up emoji

Copy link
Collaborator

bors commented Aug 18, 2025

📌 Commit 1f77424 has been approved by tgross35

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 Aug 18, 2025
Copy link
Member

@bors rollup=maybe

jieyouxu added a commit to jieyouxu/rust that referenced this pull request Aug 19, 2025
...oss35
fmt of non-decimal radix untangled
Have the implementation match its decimal counterpart.
* Digit table instead of conversion functions
* Correct buffer size per radix
* Elimination of dead code for negative
* No trait abstraction for integers
#### Original Performance
```
 fmt::write_10ints_bin 393.03ns/iter +/- 1.41
 fmt::write_10ints_hex 316.84ns/iter +/- 1.49
 fmt::write_10ints_oct 327.16ns/iter +/- 0.46
```
#### Patched Performance
```
 fmt::write_10ints_bin 392.31ns/iter +/- 3.05
 fmt::write_10ints_hex 302.41ns/iter +/- 5.48
 fmt::write_10ints_oct 322.01ns/iter +/- 3.82
```
r? tgross35
bors added a commit that referenced this pull request Aug 19, 2025
Rollup of 15 pull requests
Successful merges:
 - #139345 (Extend `QueryStability` to handle `IntoIterator` implementations)
 - #140740 (Add `-Zindirect-branch-cs-prefix`)
 - #142079 (nll-relate: improve hr opaque types support)
 - #142938 (implement std::fs::set_permissions_nofollow on unix)
 - #143730 (fmt of non-decimal radix untangled)
 - #144767 (Correct some grammar in integer documentation)
 - #144906 (Require approval from t-infra instead of t-release on tier bumps)
 - #144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
 - #145025 (run spellcheck as a tidy extra check in ci)
 - #145099 (rustc_target: Add the `32s` target feature for LoongArch)
 - #145166 (suggest using `pub(crate)` for E0364)
 - #145255 (dec2flt: Provide more valid inputs examples)
 - #145306 (Add tracing to various miscellaneous functions)
 - #145336 (Hide docs for `core::unicode`)
 - #145585 (Miri: fix handling of in-place argument and return place handling)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 4327e69 into rust-lang:master Aug 19, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 19, 2025
rust-timer added a commit that referenced this pull request Aug 19, 2025
Rollup merge of #143730 - pascaldekloe:fmt-radix-trim, r=tgross35
fmt of non-decimal radix untangled
Have the implementation match its decimal counterpart.
* Digit table instead of conversion functions
* Correct buffer size per radix
* Elimination of dead code for negative
* No trait abstraction for integers
#### Original Performance
```
 fmt::write_10ints_bin 393.03ns/iter +/- 1.41
 fmt::write_10ints_hex 316.84ns/iter +/- 1.49
 fmt::write_10ints_oct 327.16ns/iter +/- 0.46
```
#### Patched Performance
```
 fmt::write_10ints_bin 392.31ns/iter +/- 3.05
 fmt::write_10ints_hex 302.41ns/iter +/- 5.48
 fmt::write_10ints_oct 322.01ns/iter +/- 3.82
```
r? tgross35
Kobzol pushed a commit to Kobzol/rust that referenced this pull request Aug 19, 2025
Rollup of 15 pull requests
Successful merges:
 - rust-lang#139345 (Extend `QueryStability` to handle `IntoIterator` implementations)
 - rust-lang#140740 (Add `-Zindirect-branch-cs-prefix`)
 - rust-lang#142079 (nll-relate: improve hr opaque types support)
 - rust-lang#142938 (implement std::fs::set_permissions_nofollow on unix)
 - rust-lang#143730 (fmt of non-decimal radix untangled)
 - rust-lang#144767 (Correct some grammar in integer documentation)
 - rust-lang#144906 (Require approval from t-infra instead of t-release on tier bumps)
 - rust-lang#144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
 - rust-lang#145025 (run spellcheck as a tidy extra check in ci)
 - rust-lang#145099 (rustc_target: Add the `32s` target feature for LoongArch)
 - rust-lang#145166 (suggest using `pub(crate)` for E0364)
 - rust-lang#145255 (dec2flt: Provide more valid inputs examples)
 - rust-lang#145306 (Add tracing to various miscellaneous functions)
 - rust-lang#145336 (Hide docs for `core::unicode`)
 - rust-lang#145585 (Miri: fix handling of in-place argument and return place handling)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 20, 2025
Rollup of 15 pull requests
Successful merges:
 - rust-lang/rust#139345 (Extend `QueryStability` to handle `IntoIterator` implementations)
 - rust-lang/rust#140740 (Add `-Zindirect-branch-cs-prefix`)
 - rust-lang/rust#142079 (nll-relate: improve hr opaque types support)
 - rust-lang/rust#142938 (implement std::fs::set_permissions_nofollow on unix)
 - rust-lang/rust#143730 (fmt of non-decimal radix untangled)
 - rust-lang/rust#144767 (Correct some grammar in integer documentation)
 - rust-lang/rust#144906 (Require approval from t-infra instead of t-release on tier bumps)
 - rust-lang/rust#144983 (Rehome 37 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
 - rust-lang/rust#145025 (run spellcheck as a tidy extra check in ci)
 - rust-lang/rust#145099 (rustc_target: Add the `32s` target feature for LoongArch)
 - rust-lang/rust#145166 (suggest using `pub(crate)` for E0364)
 - rust-lang/rust#145255 (dec2flt: Provide more valid inputs examples)
 - rust-lang/rust#145306 (Add tracing to various miscellaneous functions)
 - rust-lang/rust#145336 (Hide docs for `core::unicode`)
 - rust-lang/rust#145585 (Miri: fix handling of in-place argument and return place handling)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Aug 20, 2025
...oss35
fmt of non-decimal radix untangled
Have the implementation match its decimal counterpart.
* Digit table instead of conversion functions
* Correct buffer size per radix
* Elimination of dead code for negative
* No trait abstraction for integers
#### Original Performance
```
 fmt::write_10ints_bin 393.03ns/iter +/- 1.41
 fmt::write_10ints_hex 316.84ns/iter +/- 1.49
 fmt::write_10ints_oct 327.16ns/iter +/- 0.46
```
#### Patched Performance
```
 fmt::write_10ints_bin 392.31ns/iter +/- 3.05
 fmt::write_10ints_hex 302.41ns/iter +/- 5.48
 fmt::write_10ints_oct 322.01ns/iter +/- 3.82
```
r? tgross35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@tgross35 tgross35 tgross35 approved these changes

Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Milestone
1.91.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /