uncache!

this is source code for a tiny program I just wrote that traverses specified directories and removes them from file system cache.

There are few use cases for it. One is for all these people who benchmark stuff and want selective OS cache purges, another is for those who run high performance databases. Remember the O_DIRECT serialization everywhere? Well, XFS does direct I/O in parallel, unless there are cached pages (and they can happen because of any random outside-of-database activity, like ‘file’ command). Once you ‘uncache’ the files, XFS will be very much parallel again \o/ \o/

5 Responses to “uncache!”

  1. Partha Dutta says:

    In new versions of linux, (and RHEL 4u6 and higher), you can also remove entries from the file system cache using /proc/sys/vm/drop_caches

  2. Partha, I know, but not individually.. ;-)

  3. [...] Domas makes something more useful than I bet most would think: http://mituzas.lt/2009/06/26/uncache/ [...]

  4. [...] Porém às vezes o cache do seu file system atrapalha. Em procedimentos de benchmark (principalmente de DB), no qual você quer analisar apenas uma das camadas de software, o ideal é desativar o cache. Você pode fazer isso setando algumas opções no /proc, desativando o cache pelo /etc/fstab ou melhor ainda: use o uncache! [...]

  5. [...] uncache! « domas mituzas: vaporware, inc. There are few use cases for it. One is for all these people who benchmark stuff and want selective OS cache purges, another is for those who run high performance databases. Remember the O_DIRECT serialization everywhere? Well, XFS does direct I/O in parallel, unless there are cached pages (and they can happen because of any random outside-of-database activity, like ‘file’ command). Once you ‘uncache’ the files, XFS will be very much parallel again o/ o/ (tags: linux filesystem cache management) [...]