lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tatu Saloranta <t...@hypermall.net>
Subject Re: Vector -> LinkedList for performance reasons...
Date Thu, 22 Jan 2004 02:22:14 GMT
On Wednesday 21 January 2004 08:38, Doug Cutting wrote:
> Francesco Bellomi wrote:
> > I agree that synchronization in Vector is a waste of time if it isn't
> > required,
>
> It would be interesting to see if such synchronization actually impairs
> overall performance significantly.  This would be fairly simple to test.

True. At the same time, it's questionable whether there's any benefit of not 
changing it to ArrayList. However:

>
> > but I'm not sure if LinkedList is a better (faster) choice than
> > ArrayList.
>
> Correct.  ArrayList is the substitute for Vector.  One could also try
> replacing Hashtable with HashMap in many places.

Yes, LinkedList is pretty much never more or even as efficient (either memory 
or performancewise) than ArrayList. Arraycopy needed when doubling the size 
(which happens seldom enough when list grows) is neglible compared to 
increased GC activity and memory usage for entries in LinkedList (object 
overhead of 24 bytes for each entry, alloc/GC). 
And obviously indexed access is hideously slow, if that's needed. I've yet to 
find any use for LinkedList; it'd make sense to have some sort of combination 
(segmented array list, ie. linked list of arrays) for huge arrays... but 
LinkedList just isn't useful even there.

...
> My hunch is that the speedup will not be significant.  Synchronization
> costs in modern JVMs are very small when there is no contention.  But
> only measurement can say for sure.

Apparently 1.4 specifically had significant improvement there, reducing cost 
of synchronization.

-+ Tatu +-

>
> Doug
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message