Skip to content

fearless simd - #268

Merged
Esgrove merged 7 commits into
mainfrom
fearless-simd
Sep 23, 2026
Merged

Esgrove merged 7 commits into
mainfrom
fearless-simd

Conversation

@Esgrove

@Esgrove Esgrove commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add portable fearless_simd byte-scanning kernels with runtime dispatch and scalar benchmarking mode.
  • Apply SIMD to SLB scanner shortcuts, scanner skip-ahead, tokenizer chunking and code-span scanning, and Markdown code detection.
  • Add Criterion microbenchmarks, scalar-versus-SIMD pipeline benchmarks, and simd-bench.sh.
  • Record Ryzen 7950X and M4 Pro results in SIMD documentation.
  • Replace dirmove's quadratic prefix candidate scans and second grouping pass with a shared sorted prefix index.
  • Precompute lowercase filename parts to avoid repeated allocations during contiguity checks.

Performance

  • M4 Pro: tokenizer paths improve 23-27%; trailing-comment scans improve 31%; Markdown format/check improves 6.6-7.1%.
  • Ryzen 7950X: tokenizer improves 21-27%; scanner paths improve up to 19%; dirmove's 500-file first pass is about 15x faster.
  • SIMD is intentionally not used for character counting or short filename scans where dispatch cost outweighs gains.

Esgrove and others added 7 commits September 23, 2026 01:38
…d separator collapsing

Adds src/simd.rs with runtime dispatched byte scanning kernels, a CLI_TOOLS_SIMD mode switch, kernel microbenchmarks, simd-bench.sh, and docs/simd.md with the Ryzen 7950X results.
…MD skip-ahead in the scanner

PrefixIndex turns the per candidate scan of every file into a binary search, making the first grouping pass over 500 files 15 times faster. The scanner jumps to the next byte that can change its state, 15 to 22 percent faster C, Python, and trailing comment scans. docs/simd.md records both.
Bump version to 10.7.0 and update dependencies.

Move the shared simd test helpers into a root-level test_helpers module.
Document the simd benchmarks and use descriptive names in the dirmove index and benchmarks.

Report the end results in docs/simd.md:
move the scanner skip-ahead results under the Ryzen 7950X, where they were measured,
replace the Apple Silicon run checklist with general rerun steps,
summarize what was kept and what stayed scalar, and align the Markdown tables.
@Esgrove
Esgrove requested a balanced review from Copilot September 23, 2026 09:43
@Esgrove
Esgrove merged commit c810ad8 into main Sep 23, 2026
4 of 5 checks passed
@Esgrove
Esgrove deleted the fearless-simd branch September 23, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

A critical mode-dependent SIMD correctness issue and multiple benchmark-script defects remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Adds runtime-dispatched SIMD byte scanning and optimizes dirmove prefix grouping.

Changes:

  • Integrates SIMD kernels across semantic line breaking and filename processing.
  • Replaces quadratic dirmove scans with a sorted prefix index and cached lowercase parts.
  • Adds benchmarks, automation, tests, and performance documentation.
File Description
src/​simd.rs Implements SIMD kernels, runtime dispatch, and tests.
src/​semantic_line_breaks/​tokenizer.rs Accelerates token scanning.
src/​semantic_line_breaks/​string_syntax.rs Defines scanner trigger-byte sets.
src/​semantic_line_breaks/​scanner.rs Adds scanner shortcuts and skip-ahead.
src/​semantic_line_breaks/​markdown.rs Updates Markdown processing documentation.
src/​semantic_line_breaks/​looks_like_code.rs Accelerates code-marker detection.
src/​semantic_line_breaks/​formatter.rs Reformats documentation comments.
src/​lib.rs Adds a separator-processing fast path.
src/​dir_move/​utils.rs Adds indexed matching and optimized contiguity checks.
src/​dir_move/​types.rs Caches lowercase filename parts.
src/​dir_move/​prefix_index.rs Implements sorted prefix lookup.
src/​dir_move/​mod.rs Exports the prefix-index module.
src/​bin/​dir_move/​dir_move.rs Integrates the shared prefix index.
simd-bench.sh Automates SIMD benchmarks and reporting.
README.md Updates user documentation.
docs/​simd.md Documents SIMD design and performance results.
CLAUDE.md Documents architecture and benchmarks.
Cargo.toml Adds dependencies and benchmark registration.
Cargo.lock Updates locked dependencies.
benches/​simd.rs Adds SIMD microbenchmarks.
benches/​dir_move.rs Adds indexed prefix-matching benchmarks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/simd.rs
/// Number of UTF-8 characters in the text that are not the given ASCII byte.
#[must_use]
pub fn count_chars_excluding(text: &str, excluded: u8) -> usize {
debug_assert!(excluded.is_ascii(), "the excluded byte must be ASCII");
Comment thread simd-bench.sh
--save-baseline "mode-$mode" "${CRITERION_ARGS[@]}" "$DUPE_FILTER"
done
print_magenta "Kernel microbenchmarks"
cargo bench --bench simd -- --save-baseline kernels "${CRITERION_ARGS[@]}"
Comment thread simd-bench.sh
print()
print("| group | input | scalar variant | scalar | simd | change |")
print("|---|---|---|---:|---:|---:|")
for group in sorted(root.glob("simd_*")):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants