Skip to content
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

Optimize core::char::CaseMappingIter #122616

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

Jules-Bertholet
Copy link
Contributor

Godbolt says this saves a few instructions…

@rustbot label T-libs A-layout C-optimization

Godbolt says this saves a few instructions…
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2024

r? @Nilstrieb

rustbot has assigned @Nilstrieb.
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. A-layout Area: Memory layout of types C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such labels Mar 17, 2024
Copy link
Member

@Noratrieb Noratrieb left a comment

Choose a reason for hiding this comment

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

The changes seem fine, but this CaseMappingIter seems pretty complex for doing a simple operation. What's the performance of just using an array::IntoIter and stopping when that one sees a \0?
I did a bit of digging on the origin of this type and it seems to have been around forever (addaa5b).

@Noratrieb Noratrieb 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 Mar 18, 2024
Makes the iterator 2*usize larger, but I doubt that matters much.
In exchange, we save a lot on instruction count.

In the absence of delegation syntax,
we must forward all the specialized impls manually…
@Jules-Bertholet Jules-Bertholet changed the title Optimize core::char::CaseMappingIter layout Optimize core::char::CaseMappingIter Mar 19, 2024
@Jules-Bertholet
Copy link
Contributor Author

Jules-Bertholet commented Mar 19, 2024

@Nilstrieb That is a much better approach, adopted.

@rustbot -S-waiting-on-author S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 22, 2024
@Noratrieb
Copy link
Member

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Mar 27, 2024

📌 Commit 2f1ab2c has been approved by Nilstrieb

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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 27, 2024
One(char),
Zero,
}
struct CaseMappingIter(core::array::IntoIter<char, 3>);
Copy link
Member

Choose a reason for hiding this comment

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

Unsure: are these something that people would commonly keep in a struct? Because while I do like the array::IntoIter phrasing of this, it means that iter will be 2×usize bigger than it used to be.

Feels like probably not, more likely something they'd just use directly and toss away, rather than use partially and keep around, but figured I'd mention it just in case.

(I wish we had an ArraySize<N> type that could be smaller for small N.)

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 28, 2024
…ut, r=Nilstrieb

Optimize `core::char::CaseMappingIter`

Godbolt says this saves a few instructions…

`@rustbot` label T-libs A-layout C-optimization
@bors
Copy link
Contributor

bors commented Mar 28, 2024

⌛ Testing commit 2f1ab2c with merge d5d479e...

@bors
Copy link
Contributor

bors commented Mar 28, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 28, 2024
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
-- Configuring done (37.1s)
-- Generating done (2.6s)
-- Build files have been written to: C:/a/rust/rust/build/x86_64-pc-windows-msvc/llvm/build
running: "cmake" "--build" "." "--target" "install" "--config" "Release" "--" "-j" "8"
ninja: error: build.ninja:3780: multiple outputs aren't (yet?) supported by depslog; bring this up on the mailing list if it affects you
thread 'main' panicked at C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.48\src\lib.rs:975:5:

command did not execute successfully, got: exit code: 1

@Jules-Bertholet
Copy link
Contributor Author

Jules-Bertholet commented Mar 28, 2024

@Noratrieb
Copy link
Member

@bors retry #122671 (comment)

@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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 28, 2024
@bors
Copy link
Contributor

bors commented Mar 29, 2024

⌛ Testing commit 2f1ab2c with merge 1c19595...

@bors
Copy link
Contributor

bors commented Mar 29, 2024

☀️ Test successful - checks-actions
Approved by: Nilstrieb
Pushing 1c19595 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 29, 2024
@bors bors merged commit 1c19595 into rust-lang:master Mar 29, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Mar 29, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1c19595): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.9% [3.9%, 3.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.9% [3.9%, 3.9%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.3%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.4%] 8
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.0%, 0.4%] 8

Bootstrap: 667.865s -> 668.406s (0.08%)
Artifact size: 315.66 MiB -> 315.93 MiB (0.09%)

@Jules-Bertholet Jules-Bertholet deleted the casemappingiter-layout branch March 29, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-layout Area: Memory layout of types C-optimization Category: An issue highlighting optimization opportunities or PRs implementing such merged-by-bors This PR was explicitly merged by bors. 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.

7 participants