classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java.util.Hashtable.size()/isEmpty()


From: Jeff Sturm
Subject: Re: java.util.Hashtable.size()/isEmpty()
Date: Fri, 15 Feb 2002 11:24:02 -0500 (EST)

On Fri, 15 Feb 2002, Etienne M. Gagnon wrote:
> Have you heard of "thin locks" and other VM level optimizations that reduces 
> "significantly" the cost of locks?

Even the ideal lock still carries a large cost.  The CPU will probably
stall, flush its store buffer, reload values from memory, etc.
There's no escaping that.  (However I'm not sure if this is true when
reentering a lock already held by the current thread.)

> The "synchronize" will force the "current processor" to update its data 
> cache.

Most modern multiprocessors use hardware cache coherency (though the Java
memory model doesn't require this, and relying on it isn't a good idea).

More importantly, synchronization forces ordering of loads and stores.

My impression is that hardware cache coherency is a bad idea because it
gives programmers a false sense of security and may even limit the
scalability of SMP hardware due to the extra bus traffic required.  (I
wonder if anyone's tried Java on a NUMA architecture?)

> Mutiprocessors + threads => difficult programming.

Most definitely.

Jeff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]