== Quote from Dan (dsstruth...@yahoo.com)'s article > My code does do considerable array appending, and I see exactly the same issue as dsimcha points out above. I would expect it is GC related, but why for multiple cores only, I cannot fathom. > Thanks for the repro, dsimcha! My code snippet would not have been as straight-forward.
Two reasons: 1. When GC info is queried, the last query is cached for (relatively) efficient array appending. However, this cache is not thread-local. Therefore, if you're appending to arrays in two different threads simultaneously, they'll both keep evicting each other's cached GC info, causing it to have to be looked up again and again. 2. Every array append requires a lock acquisition. This is much more expensive if there's contention. Bottom line: Array appending in multithreaded code is **horribly** broken and I'm glad it's being brought to people's attention. For a temporary fix, pre-allocate or use std.array.Appender.