Agreed. This is one case where linux doesn't do anything clever at all,
and one place where we should probably do some work. It happens for a lot
of scientific calculations.
The linux swapping code is really written for a more "interactive" load,
with that kind of access patterns. For that kind of load we do ok, it's
only a "special case" that we break on (admittedly it's a not-too-unusual
special case and one we should know about).
Older unixes usually take the other approach: they try to handle
exactly the kind of access pattern you use, because that used to be one
of the "normal" cases (when machines were mostly used for scientific
calculations with working sets >> main memory and very predictable access
Essentially, linux currently does a "interactive workstation" kind of
approach to swapping, where accesses are more or less random. There it
makes sense to use a global LRU-based swap-out algorithm.
With one large process that does sweeps over an array, LRU is just about
We should probably modify the LRU algorithm to take RSS into account (and
possibly access patterns, although that is harder to do). However, to be
quite honest, my personal priority is not that kind of behaviour, so it
would be up to somebody else to implement this.. (hint hint)