Skip to content

Conversation

Dr-Emann
Copy link

@Dr-Emann Dr-Emann commented Aug 4, 2025

This replaces #183, as it includes the count optimization on the SWAR fallback impl.

rebar measure -e 'fallback|onlycount'
rebar diff /tmp/old.csv /tmp/new.csv -u time -t 1.01

benchmark                          engine                                 /tmp/old.csv      /tmp/new.csv
---------                          ------                                 ------------      ------------
memchr/sherlock/common/huge1       rust/memchr/memchr/fallback            528.08us (1.15x)  458.21us (1.00x)
memchr/sherlock/common/huge1       rust/memchr/memchr/fallback/onlycount  92.29us (2.51x)   36.71us (1.00x)
memchr/sherlock/common/huge3       rust/memchr/memchr3/fallback           1.57ms (1.11x)    1.42ms (1.00x)
memchr/sherlock/common/small1      rust/memchr/memchr/fallback            167.00ns (1.00x)  250.00ns (1.50x)
memchr/sherlock/common/small1      rust/memchr/memchr/fallback/onlycount  125.00ns (2.98x)  42.00ns (1.00x)
memchr/sherlock/common/small2      rust/memchr/memchr2/fallback           292.00ns (1.00x)  625.00ns (2.14x)
memchr/sherlock/common/small3      rust/memchr/memchr3/fallback           417.00ns (1.00x)  1.08us (2.59x)
memchr/sherlock/common/tiny1       rust/memchr/memchr/fallback            42.00ns (1.02x)   41.00ns (1.00x)
memchr/sherlock/never/huge1        rust/memchr/memchr/fallback            26.50us (1.52x)   17.38us (1.00x)
memchr/sherlock/never/huge1        rust/memchr/memchr/fallback/onlycount  92.29us (2.51x)   36.71us (1.00x)
memchr/sherlock/never/huge2        rust/memchr/memchr2/fallback           49.88us (1.32x)   37.67us (1.00x)
memchr/sherlock/never/huge3        rust/memchr/memchr3/fallback           67.29us (1.17x)   57.62us (1.00x)
memchr/sherlock/never/small1       rust/memchr/memchr/fallback            42.00ns (1.02x)   41.00ns (1.00x)
memchr/sherlock/never/small1       rust/memchr/memchr/fallback/onlycount  125.00ns (2.98x)  42.00ns (1.00x)
memchr/sherlock/rare/huge1         rust/memchr/memchr/fallback            26.96us (1.36x)   19.79us (1.00x)
memchr/sherlock/rare/huge1         rust/memchr/memchr/fallback/onlycount  92.33us (2.52x)   36.71us (1.00x)
memchr/sherlock/rare/huge2         rust/memchr/memchr2/fallback           54.21us (1.26x)   43.04us (1.00x)
memchr/sherlock/rare/huge3         rust/memchr/memchr3/fallback           73.38us (1.13x)   65.04us (1.00x)
memchr/sherlock/rare/small1        rust/memchr/memchr/fallback            42.00ns (1.02x)   41.00ns (1.00x)
memchr/sherlock/rare/small1        rust/memchr/memchr/fallback/onlycount  125.00ns (2.98x)  42.00ns (1.00x)
memchr/sherlock/uncommon/huge1     rust/memchr/memchr/fallback            97.29us (1.02x)   95.38us (1.00x)
memchr/sherlock/uncommon/huge1     rust/memchr/memchr/fallback/onlycount  92.33us (2.51x)   36.75us (1.00x)
memchr/sherlock/uncommon/huge2     rust/memchr/memchr2/fallback           228.88us (1.03x)  222.17us (1.00x)
memchr/sherlock/uncommon/huge3     rust/memchr/memchr3/fallback           350.96us (1.02x)  344.54us (1.00x)
memchr/sherlock/uncommon/small1    rust/memchr/memchr/fallback/onlycount  125.00ns (2.98x)  42.00ns (1.00x)
memchr/sherlock/uncommon/small2    rust/memchr/memchr2/fallback           84.00ns (1.00x)   125.00ns (1.49x)
memchr/sherlock/uncommon/small3    rust/memchr/memchr3/fallback           167.00ns (1.00x)  250.00ns (1.50x)
memchr/sherlock/uncommon/tiny1     rust/memchr/memchr/fallback            41.00ns (41.00x)  1.00ns (1.00x)
memchr/sherlock/uncommon/tiny1     rust/memchr/memchr/fallback/onlycount  41.00ns (41.00x)  1.00ns (1.00x)
memchr/sherlock/uncommon/tiny3     rust/memchr/memchr3/fallback           42.00ns (1.00x)   125.00ns (2.98x)
memchr/sherlock/verycommon/huge1   rust/memchr/memchr/onlycount           13.29us (1.02x)   13.08us (1.00x)
memchr/sherlock/verycommon/huge1   rust/memchr/memchr/fallback            915.33us (1.42x)  643.31us (1.00x)
memchr/sherlock/verycommon/huge1   rust/memchr/memchr/fallback/onlycount  92.38us (2.52x)   36.71us (1.00x)
memchr/sherlock/verycommon/small1  rust/memchr/memchr/fallback            375.00ns (1.00x)  500.00ns (1.33x)
memchr/sherlock/verycommon/small1  rust/memchr/memchr/fallback/onlycount  125.00ns (2.98x)  42.00ns (1.00x)

Dr-Emann added 6 commits June 29, 2025 20:53
- Remove UNROLL parameter from One, Two, Three struct definitions
- Add UNROLL const generic parameter to find_raw, rfind_raw, count_raw methods
- Add inherent UNROLL constants to all architecture-specific wrapper types:
  - all/memchr.rs: One=2, Two=2, Three=1
  - x86_64/sse2: One=4, Two=2, Three=1
  - x86_64/avx2: One=4, Two=2, Three=1
  - aarch64/neon: One=4, Two=2, Three=1
@Dr-Emann Dr-Emann closed this Aug 4, 2025
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.

1 participant