[infinispan-dev] Collections, immutables and copies

Mircea Markus mircea.markus at jboss.com
Wed Jan 18 13:35:30 EST 2012


On 18 Jan 2012, at 18:19, Sanne Grinovero wrote:

> Hi All,
> after some profiling I've seen that even to manage a single command,
> there is a huge amount of List<Address>, Map<Address,[something]>,
> HashSet constructions involved; often they are defensively copied as
> many methods might potentially remove a couple of elements, but this
> event is very unlikely.
there's a lot of such noise around calculating the CH afaik is calculated several times.
One idea that just came to my mind is to cache the possible CH values in immutable collections and always return these cached collections when CH is invoked. 
This might end up with numVirtualNodes cached collections of addresses per node, but might reduce the level of noise considerably.
> So I think the standard collections are unfit for this purpose, as
> this is pretty much a constant, and also HashSets are not fit for the
> purpose as most commonly they will contain a very small amount of
> addresses.
> 
> I started as a draft to change this to a custom collection which would
> be immutable by default and provide efficient implementations for the
> specific use cases Infinispan has, and while proceeding in making more
> and more changes to make it compile I convinced myself that it was the
> way to go as the amount of copies and operations performed on these is
> impressive, and this was going to avoid most of the work.
> 
> BUT I'm changing way more code than expected, including lots of
> interfaces, and keeping deprecated copies makes it too complex.
> 
> So even if this was meant to be a draft and I didn't even finish it,
> I'm aborting the task already and proposing to do something similar
> for 6.0.
> I can say now that it's a big work, and while I don't have performance
> tests backing this I expect it to be worth it.
+1


More information about the infinispan-dev mailing list