Skip to content

Add NEON support for is_ascii and eq_ignore_ascii_case - #160143

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ywxt:add-neon-support-is-ascii
Aug 3, 2026
Merged

Add NEON support for is_ascii and eq_ignore_ascii_case#160143
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ywxt:add-neon-support-is-ascii

Conversation

@ywxt

@ywxt ywxt commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Results on my aarch64 machine.

1. is_ascii

1.1 Raw Data (ns/iter, case00_libcore only — the path that calls bytes.is_ascii())

Input Baseline (NEON off) Optimized (NEON on) Change
long 19.69 6.46 -67.2%
unaligned_both_long 22.60 8.92 -60.5%
unaligned_head_long 20.62 8.81 -57.3%
unaligned_tail_long 21.15 8.68 -59.0%
medium 3.10 2.92 -5.8%
short 3.77 3.81 +1.1%
unaligned_both_medium 2.59 2.83 +9.3%
unaligned_head_medium 2.95 5.00 +69.5%
unaligned_tail_medium 2.37 2.96 +24.9%

1.2 Grouped Comparison (case00_libcore — the path affected by the change)

Group Baseline sum (ns) Optimized sum (ns) Change
LONG (~350B, 4 items) 84.06 32.87 -60.9%
MEDIUM/SHORT (~16–32B, 5 items) 14.78 17.52 +18.5%
All 9 items 98.84 50.39 -49.0%

2. eq_ignore_ascii_case

2.1 Raw Data (ns/iter)

Bench Baseline (NEON off) Optimized (NEON on) Change
bench_large_str_eq 6235.89 546.61 -91.2%
bench_medium_str_eq 780.81 68.05 -91.3%
bench_medium_str_tail_mismatch 786.84 65.76 -91.6%
bench_str_31_bytes_eq 35.87 3.98 -88.9%
bench_str_17_bytes_eq 19.62 4.05 -79.4%
bench_medium_str_early_mismatch 1.32 2.42 +0.75 ns
bench_str_of_8_bytes_eq 9.20 9.20 0.0%
bench_str_under_8_bytes_eq 3.49 3.49 0.0%

2.2 Grouped Comparison

Group Scenario Baseline Optimized Change
≥16B equal 17B / 31B / MEDIUM / LARGE 19.6–6236 ns 4.0–547 ns -79% ~ -91%
≥16B tail mismatch MEDIUM, last byte differs 786.84 ns 65.76 ns -91.6%
≥16B early mismatch MEDIUM, first byte differs 1.32 ns 2.42 ns +0.75 ns
<16B 8B / <8B equal 3.49–9.20 ns 3.49–9.20 ns no change

r? @Amanieu

@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 29, 2026
@Amanieu

Amanieu commented Aug 3, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit ccbf7c6 has been approved by Amanieu

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 Aug 3, 2026
@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit ccbf7c6 with merge 37c88a8...

Workflow: https://github.com/rust-lang/rust/actions/runs/30779241503

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Add NEON support for is_ascii and eq_ignore_ascii_case



Results on my aarch64 machine.

## 1. `is_ascii`

### 1.1 Raw Data (ns/iter, case00_libcore only — the path that calls `bytes.is_ascii()`)

| Input | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| long | 19.69 | 6.46 | **-67.2%** |
| unaligned_both_long | 22.60 | 8.92 | **-60.5%** |
| unaligned_head_long | 20.62 | 8.81 | **-57.3%** |
| unaligned_tail_long | 21.15 | 8.68 | **-59.0%** |
| medium | 3.10 | 2.92 | -5.8% |
| short | 3.77 | 3.81 | +1.1% |
| unaligned_both_medium | 2.59 | 2.83 | +9.3% |
| unaligned_head_medium | 2.95 | 5.00 | +69.5% |
| unaligned_tail_medium | 2.37 | 2.96 | +24.9% |

### 1.2 Grouped Comparison (case00_libcore — the path affected by the change)

| Group | Baseline sum (ns) | Optimized sum (ns) | Change |
|---|---|---|---|
| **LONG (~350B, 4 items)** | 84.06 | 32.87 | **-60.9%** |
| **MEDIUM/SHORT (~16–32B, 5 items)** | 14.78 | 17.52 | +18.5% |
| All 9 items | 98.84 | 50.39 | **-49.0%** |

## 2. `eq_ignore_ascii_case`

### 2.1 Raw Data (ns/iter)

| Bench | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| bench_large_str_eq | 6235.89 | 546.61 | **-91.2%** |
| bench_medium_str_eq | 780.81 | 68.05 | **-91.3%** |
| bench_medium_str_tail_mismatch | 786.84 | 65.76 | **-91.6%** |
| bench_str_31_bytes_eq | 35.87 | 3.98 | **-88.9%** |
| bench_str_17_bytes_eq | 19.62 | 4.05 | **-79.4%** |
| bench_medium_str_early_mismatch | 1.32 | 2.42 | +0.75 ns |
| bench_str_of_8_bytes_eq | 9.20 | 9.20 | 0.0% |
| bench_str_under_8_bytes_eq | 3.49 | 3.49 | 0.0% |

### 2.2 Grouped Comparison

| Group | Scenario | Baseline | Optimized | Change |
|---|---|---|---|---|
| **≥16B equal** | 17B / 31B / MEDIUM / LARGE | 19.6–6236 ns | 4.0–547 ns | **-79% ~ -91%** |
| **≥16B tail mismatch** | MEDIUM, last byte differs | 786.84 ns | 65.76 ns | **-91.6%** |
| **≥16B early mismatch** | MEDIUM, first byte differs | 1.32 ns | 2.42 ns | +0.75 ns |
| **<16B** | 8B / <8B equal | 3.49–9.20 ns | 3.49–9.20 ns | no change |


r? @Amanieu
@Zalathar

Zalathar commented Aug 3, 2026

Copy link
Copy Markdown
Member

@bors yield (to enclosing rollup)

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #160411.

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Rollup of 5 pull requests

Successful merges:

 - #160143 (Add NEON support for is_ascii and eq_ignore_ascii_case)
 - #160191 (bootstrap: Don't pass `Kind` to some places that don't need it)
 - #160386 (rustc_data_structures: Cleanup jobserver initialization)
 - #160409 (Remove redundant target check from check_eii_impl)
 - #160410 (Update GitHub Actions to v7.0.1)
@rust-bors
rust-bors Bot merged commit f173ba2 into rust-lang:main Aug 3, 2026
13 of 14 checks passed
rust-timer added a commit that referenced this pull request Aug 3, 2026
Rollup merge of #160143 - ywxt:add-neon-support-is-ascii, r=Amanieu

Add NEON support for is_ascii and eq_ignore_ascii_case

Results on my aarch64 machine.

## 1. `is_ascii`

### 1.1 Raw Data (ns/iter, case00_libcore only — the path that calls `bytes.is_ascii()`)

| Input | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| long | 19.69 | 6.46 | **-67.2%** |
| unaligned_both_long | 22.60 | 8.92 | **-60.5%** |
| unaligned_head_long | 20.62 | 8.81 | **-57.3%** |
| unaligned_tail_long | 21.15 | 8.68 | **-59.0%** |
| medium | 3.10 | 2.92 | -5.8% |
| short | 3.77 | 3.81 | +1.1% |
| unaligned_both_medium | 2.59 | 2.83 | +9.3% |
| unaligned_head_medium | 2.95 | 5.00 | +69.5% |
| unaligned_tail_medium | 2.37 | 2.96 | +24.9% |

### 1.2 Grouped Comparison (case00_libcore — the path affected by the change)

| Group | Baseline sum (ns) | Optimized sum (ns) | Change |
|---|---|---|---|
| **LONG (~350B, 4 items)** | 84.06 | 32.87 | **-60.9%** |
| **MEDIUM/SHORT (~16–32B, 5 items)** | 14.78 | 17.52 | +18.5% |
| All 9 items | 98.84 | 50.39 | **-49.0%** |

## 2. `eq_ignore_ascii_case`

### 2.1 Raw Data (ns/iter)

| Bench | Baseline (NEON off) | Optimized (NEON on) | Change |
|---|---|---|---|
| bench_large_str_eq | 6235.89 | 546.61 | **-91.2%** |
| bench_medium_str_eq | 780.81 | 68.05 | **-91.3%** |
| bench_medium_str_tail_mismatch | 786.84 | 65.76 | **-91.6%** |
| bench_str_31_bytes_eq | 35.87 | 3.98 | **-88.9%** |
| bench_str_17_bytes_eq | 19.62 | 4.05 | **-79.4%** |
| bench_medium_str_early_mismatch | 1.32 | 2.42 | +0.75 ns |
| bench_str_of_8_bytes_eq | 9.20 | 9.20 | 0.0% |
| bench_str_under_8_bytes_eq | 3.49 | 3.49 | 0.0% |

### 2.2 Grouped Comparison

| Group | Scenario | Baseline | Optimized | Change |
|---|---|---|---|---|
| **≥16B equal** | 17B / 31B / MEDIUM / LARGE | 19.6–6236 ns | 4.0–547 ns | **-79% ~ -91%** |
| **≥16B tail mismatch** | MEDIUM, last byte differs | 786.84 ns | 65.76 ns | **-91.6%** |
| **≥16B early mismatch** | MEDIUM, first byte differs | 1.32 ns | 2.42 ns | +0.75 ns |
| **<16B** | 8B / <8B equal | 3.49–9.20 ns | 3.49–9.20 ns | no change |

r? @Amanieu
@rustbot rustbot added this to the 1.99.0 milestone Aug 3, 2026
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.

4 participants