4 ms·
C optimization: conditional store to avoid dirtying a cache line
- dalke 13y agoYears ago I worked on Python optimizations for the string type. I tried speeding up .upper() and .lower() by replacing things like: if (isupper(c)) s[i] = _tolower(c); with: s[i] = _tolower(c); My mental model, which was still influenced by the microcomputer era, did not match the hardware. Benchmarks quickly identified that my "faster" implementation was actually noticeable slower. That's when I first started to understand cache lines.