Coverage test is extremely slow on multiple threads

Running with code coverage inserts a lot of loads and stores to increment the coverage counters. From my understanding, all threads load and store to the same location (so it’s racy). One core writing to a cache line that is in the cache for another core will invalidate that cache line and the core has to re-fetch it (which can be expensive) to have cache coherence. Maybe that is what you are seeing. Note that this is just a theory.

1 Like