On Jan 3, 2013, at 8:52 PM, Adrien Piérard wrote:
Another interesting question: is there an API on the main OSes to get the cache sizes? We could make the default minimum heap size dependent on the cache size.
For windows, it seems there's an API: http://stackoverflow.com/questions/150294/how-to-programmatically-get-the-cp...
For linux, it seems that libproccpuinfo would allow you to read /sys/devices/system/cpu/cpu0/cache/index2/size properly, and thus get the information as well.
I currently don't have a FreeBSD machine to check for this OS what to do, but I assume it's accessible with the `sysctl` tool, and that an API exists for it as well.
Cool! Here's what I get in Mac OS X 10.6.8:
[Media-Mac-mini-3:~/programs] lucier% sysctl -a | grep cache hw.cachelinesize = 64 hw.l1icachesize = 32768 hw.l1dcachesize = 32768 hw.l2cachesize = 3145728 kern.flush_cache_on_write: 0 vfs.generic.nfs.client.access_cache_timeout: 60 vfs.generic.nfs.server.reqcache_size: 64 net.inet.ip.rtmaxcache: 128 net.inet6.ip6.rtmaxcache: 128 hw.cacheconfig: 2 1 2 0 0 0 0 0 0 0 hw.cachesize: 8321499136 32768 3145728 0 0 0 0 0 0 0 hw.cachelinesize: 64 hw.l1icachesize: 32768 hw.l1dcachesize: 32768 hw.l2cachesize: 3145728 machdep.cpu.cache.linesize: 64 machdep.cpu.cache.L2_associativity: 6 machdep.cpu.cache.size: 3072
Brad