How can you tell how much of the filesystem cache is hot (frequently accessed) or not?

The use case would be determining when you are approaching the limits of your memory but before you actually hit them (and see a spike in page faults)

Essentially how can you tell the difference between:

1. a machine that has 4gb memory and nearly all of it is used for file caching but a process is only really accessing the same 100mb file repeatedly, and the rest was loaded over a long period of time and never accessed again (but is still cached in memory since there's no pressure to evict it)


2. a machine that has 4gb memory and is repeatedly accessing 3.9gb of it (and is just on the edge of causing page faults)


I would:

  1. take a snapshot of mem swap usage
  2. drop cache using :

    sync; echo 3 > /proc/sys/vm/drop_caches

  3. monitor how cache is being used next to this.

But this may impact performance for a short period to refresh the cache if it is actually mostly hot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.