-
Notifications
You must be signed in to change notification settings - Fork 54
Hmm note for those that uses +/- 16 +/- 32 to skip to win the race. #26
Description
This why sometimes those speedy scanner failed but sometimes works.. because they assume the pattern you looking for is aligned. even tho its not "sometimes". specially this benchmark generate the test binary on the fly. might be align might be not.
if u have this as example data
00 00 00 0A 0B 0C 00 00 00 00
lets say u skip + 4
and ur target is [0A 0B 0C 00]
your 1st scan is [00 00 00 0A] dint match so.. you did + 4. now u at [0B 0C 00 00] see now u missed the [0A 0B 0C 00] and fail see the red text thats why u missed it u skipped it.

but if u scan byte by byte u do [00 00 00 0A] -> [00 00 0A 0B] -> [00 0A 0B 0C ] -> [0A 0B 0C 00 ] (found it)

and yes it will be slow af. skipping is nice if it works and you are 100% sure its aligned xD but theres a chance it will fail. maybe next update ur pattern is not aligned anymore. but last update its aligned thats why it works.
This just a simple warning for those who likes the skipping. they work like A-Train with speed drug xD
u can drop the skipping and still use simd btw. it does improved the perf than regular inner loop. but you might be limited to 16 for sse and 32 for avx as max pattern .. but maybe u do another pass to extend it. but it might gonna be slower. or impact the perf. using simd doesnt make it go brrr by default its about how you use it. and optimize it.