Skip to content
pid7-orgPublic

About

Hardware accelerated routines for single substring search.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

20 stars

Watchers

0 watching

Forks

Crates.io npm PyPI Docs.rs Tests License

Ashwa 🐎

Hardware accelerated routines for single substring search

Index

Language Ecosystems

Supported Targets

Architecture Target Platform Target ISA Fallback
x86_64 Linux, macOS, Windows, Android, FreeBSD AVX-512BW, AVX2, SSE4.2, SSSE3, SSE2 64-bit SWAR
AArch64 (ARM64) Apple Silicon, Linux ARM64, Android, FreeBSD 128-bit ARM NEON 64-bit SWAR
x86 (i686) Windows, Linux SSE2 32-bit SWAR
ARMv7 Linux ARM, Android 128-bit ARM NEON 32-bit SWAR
WebAssembly Browsers, Node.js (wasm32) WASM SIMD128 (simd128) 32-bit SWAR

Installation

Add ashwa to your Cargo.toml:

[dependencies]
ashwa = "1.0.1"

Important

Minimum Supported Rust Version (MSRV) is 1.89.0.

ashwa needs Rust 1.89.0 or newer to use stable AVX-512BW support. This allows it to automatically choose the best instructions for each x86_64 processor without needing a nightly Rust version.

API

Refer to docs.rs for the complete crate documentation and API reference.

Benchmarks

Note

Benchmarks are evaluated across dedicated AWS EC2 hardware environments,

  • x86_64 (x64)

    • Instance: Intel(R) Xeon(R) Platinum 8488C (8C/16T)
    • ISA: AVX512BW
    • Cache: L1d: 384 KiB · L2: 16 MiB · L3: 105 MiB
    • STREAM Triad (Read + Write): 25.76 GiB/s
    • Max Single-Core Read Bandwidth: ~12.5 GiB/s
  • AArch64 (arm64)

    • Instance: AWS Graviton3 ARM Neoverse-V1 (16C/16T)
    • ISA: NEON
    • Cache: L1d: 1 MiB · L2: 16 MiB · L3: 32 MiB
    • STREAM Triad (Read + Write): 75.48 GiB/s
    • Max Single-Core Read Bandwidth: ~25.5 GiB/s

Note

All benchmarks execute while pinned to a single physical core (mostly to 0th core). For out-of-cache RAM-bound payloads (>256 MiB), every search routine fully saturates the hardwares maximum single-core memory bandwidth ceiling (~12 GiB/s on x64, ~25 GiB/s on arm64). Execution is 100% memory-bandwidth bound rather than compute-bound searching data as fast as the physical memory bus can deliver bytes into the CPU registers.

search_one

Level Payload Latency (x64) Latency (arm64) Throughput (x64) Throughput (arm64)
L1 Cache 32 KiB 203.82 ns 668.40 ns 149.73 GiB/s 45.66 GiB/s
L2 Cache 512 KiB 3.31 µs 11.29 µs 147.74 GiB/s 43.24 GiB/s
L3 Cache 16 MiB 465.93 µs 461.74 µs 33.54 GiB/s 33.84 GiB/s
RAM 256 MiB 21.44 ms 10.87 ms 11.66 GiB/s 23.00 GiB/s
RAM 512 MiB 44.49 ms 20.91 ms 11.24 GiB/s 23.92 GiB/s
RAM 1 GiB 89.23 ms 40.30 ms 11.21 GiB/s 24.82 GiB/s

search_two

Level Payload Latency (x64) Latency (arm64) Throughput (x64) Throughput (arm64)
L1 Cache 32 KiB 388.76 ns 1.49 µs 78.50 GiB/s 20.55 GiB/s
L2 Cache 512 KiB 9.32 µs 23.99 µs 52.41 GiB/s 20.35 GiB/s
L3 Cache 16 MiB 505.33 µs 768.56 µs 30.92 GiB/s 20.33 GiB/s
RAM 256 MiB 19.85 ms 13.00 ms 12.60 GiB/s 19.23 GiB/s
RAM 512 MiB 41.67 ms 26.09 ms 12.00 GiB/s 19.16 GiB/s
RAM 1 GiB 83.70 ms 52.12 ms 11.95 GiB/s 19.19 GiB/s

search_three

Level Payload Latency (x64) Latency (arm64) Throughput (x64) Throughput (arm64)
L1 Cache 32 KiB 427.32 ns 2.17 µs 71.42 GiB/s 14.07 GiB/s
L2 Cache 512 KiB 7.87 µs 34.69 µs 62.01 GiB/s 14.08 GiB/s
L3 Cache 16 MiB 474.87 µs 1.12 ms 32.90 GiB/s 13.91 GiB/s
RAM 256 MiB 20.33 ms 17.92 ms 12.30 GiB/s 13.95 GiB/s
RAM 512 MiB 41.13 ms 35.96 ms 12.16 GiB/s 13.91 GiB/s
RAM 1 GiB 87.32 ms 71.86 ms 11.45 GiB/s 13.92 GiB/s

search_n (where len(N) = 8)

Level Payload Latency (x64) Latency (arm64) Throughput (x64) Throughput (arm64)
L1 Cache 32 KiB 706.40 ns 2.47 µs 43.20 GiB/s 12.37 GiB/s
L2 Cache 512 KiB 11.51 µs 37.63 µs 42.43 GiB/s 12.98 GiB/s
L3 Cache 16 MiB 532.58 µs 1.22 ms 29.34 GiB/s 12.79 GiB/s
RAM 256 MiB 20.28 ms 19.24 ms 12.33 GiB/s 12.99 GiB/s
RAM 512 MiB 43.17 ms 38.46 ms 11.58 GiB/s 13.00 GiB/s
RAM 1 GiB 87.43 ms 76.88 ms 11.44 GiB/s 13.01 GiB/s

About

Hardware accelerated routines for single substring search.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

20 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages