BurntSushi / memchr

Optimized string search routines for Rust.
The Unlicense
899 stars 102 forks source link

Improve: Call target directly from unsafe_ifunc macro whenever possible. #165

Open Sewer56 opened 1 month ago

Sewer56 commented 1 month ago

Example based on discussion from:

This is just an example of the sort of improvement/change I had in mind:

Before:

RUSTFLAGS="-C target-cpu=x86-64-v3" cargo bench:

[create_string_pool_4000_V0] Packed size: 200343 bytes
unpack_string_pool_4000_V0
                        time:   [27.400 µs 27.523 µs 27.663 µs]
                        change: [-2.8856% -2.2842% -1.6698%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  6 (6.00%) high mild
  3 (3.00%) high severe

After, with no_std:

[create_string_pool_4000_V0] Packed size: 200343 bytes
unpack_string_pool_4000_V0
                        time:   [26.712 µs 26.769 µs 26.847 µs]
                        change: [-2.3623% -2.1856% -1.9750%] (p = 0.00 < 0.05)
                        Performance has improved.

Test is more than just use of memchr; it's on a real scenario involving memchr. So this isn't a '2%' improvement, raw improvement is closer to '4%'.

For more details see:

Sewer56 commented 1 month ago

CI Failure is not caused by this commit.

This Actions Run https://github.com/BurntSushi/memchr/actions/runs/11258409805

Was ran with commit reverted, i.e. using code from master.