

C optimization: conditional store to avoid dirtying a cache line - albertzeyer
http://stackoverflow.com/questions/22717010/c-optimization-conditional-store-to-avoid-dirtying-a-cache-line/

======
dalke
Years 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.

