Determing cache sizes -- request for testing

Don nospam at nospam.com.au
Thu Sep 11 00:09:15 PDT 2008


Craig Black wrote:
> Don,
> 
> Very good work on all this stuff!!  I didn't realize that this was 
> possible to do.  Once you get the cache sizes it would be beneficial to 
> know what regions of memory are currently loaded into cache and RAM.  Do 
> you know if this can be done?

I don't think that's possible.

One thing you can do, though, is use the performance counters to measure 
how many cache misses you're getting. (There are performance counters 
for L1 read misses, L1 write misses, L2 misses, # L2 lines evicted from 
cache, etc). Requires a small kernel mode driver, though, so can't be 
used for client code. But it's what I use for development -- you can 
learn a lot with it.

> If such information was available, it would be possible to write a 
> "memory optimizer" that would work on special data structures that could 
> be moved around on the heap.  Objects that are accessed frequently could 
> be moved around to improve locality of reference.

Nice idea. Still, the most important things can be done at compile time.
(especially, making sure that arrays of structs are sensibly arranged).



More information about the Digitalmars-d mailing list