[infinispan-dev] Collections, immutables and copies

Bela Ban bban at redhat.com
Thu Jan 19 02:17:21 EST 2012


This makes a lot of sense IMO, as I've done similar things in JGroups 
(e.g. my own optimized hashmap "Headers" in Message).

On 1/18/12 7:19 PM, 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.
>
> 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.


-- 
Bela Ban
Lead JGroups (http://www.jgroups.org)
JBoss / Red Hat


More information about the infinispan-dev mailing list