Skip to content

Conversation

pascaldekloe
Copy link
Contributor

@pascaldekloe pascaldekloe commented Aug 27, 2025

No need for fragmented buffers when formatting.

orig.txt: fmt::write_i128_exp                                                  143.39ns/iter      +/- 0.32
orig.txt: fmt::write_i64_exp                                                    68.72ns/iter      +/- 0.03
new.txt:  fmt::write_i128_exp                                                  138.29ns/iter      +/- 0.50
new.txt:  fmt::write_i64_exp                                                    58.93ns/iter      +/- 4.62

This patch fully eliminates unsafe pointer use (after #135265 and #136594).

r? libs

@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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 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 Aug 27, 2025
@pascaldekloe
Copy link
Contributor Author

https://rust.godbolt.org/z/oe9zr1qd9

Do you want to have another look @tgross35? 🙏 I think we can (and should) format floating points in a single buffer too. If that succeeds then we can drop unstable feature numfmt, package num::fmt. ✨

@tgross35
Copy link
Contributor

Thanks for the ping, sure I'm happy to take the formatting followups here

r? tgross35

@rustbot rustbot assigned tgross35 and unassigned ibraheemdev Aug 27, 2025
@pascaldekloe pascaldekloe force-pushed the int-exp-tune branch 2 times, most recently from 640b1c3 to f135601 Compare August 28, 2025 16:20
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.

Another great change! Looks mostly good, few small things and doc nits

View changes since this review

@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 Sep 5, 2025
@tgross35
Copy link
Contributor

tgross35 commented Sep 5, 2025

Double checking that optimize for size job. Also don't think perf will show anything but may as well run it

@bors2 try jobs=x86_64-gnu,x86_64-gnu-llvm-19-3
@rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

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

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 5, 2025
single buffer for exponent fmt of integers

try-job: x86_64-gnu
try-job: x86_64-gnu-llvm-19-3
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 5, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 5, 2025

☀️ Try build successful (CI)
Build commit: 5fe1474 (5fe147445d224fb3e792d4558c52702727add2fc, parent: 91edc3ebccc4daa46c20a93f4709862376da1fdd)

@rust-timer
Copy link
Collaborator

Queued 5fe1474 with parent 91edc3e, future comparison URL.
There are currently 2 preceding artifacts in the queue.
It will probably take at least ~2.9 hours until the benchmark run finishes.

@pascaldekloe
Copy link
Contributor Author

Another great review! The revision on floating points is starting to work too now. With a little luck we have this piggy washed somewhere next week. 🐷 🧼

@rust-log-analyzer

This comment has been minimized.

@tgross35
Copy link
Contributor

tgross35 commented Sep 5, 2025

Another great review! The revision on floating points is starting to work too now. With a little luck we have this piggy washed somewhere next week. 🐷 🧼

Feel free to request me for these reviews too, I've worked on those a bit. Very much looking forward to them!

If you're working on these and up for it, one easy thing I've wanted for a little while is to refactor the traits a bit. Basically:

Reasoning here is that f128 probably needs a different algorithm, and some of the algorithm-specific constants on the current RawFloat doesn't really make sense for it. Also should make it easier to try something new like the dragonbox algorithm.

@pascaldekloe
Copy link
Contributor Author

The Grisu and Dragon implementations use flt2dec::decoder::Decoded as an abstraction, which seems like an elegant solution, except maybe for the 26-byte footprint. What confuses me is the enormous amount of abstractions (and copies) that get introduced before the Decoded extraction.

DecodableFloat is gone indeed. Don't need the Float abstraction either. It seems so much easier to deal with the edge cases by just calling f64::is_* in the macro_rules themselves. Enumerations FullDecoded and Sign are gone too. I'm hoping it all works out without some hidden catch. 🙏

Can you remove the S-waiting-on-author @tgross35?

@tgross35
Copy link
Contributor

tgross35 commented Sep 6, 2025

Thanks for the updates. I guess the push removed this from the perf queue, but I don't expect to see much there anyway so

@bors r+

Can you remove the S-waiting-on-author @tgross35?

Commenting @rustbot review does this, re-requesting a review should too.

@bors
Copy link
Collaborator

bors commented Sep 6, 2025

📌 Commit 56e95aa 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 Sep 6, 2025
bors added a commit that referenced this pull request Sep 6, 2025
Rollup of 5 pull requests

Successful merges:

 - #139524 (Add socket extensions for cygwin)
 - #145940 (single buffer for exponent fmt of integers)
 - #146206 (identity uses are ok, even if there are no defining uses)
 - #146272 (Update comment for `-Werror` on LLVM builds)
 - #146280 (Make `LetChainsPolicy` public for rustfmt usage)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ebde667 into rust-lang:master Sep 7, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 7, 2025
rust-timer added a commit that referenced this pull request Sep 7, 2025
Rollup merge of #145940 - pascaldekloe:int-exp-tune, r=tgross35

single buffer for exponent fmt of integers

No need for fragmented buffers when formatting.

```
orig.txt: fmt::write_i128_exp                                                  143.39ns/iter      +/- 0.32
orig.txt: fmt::write_i64_exp                                                    68.72ns/iter      +/- 0.03
new.txt:  fmt::write_i128_exp                                                  138.29ns/iter      +/- 0.50
new.txt:  fmt::write_i64_exp                                                    58.93ns/iter      +/- 4.62
```

This patch fully eliminates unsafe pointer use (after #135265 and #136594).

    r? libs
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 8, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#139524 (Add socket extensions for cygwin)
 - rust-lang/rust#145940 (single buffer for exponent fmt of integers)
 - rust-lang/rust#146206 (identity uses are ok, even if there are no defining uses)
 - rust-lang/rust#146272 (Update comment for `-Werror` on LLVM builds)
 - rust-lang/rust#146280 (Make `LetChainsPolicy` public for rustfmt usage)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Sep 10, 2025
single buffer for exponent fmt of integers

No need for fragmented buffers when formatting.

```
orig.txt: fmt::write_i128_exp                                                  143.39ns/iter      +/- 0.32
orig.txt: fmt::write_i64_exp                                                    68.72ns/iter      +/- 0.03
new.txt:  fmt::write_i128_exp                                                  138.29ns/iter      +/- 0.50
new.txt:  fmt::write_i64_exp                                                    58.93ns/iter      +/- 4.62
```

This patch fully eliminates unsafe pointer use (after rust-lang#135265 and rust-lang#136594).

    r? libs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-perf Status: Waiting on a perf run to be completed. T-libs Relevant to the library 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