I'm designing a data structure that does a lot of object allocations in order to perform its function. It takes around 500 milliseconds to add one million items to it.
I've been looking for ways to optimize its functionality and just make it generally faster and I feel like I've exhausted other potential methods of increasing its performance.
While reading about garbage collection, I noticed there was an option for enabling server garbage collection and on a whim I just set it to true, and it caused the runtime to go from 500 ms to 200 ms: an unbelievable improvement!
I read that it uses multiple cores to run the garbage collector. I'm wondering a couple things. Most people have multicore systems nowadays so why isn't this included by default? Also, if I package my data structure as a DLL, would it be possible to have this enabled by default, perhaps only for my library and not for the rest of the application if the client prefers otherwise?
I have a feeling I'm not really going to be able to leverage this power, but perhaps there is a way to steal a couple techniques from this and incorporate it somehow in to my own program? How is server garbage collection so fast? Is it just the fact that it uses multiple cores or are there other features that I might be able to clone in my own code?