[jboss-user] [JBoss Microcontainer Development] New message: "Re: Profiling the dependency project"
David Lloyd
do-not-reply at jboss.com
Fri Feb 19 10:47:42 EST 2010
User development,
A new message was posted in the thread "Profiling the dependency project":
http://community.jboss.org/message/527291#527291
Author : David Lloyd
Profile : http://community.jboss.org/people/david.lloyd@jboss.com
Message:
--------------------------------------------------------------
> alesj wrote:
>
>
> > Since installCallbacks and uninstallCallbacks are ConcurrentHashMaps, I think the read lock is unnecessary here in AbstractController:
> Since I think callbacks are already used in some explicitly locked code (via Lock),
> what about if we leave the locks and just change the callbacks to plain HashMap?
>
> Like discussed on the call, what is faster in a really-rare-concurrent env?
> * lock + plain hash collection
> * concurrent hash collection
>
> Jason, DML?
Well, if you're already locking, concurrent hash maps will generally give you general throughput in the contended case; if there's only one contender then there's only one lock acquisition so it's a wash, on paper. In reality, a CHM is actually a bit more complex, and it's also a really big structure (even if it's empty), consisting of a ReentrantLock for each lock stripe, each of which includes a bunch of stuff, so you get another kind of savings by using a simple synchronized map. In fact I'm hesitant to ever use CHM just because of its excessive size, especially if you're creating a lot of them (if you ever do a memory profile of AS, you can see that CHM and its components tend to bubble to the top of the list). So for low contention situations I'd always recommend a plain synchronized map.
The best solution would of course be to eliminate the lock - if you're already protected, you could use a plain hashmap. Otherwise consider if copy-on-write is suitable for you - Jason's FastCopyHashMap is good for that kind of thing.
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/527291#527291
More information about the jboss-user
mailing list