1. 22
  1. 5

    Hey Sam, welcome to lobsters!

    1. 2

      Thank you!

    2. 2

      Nice. Similar pattern for heavily threaded code accessing shared state - split the variable into an array & ensure there’s a cacheline of space for each to avoid false sharing..

      1. 1

        This is very similar to the pattern of putting counters in “thread-local storage” in a PC app; each thread increments its own private counter (which won’t be contended by anyone else), and it’s the reader’s responsibility to grab a coherent view of all of the counters and add them up. As long as you expect reads to be rare compared to increments, it works well.