Skip to content

[rustc_data_structures][perf] Simplify base_n::push_str. - #114306

Merged
bors merged 1 commit into
rust-lang:masterfrom
ttsugriy:push_str
Aug 1, 2023
Merged

[rustc_data_structures][perf] Simplify base_n::push_str.#114306
bors merged 1 commit into
rust-lang:masterfrom
ttsugriy:push_str

Conversation

@ttsugriy

Copy link
Copy Markdown
Contributor

This minor change removes the need to reverse resulting digits. Since reverse is O(|digit_num|) but bounded by 128, it's unlikely to be a noticeable in practice. At the same time, this code is also a 1 line shorter, so combined with tiny perf win, why not?

I ran https://gist.github.com/ttsugriy/ed14860ef597ab315d4129d5f8adb191 on M1 macbook air and got a small improvement

Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old time: [14.180 µs 14.313 µs 14.462 µs]
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe
push_str/new time: [13.741 µs 13.839 µs 13.973 µs]
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
3 (3.00%) high mild
5 (5.00%) high severe

This minor change removes the need to reverse resulting digits.
Since reverse is O(|digit_num|) but bounded by 128, it's unlikely
to be a noticeable in practice. At the same time, this code is
also a 1 line shorter, so combined with tiny perf win, why not?
I ran https://gist.github.com/ttsugriy/ed14860ef597ab315d4129d5f8adb191
on M1 macbook air and got a small improvement
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old time: [14.180 µs 14.313 µs 14.462 µs]
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
4 (4.00%) high mild
1 (1.00%) high severe
push_str/new time: [13.741 µs 13.839 µs 13.973 µs]
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
3 (3.00%) high mild
5 (5.00%) high severe
```
@rustbot

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 31, 2023
@wesleywiser

Copy link
Copy Markdown
Member

Thanks @ttsugriy!

@bors r+ rollup

@bors

bors commented Aug 1, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit b84942a has been approved by wesleywiser

It is now in the queue for this repository.

@borsbors 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 Aug 1, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2023
…iaskrgr
Rollup of 7 pull requests
Successful merges:
- rust-lang#100455 (Implement RefUnwindSafe for Backtrace)
- rust-lang#113428 (coverage: Replace `ExpressionOperandId` with enum `Operand`)
- rust-lang#114283 (Use parking lot's rwlock even without parallel-rustc)
- rust-lang#114288 (Improve diagnostic for wrong borrow on binary operations)
- rust-lang#114296 (interpret: fix alignment handling for Repeat expressions)
- rust-lang#114306 ([rustc_data_structures][perf] Simplify base_n::push_str.)
- rust-lang#114320 (Cover statements for stable_mir)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 00ad3cc into rust-lang:masterAug 1, 2023
@rustbotrustbot added this to the 1.73.0 milestone Aug 1, 2023
@ttsugriy
ttsugriy deleted the push_str branch August 1, 2023 18:21
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler 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

@ttsugriy@rustbot@wesleywiser@bors