3 ms·
I wonder if all of these optimizations are still as helpful. For example, skipping bytes only saves memory bandwidth if you skip whole cachelines. Also, for -
by amluto 10y ago
I wonder if all of these optimizations are still as helpful. For example, skipping bytes only saves memory bandwidth if you skip whole cachelines.
Also, for --mmap, there are a couple of conflicting considerations. On newer CPUs, large memory copies are very fast. With mmap, though, unless you use MAP_POPULATE, you can get a page fault every few pages, and on CPUs with exception mechanisms as bad as x86's, page faults are very slow (probably 20 times as bad as a syscall).
- goldenkey 10y agoDoes it use SIMD instructions? Some newer cpus can do up to 16 comparisons at once. That also might mean skipping will be branchy and not exactly divisible on word boundaries for best vectorization.
- adrianratnapala 10y agoThe bottleneck is not reading the byte, it is the CPU clocks needed to figure out that it is safe to skip. Assuming cache prefetching works well thanks to the sequential search, you can try to max out the memory bandwidth. But even DDR3 has best-case transfer rates from 6-17 GB/second. So to max it out on a 3GHz CPU, you need to eliminate 2-6 bytes on every tick of the clock.
- ksk 10y agoMemory bandwidth is not the main concern here since they explicitly mention that executing more CPU instructions kill performance far quicker - in this case. As for mmap, perhaps you would like to present your own benchmark that contradicts the article. But anyway, I highly doubt that either of the basic things you mentioned are news to the implementors. The implementation is supposed to run on all kinds of processors with varying architectures so making the implementation portable is bound to leave performance on the table. Not to mention other constraints like maintainability and meeting the performance criteria for the common use case/workload.