8

Our server is performing decently, but when backups or other scan processes run it will tank the entire server. Something like clamd will run and scan many files. While we expect slow performance, it's killing our cache and the end result is we don't get a system that can do anything.

Is there a way to disable disc/disk caching for a single command? The idea would be to run it like this:

# ./nocache clamd

Then while running clamd it would not thrash the primed cache while reading all the files on the system.

Kristopher Ives
  • 364
  • 1
  • 3
  • 13

2 Answers2

4

Its not really the answer you are looking for but we just use ionice for backups and scans so they don't affect the other programs on the server.

ionice -c3 clamd
Jure1873
  • 3,692
  • 1
  • 21
  • 28
2

It has to be implemented in the program itself. If clamd doesn't already do it, you can modify clamd to avoid an unnecessarily large cache footprint by adding calls to functions like posix_fadvise(... POSIX_FADV_NOREUSE) or madvise(... MADV_DONTNEED) (if it memory maps the files). It will still push filesystem metadata out of the cache though. There's not much you can do about that.

David Schwartz
  • 31,215
  • 2
  • 53
  • 82
  • 1
    Sad we don't have a user-level way, but thanks for the information. A madman could use a hook or create a process that executes the other code having called this POSIX function (or use LD_LIB) – Kristopher Ives Nov 29 '11 at 23:22
  • Did you ever find a way or code something yourself @KristopherIves? – user643011 Nov 28 '21 at 23:16