Skip to content

Conversation

@malik672
Copy link

@malik672 malik672 commented Nov 21, 2025

Replaced the iter().zip().find_map() chain with a slice based iter().position() scan.

The zip iterator forced a runtime cmp/cmovb check between values.len() and targets.len() to establish loop bounds. The new implementation depends solely on values, decoupling the dependency chain.

https://godbolt.org/z/hGda7PYzz

@rustbot rustbot 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 Nov 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2025

r? @chenyukang

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

@lqd
Copy link
Member

lqd commented Nov 21, 2025

Is that code path particularly hot in your experience?

It doesn't hurt to check, even if it may be unlikely (and the reason why "no one noticed").

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Nov 21, 2025
Perf: Optimize `target_for_value` lookup
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 21, 2025
@malik672
Copy link
Author

Is that code path particularly hot in your experience?

It doesn't hurt to check, even if it may be unlikely (and the reason why "no one noticed").

@bors try @rust-timer queue

Idk, was just reading some part of the codebase and picked it out
decided to check on godbolt

@rust-timer

This comment was marked as resolved.

@rust-bors
Copy link

rust-bors bot commented Nov 21, 2025

☀️ Try build successful (CI)
Build commit: 6014c74 (6014c74d5b6b9c8bdc7133a8bb8291f57ac4df2e, parent: e22dab387f6b4f6a87dfc54ac2f6013dddb41e68)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6014c74): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.6% [0.5%, 0.6%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (primary -2.0%, secondary 3.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)
3.0% [3.0%, 3.0%] 1
Improvements ✅
(primary)
-2.0% [-2.0%, -2.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-2.0%, -2.0%] 1

Binary size

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

Bootstrap: 473.456s -> 472.515s (-0.20%)
Artifact size: 388.90 MiB -> 388.91 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 21, 2025
@malik672 malik672 closed this Nov 21, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant 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.

5 participants