4 ms·
Very nice, how’s the performance?
by hnav 4y ago
Very nice, how’s the performance?
- sparkie 4y agoNot tested, but should be predictable. Each instrinsic maps to one instruction. Instruction latencies according to uops.info: vmovdqa64 zmm, m512 ; latency<=12 vpbroadcastq zmm, r64 ; latency<=5 vpcmpeqq k, zmm, zmm ; latency=3 kmovb r32, k ; latency<=3 The code is branchless. It will take the same number of cycles regardless of input. This is why it is `maybe_faster`. The faster version from the article may be faster for http/https because of short-circuiting behavior, but it would be slower for other protocols due to multiple branching. Aside from having greater throughput per instruction, being branchless means you will not have any branch prediction misses which negatively affect performance. The vectorized version would be a significant improvement if there are many (more than 6) small strings to compare, but for this example the difference is probably minor.