drop_caches hangs for 1-2 min and maxes cpu before completing

cn flag

If I have been logged into the Ubuntu 18.04 graphical console for a while and run either:

echo 2 >| /proc/sys/vm/drop_caches
echo 3 >| /proc/sys/vm/drop_caches

the process takes almost 2 minutes, whereas it is supposed to be nearly instantaneous. This in turn causes 'logout' to hang for more than a minute. At the same time the CPU pegs at 100%.

This happens even if run the commands repeatedly. However, echoing 1 is almost instantaneous.

If I log out of the graphical console, then dump_cache becomes almost instantaneous. If I log back in to the graphical console, dump_cache starts taking a couple of seconds but over time will revert to 1-2 minutes again -- not sure though what triggers that change.

I don't have anything running in the console itself other than 2 xterm windows and whatever background processes launch automatically with Ubuntu 18.04

More generally, I am not anything other than a few screen sessions, ssh client sessions, and emacs.

Free shows very little memory or cache usage:

              total        used        free      shared  buff/cache   available
Mem:            39G        4.7G         33G        209M        1.3G         33G
Swap:            0B          0B          0B

Root and system files are stored on SSD so writing cached files should be super-quick.

CPU usage as shown by htop is < 10% on all 4 processors.

  • Any idea what could be causing this?
  • And even if the first dump_cache takes a while due to accumulated 'stuff', why would a second dump_cache that follows immediately take the same amount of time?
  • What could possible be taking almost 2 minutes to dump given that there are <2GB of cache and my disk is a fast Samsung SSD?

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.