Skip to content

a bit optimize four-digit chunks in integer formatting#159130

Open
chirizxc wants to merge 2 commits into
rust-lang:mainfrom
chirizxc:num_fmt
Open

a bit optimize four-digit chunks in integer formatting#159130
chirizxc wants to merge 2 commits into
rust-lang:mainfrom
chirizxc:num_fmt

Conversation

@chirizxc

@chirizxc chirizxc commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Compiler Explorer GodBolt

Number of asm instructions has decreased (78 -> 59)

The current upstream version contains:

movabs  rax, 9999999999999999
cmp     rsi, rax
ja      .LBB0_2

(if n > 9_999_999_999_999_999 -> go to panic)

But this function isn't part of the public API, so I suppose we can use assert_unchecked(n < 10_000_000_000_000_000);

Similarly, write_quad has been moved to a separate fn to reduce duplication slightly

@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in integer formatting

cc @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 11, 2026
@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

r? @clarfonthey

rustbot has assigned @clarfonthey.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from Darksonn, JohnTitor, Mark-Simulacrum, clarfonthey, jhpratt

@rust-log-analyzer

This comment has been minimized.

@clarfonthey

Copy link
Copy Markdown
Contributor

Haven't reviewed the code yet, but have you actually benchmarked this other than checking the generated assembly? Because number of instructions isn't really a metric we care about, just speed; we have optimize_for_size separately for that.

@chirizxc

Copy link
Copy Markdown
Contributor Author

Haven't reviewed the code yet, but have you actually benchmarked this other than checking the generated assembly? Because number of instructions isn't really a metric we care about, just speed; we have optimize_for_size separately for that.

Yes, I'll send results a little later

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. 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.

4 participants