Hacker News new | ask | show | jobs
by ReactiveJelly 2188 days ago
How hard is it to empirically detect cache size at startup and tune the algorithms based on that?

I guess you'd miss out on inlining / constant folding opportunities. If you didn't have a JIT.

1 comments

Certainly possible. Glibc has the sysconf function which can provide the cache sizes at runtime.

https://www.gnu.org/software/libc/manual/html_node/Constants...

However, consider a scenario like a database where you might store on disk once and don't get cheap opportunities to reorganize data when the memory or processor hardware is switched out.

Or when your data is sent over the network for processing by some arbitrary client hardware.