|
|
|
|
|
by SillyUsername
393 days ago
|
|
I have seen it for millions of add/del operations, an analytics framework actually for a big American games company (first guess and you'll probably say it), which is where I originally did the analysis about 10 years ago. I've also written a a video processor around that time too that was bottle necked using ArrayLists - typically a decode, store and read once op.
It was at this point I looked at other collections, other list implementations and blocking deques (ArrayList was the wrong collection type to use, but I'd been in a rush
for MVP) and ultimately came across https://github.com/conversant/disruptor and used that instead. The ArrayList Vs Linkedlist was a real eye opener for me in two different systems this same behaviour was replicated when using ArrayLists like queues or incorrect sizing of the buffer increments as load increases. |
|
Anyway, I felt I had to run the benchmarks myself.
And as I expected, on JDK 8 ArrayList with an appropriate initial capacity was faster than LinkedList. Admittedly not an order of magnitude difference, only 1.7x. But! On JDK 17 the situation is completely upside-down: I wonder why ArrayList with default initial capacity got so much worse. Worth investigating further.