[vox-tech] benchmarking (again)

Mark K. Kim lugod at cbreak.org
Fri Feb 17 14:03:36 PST 2006


On Fri, Feb 17, 2006 at 04:16:29PM -0500, Peter Jay Salzman wrote:
> On Fri 17 Feb 06, 12:00 PM, Mark K. Kim <lugod at cbreak.org> said:
[snip]
> > I think you mean CPU registers?  L1/L2/L3 caches are just buffers
> > between RAM and the CPU registers, and all data allocated in RAM, stack
> > or heap, go through L1 cache at some point.  Programming languages or
> > compilers have no direct memory allocation access of the caches.
>  
> I was under the impression that this is what computer scientists call
> "locality of data" -- if data is used once, it'll be used again soon.  The
> strategy that attempts to exploit locality of data is to hold recent data in
> L1 cache.

Yep.  But the software has little control over what happens at L[123]
cache because L[123] caching is done at hardware-level, behind the
scene.  All RAM read/write goes through the cache, and all recently RAM
read/written data is most likely to be in the L[123] cache, whether it
was a heap read/write operation or a stack read/write operation.  The
compiler, if it knows the caching algorithm of the platform, can try to
take advantage of the caching pattern, but that's pretty much the extent
of the software's control over the L[123] cache.  

> I see what you mean.  Yeah, but the question still remains -- what's going
> on with the user time in java apps, and why does the program run faster in
> Java than C++?  Certainly C++ compilers know how to do all that stuff too.

As Jeff pointed out, Cygwin can be a bit of an oddball.  I'm not sure
what happens if you run `time` on a non-Cygwin program like a JVM.
Also, I'm not sure what JVM considers "system" and "user" time -- if the
whole program gets executed by the JVM as a system driver then "system"
time is what C++ would consider a "user" time.

Try the code under Linux.  It should give more accurate measurements.

-Mark


-- 
Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Cyworld: http://www.cyworld.com/markuskimius
Friendster: http://www.friendster.com/user.php?uid=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E  5167 6822 94F0 F298 5DCE
PGP key available on the homepage


More information about the vox-tech mailing list