Skip to content

use u64 limbs in core::num::bignum - #162879

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
kiana1kaslana:bignum-u64-limbs
Sep 19, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
kiana1kaslana:bignum-u64-limbs

Conversation

@kiana1kaslana

@kiana1kaslana kiana1kaslana commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

View all comments

The code was totally written by myself without any llm.Last time I write description with the polish of llm,but this time I write the description on my own.
This pr use u64 limbs in core::num::bignum

Since the unlocking of u128 in #146277, a discussion happened in #137887. From which I know maybe I can help making a u64 digit path.

changes are as follows:

  1. total capacity of bignum remains the same, 1280bits. Big32x40=>Big64x20
  2. add u64 entry to SMALL_POW5.
  3. update the corresponding coretests to use Big64x20.

performance:

​ I ran benchmarks on my PC,use

./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy

​ results are as follows:

Benchmark Big32x40 (ns/iter) Big64x20 (ns/iter) Speedup
bench_big_exact_inf 33,568 ~21,700 1.55x
bench_big_shortest 2,913 ~1,880 1.55x
bench_big_exact_12 1,680 ~1,030 1.63x
bench_big_exact_3 878 ~585 1.50x
bench_small_exact_inf 1,353 ~1,425 ~1.0x
bench_small_exact_12 277 ~220 1.26x
bench_small_exact_3 170 ~134 1.27x
bench_small_shortest 320 ~275 1.16x

@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in float parsing

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 Sep 17, 2026
@rustbot

rustbot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @clarfonthey (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

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

Comment thread library/core/src/num/imp/bignum.rs
@tgross35

Copy link
Copy Markdown
Member

This PR was initially created as #162746

​ I ran benchmarks on my PC,use

./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy

Could you post your processor type so we have an idea of what this is on? Also these don't look like the invocations to run benchmarks.

@kiana1kaslana

Copy link
Copy Markdown
Contributor Author

This PR was initially created as #162746

​ I ran benchmarks on my PC,use

./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy

Could you post your processor type so we have an idea of what this is on? Also these don't look like the invocations to run benchmarks.

I used the wrong command, it should be ./x bench library/coretests --test-args bignum. My CPU is AMD Ryzen 9 7940HX. After my changes I will rerun the benchmarks and update the data.

@kiana1kaslana

Copy link
Copy Markdown
Contributor Author

test command:
./x bench library/coretests --test-args dragon
data(u64 limbs):
benchmarks:
num::flt2dec::strategy::dragon::bench_big_exact_12 655.21ns/iter +/- 227.79
num::flt2dec::strategy::dragon::bench_big_exact_3 358.60ns/iter +/-91.29
num::flt2dec::strategy::dragon::bench_big_exact_inf 12631.63ns/iter +/- 4610.84
num::flt2dec::strategy::dragon::bench_big_shortest 1128.00ns/iter +/- 300.20
num::flt2dec::strategy::dragon::bench_small_exact_12 137.03ns/iter +/-31.65
num::flt2dec::strategy::dragon::bench_small_exact_3 85.67ns/iter +/-19.77
num::flt2dec::strategy::dragon::bench_small_exact_inf 909.91ns/iter +/- 260.49
num::flt2dec::strategy::dragon::bench_small_shortest 174.78ns/iter +/-24.34

I think the comparison bettween u64 and u32 can refer to rust-timer.

Comment thread library/core/src/num/imp/bignum.rs Outdated
Comment thread library/core/src/num/imp/flt2dec/strategy/dragon.rs
@kiana1kaslana

Copy link
Copy Markdown
Contributor Author

Well, I've learned the use of unbounded_shr(), thanks.For the macro approach, I'd like to keep the tables as-is for this round

@clarfonthey

Copy link
Copy Markdown
Contributor

Always happy to find more uses for new libs functions. In terms of the tables, I'm okay with that, but would you mind adding a FIXME comment somewhere around the first table definition and say that maybe we should define these using a macro instead?

Comment thread library/core/src/num/imp/bignum.rs
Comment thread library/coretests/tests/num/flt2dec/strategy/dragon.rs Outdated
Comment thread library/coretests/tests/num/bignum.rs Outdated
Comment thread library/core/src/num/imp/flt2dec/strategy/dragon.rs Outdated
@kiana1kaslana

Copy link
Copy Markdown
Contributor Author

Ok, I've polished the code as you said,thanks for your guidance.

Comment thread library/core/src/num/imp/flt2dec/strategy/dragon.rs Outdated
@clarfonthey

Copy link
Copy Markdown
Contributor

One final comment, otherwise looks good to me. Thank you for working on this!

Co-authored-by: Clar Fon <15850505+clarfonthey@users.noreply.github.com>
@clarfonthey

Copy link
Copy Markdown
Contributor

@bors r+ rollup

Thank you!

@rust-bors

rust-bors Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9d8d943 has been approved by clarfonthey

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
…clarfonthey

use u64 limbs in core::num::bignum

The code was totally written by myself without any llm.Last time I write description with the polish of llm,but this time I write the description on my own.
This pr use u64 limbs in core::num::bignum

Since the unlocking of u128 in rust-lang#146277, a discussion happened in rust-lang#137887. From which I know maybe I can help making a u64 digit path.

changes are as follows:

1.  total capacity of bignum remains the same, 1280bits. Big32x40=>Big64x20
2. add u64 entry to SMALL_POW5.
3. update the corresponding coretests to use Big64x20.

performance:

​	I ran benchmarks on my PC,use

```text
./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy
```

​    results are as follows:

| Benchmark               | Big32x40 (ns/iter) | Big64x20 (ns/iter) | Speedup |
| ----------------------- | ------------------ | ------------------ | ------- |
| `bench_big_exact_inf`   | 33,568             | ~21,700            | 1.55x   |
| `bench_big_shortest`    | 2,913              | ~1,880             | 1.55x   |
| `bench_big_exact_12`    | 1,680              | ~1,030             | 1.63x   |
| `bench_big_exact_3`     | 878                | ~585               | 1.50x   |
| `bench_small_exact_inf` | 1,353              | ~1,425             | ~1.0x   |
| `bench_small_exact_12`  | 277                | ~220               | 1.26x   |
| `bench_small_exact_3`   | 170                | ~134               | 1.27x   |
| `bench_small_shortest`  | 320                | ~275               | 1.16x   |
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 18, 2026
…clarfonthey

use u64 limbs in core::num::bignum

The code was totally written by myself without any llm.Last time I write description with the polish of llm,but this time I write the description on my own.
This pr use u64 limbs in core::num::bignum

Since the unlocking of u128 in rust-lang#146277, a discussion happened in rust-lang#137887. From which I know maybe I can help making a u64 digit path.

changes are as follows:

1.  total capacity of bignum remains the same, 1280bits. Big32x40=>Big64x20
2. add u64 entry to SMALL_POW5.
3. update the corresponding coretests to use Big64x20.

performance:

​	I ran benchmarks on my PC,use

```text
./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy
```

​    results are as follows:

| Benchmark               | Big32x40 (ns/iter) | Big64x20 (ns/iter) | Speedup |
| ----------------------- | ------------------ | ------------------ | ------- |
| `bench_big_exact_inf`   | 33,568             | ~21,700            | 1.55x   |
| `bench_big_shortest`    | 2,913              | ~1,880             | 1.55x   |
| `bench_big_exact_12`    | 1,680              | ~1,030             | 1.63x   |
| `bench_big_exact_3`     | 878                | ~585               | 1.50x   |
| `bench_small_exact_inf` | 1,353              | ~1,425             | ~1.0x   |
| `bench_small_exact_12`  | 277                | ~220               | 1.26x   |
| `bench_small_exact_3`   | 170                | ~134               | 1.27x   |
| `bench_small_shortest`  | 320                | ~275               | 1.16x   |
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #162715 (don't calculate dtors if the self ty has impossible bounds)
 - #162740 (stdarch subtree update)
 - #162824 (link Enzyme and the offload with in-tree lld if possible)
 - #162946 (Simplify query stack printing)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162879 (use u64 limbs in core::num::bignum)
 - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag)
 - #162905 (c-variadic: add checks for windows i686)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
 - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #162715 (don't calculate dtors if the self ty has impossible bounds)
 - #162740 (stdarch subtree update)
 - #162946 (Simplify query stack printing)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162879 (use u64 limbs in core::num::bignum)
 - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag)
 - #162905 (c-variadic: add checks for windows i686)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
 - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
rust-bors Bot pushed a commit that referenced this pull request Sep 18, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - #160401 (sparc: make ABI consistent with clang)
 - #162715 (don't calculate dtors if the self ty has impossible bounds)
 - #162740 (stdarch subtree update)
 - #162946 (Simplify query stack printing)
 - #161005 (fix: unfulfilled nested dead code lint)
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - #162661 (simplify `Target::GenericParam`)
 - #162666 (Tidy footnote in `platform-support.md`)
 - #162803 (docs(num): add documentation for `NonZero::from_str`)
 - #162879 (use u64 limbs in core::num::bignum)
 - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag)
 - #162905 (c-variadic: add checks for windows i686)
 - #162906 (Move more `rustdoc-html` tests in the right location)
 - #162922 (An assortment of polonius tweaks)
 - #162929 (Update unicode_data to Unicode version 18.0.0)
 - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
 - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
@rust-bors
rust-bors Bot merged commit ad0637a into rust-lang:main Sep 19, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
Rollup merge of #162879 - kiana1kaslana:bignum-u64-limbs, r=clarfonthey

use u64 limbs in core::num::bignum

The code was totally written by myself without any llm.Last time I write description with the polish of llm,but this time I write the description on my own.
This pr use u64 limbs in core::num::bignum

Since the unlocking of u128 in #146277, a discussion happened in #137887. From which I know maybe I can help making a u64 digit path.

changes are as follows:

1.  total capacity of bignum remains the same, 1280bits. Big32x40=>Big64x20
2. add u64 entry to SMALL_POW5.
3. update the corresponding coretests to use Big64x20.

performance:

​	I ran benchmarks on my PC,use

```text
./x test library/coretests --test-args bignum
./x test library/coretests --test-args flt2dec
./x test tidy
```

​    results are as follows:

| Benchmark               | Big32x40 (ns/iter) | Big64x20 (ns/iter) | Speedup |
| ----------------------- | ------------------ | ------------------ | ------- |
| `bench_big_exact_inf`   | 33,568             | ~21,700            | 1.55x   |
| `bench_big_shortest`    | 2,913              | ~1,880             | 1.55x   |
| `bench_big_exact_12`    | 1,680              | ~1,030             | 1.63x   |
| `bench_big_exact_3`     | 878                | ~585               | 1.50x   |
| `bench_small_exact_inf` | 1,353              | ~1,425             | ~1.0x   |
| `bench_small_exact_12`  | 277                | ~220               | 1.26x   |
| `bench_small_exact_3`   | 170                | ~134               | 1.27x   |
| `bench_small_shortest`  | 320                | ~275               | 1.16x   |
@tgross35

Copy link
Copy Markdown
Member

I expect the perf improvements in #162989 (comment) may be this, may as well confirm

@rust-timer build 898e43b

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (898e43b): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary 3.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.0% [2.5%, 3.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.0% [2.5%, 3.5%] 2

Cycles

This perf run didn't have relevant results for this metric.

Binary size

Results (primary -0.0%)

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)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 4

Bootstrap: 498.333s -> 497.77s (-0.11%)
Artifact size: 408.93 MiB -> 408.87 MiB (-0.01%)

pull Bot pushed a commit to LeeeeeeM/miri that referenced this pull request Sep 19, 2026
…uwer

Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#160401 (sparc: make ABI consistent with clang)
 - rust-lang/rust#162715 (don't calculate dtors if the self ty has impossible bounds)
 - rust-lang/rust#162740 (stdarch subtree update)
 - rust-lang/rust#162946 (Simplify query stack printing)
 - rust-lang/rust#161005 (fix: unfulfilled nested dead code lint)
 - rust-lang/rust#161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - rust-lang/rust#161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase)
 - rust-lang/rust#162256 (Add mentions to sync back `RELEASES.md` to the `main` branch)
 - rust-lang/rust#162661 (simplify `Target::GenericParam`)
 - rust-lang/rust#162666 (Tidy footnote in `platform-support.md`)
 - rust-lang/rust#162803 (docs(num): add documentation for `NonZero::from_str`)
 - rust-lang/rust#162879 (use u64 limbs in core::num::bignum)
 - rust-lang/rust#162903 (PassWrapper: adapt to LLVM reading exception model from module flag)
 - rust-lang/rust#162905 (c-variadic: add checks for windows i686)
 - rust-lang/rust#162906 (Move more `rustdoc-html` tests in the right location)
 - rust-lang/rust#162922 (An assortment of polonius tweaks)
 - rust-lang/rust#162929 (Update unicode_data to Unicode version 18.0.0)
 - rust-lang/rust#162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
 - rust-lang/rust#162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
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. 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.

5 participants