4 ms·
java.util.concurrent has some great functionality, but I have found that some of the concurrent datastructures cause significantly more garbage generation than
by gamegoblin 11y ago
java.util.concurrent has some great functionality, but I have found that some of the concurrent datastructures cause significantly more garbage generation than their non-concurrent counterparts.
I was writing some highly concurrent code and initially wrote it with the jdk's lock-free containers, but found that GC was about 5-10x worse (depending on the workload) than simply wrapping the non-concurrent equivalent in a lock.
- bsder 11y ago> I was writing some highly concurrent code and initially wrote it with the jdk's lock-free containers, but found that GC was about 5-10x worse (depending on the workload) than simply wrapping the non-concurrent equivalent in a lock. That seems a bit high, but I can believe it under heavy contention. But, you measured, and then optimized. Which is what people should be doing but aren't.
- gamegoblin 11y agoThe biggest of them was all of the Node objects that ConcurrentSkipListSet generates. Replacing that with a synchronized TreeSet fixed most GC issues. Yes, this was a 100K+ element collection being concurrently used by 1000+ threads. I used YourKit to profile.