Repository navigation
x86_64 SIMD string scanning and int decoding - #279
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/jiter/src/simd/x86_64.rs">
<violation number="1" location="crates/jiter/src/simd/x86_64.rs:74">
P1: When a long integer is followed by a non-float delimiter and at least 16 bytes remain, `first_non_digit` returns 32 and `full_calc` panics in its `unreachable!` arm. Return position 0 for an all-nondigit mask before decoding the chunk.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Merging this PR will degrade performance by 4.48%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
|
@codspeedbot explain the regression. |
Short answer: none of the 8 reported changes are real — the aarch64 machine code on this branch is identical to
|
| file | effect on aarch64 |
|---|---|
crates/jiter/src/simd/x86_64.rs (new) |
behind #[cfg(target_arch = "x86_64")] — never compiled |
crates/jiter/src/simd/mod.rs |
ONGOING_CHUNK_MULTIPLIER moved here; still 10^16 on aarch64 |
crates/jiter/src/number_decoder.rs |
the same const removed and imported instead |
The bench job runs on codspeed-macro, which is arm64, so the new SSE2 paths are dead code there.
I verified this rather than assuming it: cross-compiling the jiter lib at e39ce33 and at 75b5567 to aarch64-unknown-linux-gnu and diffing the emitted assembly gives 26,985 identical lines except one, and that one is a panic-location constant whose source line number changed (320 → 315) because 5 lines were deleted from number_decoder.rs. Zero instruction differences, same constant length, so no code or data layout shift either.
2. The per-commit history shows where the numbers actually moved
The branch has three commits. Comparing each run:
| comparison | contents | python_parse_x100_not_cached |
|---|---|---|
e39ce33 (main, base) |
— | 128 ns |
c858b19 — all the x86 SIMD code |
~230 lines of new code | 128 ns |
1a7b95f — move the const |
trivial | 128 ns |
75b5567 — "bump" |
empty commit, zero diff | 165 ns (-22%) |
The commit that contains the entire feature measured flat. The regression appears on a commit with no diff at all. That same empty commit is also responsible for python_parse_x100 152 → 171 ns and unicode_jiter_value -8.8%, while giving back sentence_jiter_iter +7.9% and sentence_jiter_value +5.4%.
An empty commit moving a benchmark 29% is a measurement artefact by definition.
3. Why these particular benchmarks
python_parse_x100*run in ~130-170 ns. At that scale, code/data placement and process/heap state dominate; within-run stdev is 0.2-0.4%, but the between-run spread is much larger. These are the two smallest benchmarks in the suite and they are the two largest reported "regressions".true_array_jiter_value/unicode_jiter_value/sentence_*are the allocation-heavy value benchmarks, which historically swing 5-15% between runs on this repo with no code change (true_array_jiter_valuealone has ranged 2.84-3.08 µs across consecutivemainpushes). Note the report shows them moving in both directions here, which is the usual signature.- CodSpeed also flagged different runtime environments between the base and head runs (different
libpython3.10/libexpat/libzbuild IDs recorded), and every benchmark in the report is in the affected list.
Recommendation
Nothing to fix on the branch — you can acknowledge these on CodSpeed. If you want a clean report, re-running the bench job on 75b5567 should shuffle them back.
Worth restating the point already in the PR description: because the macro runners are arm64, this PR is currently unmeasurable on CodSpeed — the report can only confirm that aarch64 is unchanged (which it now does, at the instruction level). The x86 numbers still need a main-vs-branch cargo bench on real x86 hardware.
No code changes were made.
Summary
- Warming up the performance wizard...
- Inspect CodSpeed runs for PR x86_64 SIMD string scanning and int decoding #279 — Compared 75b5567 vs e39ce33: 4 regressions, 4 improvements, env difference flagged
- Check whether x86 changes can affect aarch64 codegen — Cross-compiled jiter to aarch64 at e39ce33 and 75b5567: asm identical except one panic-location line number
- Reply with the explanation — Explanation posted; no code changes were needed
- Handling comment — Comment handling finished successfully
Learnings updated. See what CodSpeed remembers about this repository.
Was this response helpful? React with 👍 or 👎 to help us improve CodSpeedBot.
Port the aarch64 NEON fast paths to SSE2, selected at compile time via `cfg(target_arch = "x86_64")` with no runtime feature detection, since SSE2 is part of the x86_64 baseline. The string scan keeps the aarch64 shape: the vector mask only detects that a chunk contains a special byte and jumps over non-ascii runs; the stop character is located by the scalar table scan so the returned index stays off the vector->GPR transfer path. `pmovmskb` gives a bit-per-byte mask directly, so no `vshrn` nibble packing is needed. The ascii mask uses a single signed compare against 32, which catches control characters and bytes above 127 (negative as i8) in one instruction. Int decoding right-aligns the digits with `pslldq` and reduces with `pmullw`/`paddw`, `pmaddwd`, and `pmuludq`; there are no 64-bit half registers on x86 so one function covers 0..=16 digits. `ONGOING_CHUNK_MULTIPLIER` is now 10^16 on both SIMD architectures, matching the 16-byte step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dvr4FioDLzkHkriM5to3wC
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dvr4FioDLzkHkriM5to3wC
x86_64 SIMD (#279) merged after the IntChunk::Float variant gained its payload; like aarch64, the big decoder passes 0 since both callers discard the value for floats. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkwvHii1SZaVsrhw5skD4g
Port the aarch64 NEON fast paths (
decode_string_chunk,decode_int_chunk_big) to x86_64 using SSE2 only, selected at compile time withcfg(target_arch = "x86_64")— no runtime feature detection, since SSE2 is in the x86_64 baseline.Design
pmovmskbgives a bit-per-byte mask so novshrnnibble trick. A single signedpcmpgtbagainst 32 catches control chars and bytes ≥ 0x80 (negative as i8).pslldqand reduces viapmullw/paddw→pmaddwd→pmuludq. Onefull_calccovers 0..=16 digits.ONGOING_CHUNK_MULTIPLIERinnumber_decoder.rsis now10^16on both SIMD arches.TODOs mark follow-ups: SSSE3pmaddubsw, SSE4.1 lane packing, AVX2 32-byte loop.Verification
x86_64-apple-darwinunder Rosetta (incl. serde proptest) plus native aarch64 — all green. This caught one bug during development (all-digit mask →trailing_zerosof 0).-D warningson x86_64 and the wasm32 fallback,cargo bench -- --teston x86_64.objdumpof the x86 release build showspmovmskb/pmaddwd/pmuludq/pslldqand nocpuid.Not yet measured
CodSpeed's macro runners are arm64, so the bench job here only confirms aarch64 is unchanged. x86 performance numbers still need a
cargo benchmain-vs-branch run on real x86 hardware (e.g. a Codespace).🤖 Generated with Claude Code
https://claude.ai/code/session_01Dvr4FioDLzkHkriM5to3wC
Summary by cubic
Ports the aarch64 NEON fast paths for string scanning and integer decoding to x86_64 via SSE2 intrinsics, gated with
#[target_feature(enable = "sse2")]and selected at compile time withcfg(target_arch = "x86_64"). No runtime feature detection is needed because SSE2 is part of the x86_64 baseline.pmovmskbbit-per-byte mask to jump over non-ASCII runs; the stop character is still located by the scalar scan so the index stays off the vector→GPR path.pslldqand reduces viapmullw/paddw,pmaddwd, andpmuludq; onefull_calccovers 0..=16 digits.ONGOING_CHUNK_MULTIPLIERmoved intosimd/mod.rsand is now10^16for both SIMD architectures;number_decoder.rsimports it.simd/mod.rsand are wrapped inunsafeblocks.TODOs mark follow-ups for SSSE3, SSE4.1, and AVX2.Verification
-D warningspasses on x86_64 and wasm32 fallback.cargo bench -- --testpasses on x86_64, but x86 benchmark numbers on real hardware are still pending (CodSpeed runners are arm64).Written for commit 4fd4265. Summary will update on new commits.