3

When I download a lot of data (e.g. 3GB) in one go, using a program such as Transmission or Wget, progressively during the downloading, and after it has has finished, the computer always seems slightly sluggish, as though it's been using swap. However, the result of free always shows 0 bytes of swap used, both during the downloading and after.

I typically notice that the program used to download is slower to close, and subsequent programs are slower to open, but only the first time they're opened, as though the data is being transfered from swap to RAM.

My swap and free aren't faulty, since on other occasions free reports some swap usage as expected. My computer is never suspended nor hibernated; I don't use a screen saver; my computer is switched off at the end of every day.

My computer has 4 GB of RAM, and a fast processor, which never goes above ~20% usage when/after I'm downloading.

I'm using Linux.

What could be the cause of this behaviour?

EmmaV
  • 4,067

1 Answers1

3

The RAM in a computer is useful for two things: to store the memory of programs, and as a cache of recently-used disk content. On a typical healthy desktop system, about half the memory goes into each. You can check your memory usage with the free command; the “used” column of the “-/+ buffers/cache” is the figure for memory used for program data, and the “buffers” and “cache” values are the disk cache.

When you've been downloading a lot of things, this data fills the disk cache. As it does so, something else will have to go, because memory is finite. It appears that you aren't running any programs that have infrequently-used data, so no data gets written to the swap; instead, other data is evicted from the cache.

Programs are slower to open the first time after the download because you're used to the speed when the program code and data is already in the cache, but now they've been displaced from the cache to make room for the downloaded files.

The download program is probably slower to close because of delayed writes: the files that it writes are buffered, and the data is only fully written to disk when the system isn't using the disk bandwidth for more important things or when the buffer memory needs to be repurposed, or by explicit request with the sync command.

That you aren't seeing any swap at all is a bit strange. It suggests that you've tuned your swappiness to a value that reduces performance (swap usage is healthy, but there's a lot of advice on the web that suggests turning it off, which is almost always counter-productive).

  • Thanks for your explanation. One question though: First you say RAM stores programs separately from recently-used disk content, which is stored in the cache; then you say that programs are slower to open because the program code has been displaced from the cache. Do you mean the program code is in non-cache memory, but is subsequently removed to make way for disk content in the expanding cache? – EmmaV Nov 28 '14 at 00:10
  • @EmmaV RAM stores both the data of running programs, and code and data loaded from disk files. Program code is in cache, it's the working data that isn't in cache (and so must be stored in swap if there's no more room for it in memory). On your system, program code is getting displaced by the downloaded content. – Gilles 'SO- stop being evil' Nov 28 '14 at 00:44