News for hackers. Stuff that matters.
Re:tolower() in bulk at speed by janwas on Tuesday June 28, 2022 @02:06AM (#31904608)
I agree padding is a good solution when you can arrange it.

In Highway we also use the blending/bit-select you mention: https://github.com/google/highway/blob/master/hwy/ops/generi... If HWY_MEM_OPS_MIGHT_FAULT, which is true if using ASAN or AVX2 (because AMD reserves the right to fault even if mask=0), we actually use a scalar loop.

I'm curious if anyone has data indicating that a jump table is faster, enough to make a difference?

Re:tolower() in bulk at speed by dragontamer on Tuesday June 28, 2022 @04:23PM (#31912556)
> I'm curious if anyone has data indicating that a jump table is faster, enough to make a difference?

Anything that touches the branch predictors on these modern, crazy CPUs, is going to be too complicated to really understand from a performance perspective!

I'm pretty sure that jump tables / if statements all touch the branch predictor. Things will be high performance if the branch is consistently predicted correctly, but good luck figuring that out without just running the darn program on a CPU.

Re:tolower() in bulk at speed by dzaima on Tuesday June 28, 2022 @04:47PM (#31912809)
Between a jump table and a scalar loop, the loop will screw with the branch predictor more.

A jump table has the potential to be faster by doing SIMD, at the cost of taking more icache.