Re: Anyone know CUP cache and java array?
Kevin wrote On 05/03/06 12:21,:
I think the CUP needs to load the data structure to its CPU cache in
order to operate them, right?
Usually, yes. Note that most modern computers have
multiple levels of cache with different characteristics.
Also, it may be possible to do some kinds of manipulation
(e.g., block copies) without involving some caches.
So when we have a java array, for example:
int[] myArray = new int[2000];
When I want to update one of its values, for example:
myArray[1000] = myArray[1000] + 1;
In order to process this line, will the CPU load the whole array into
its CPU cache to process? Or it can just load that particular item to
its cache to update it?
In one sense you don't know. You write this line of
Java, javac compiles it, and the JVM executes it ... somehow.
The details of the execution are (mercifully -- take my word
for it) hidden from you.
In another sense, it's easy to get at least a partial
answer. Choose whichever cache level interests you and
consider its size. Then write a Java program with an array
of, say, five times that size. Do you think your program
will run, or do you think the CPU cache will explode like
Mr. Creosote after the "waafer-thin" mint?
--
Eric.Sosman@sun.com