Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I feel like this is a bit of a duplicate of this other question about making caching more aggressive, but I tried a lot of the suggestions there and I just can't figure out why I'm having trouble.

My scenario is that I've got Ubuntu 12.10 on a little USB flash drive I keep on my keychain. (I use it for times when I need to rescue someone's PC or when I want to have my own desktop with my own settings and bookmarks, etc. no matter what PC I find myself in front of).

The problem is that the system is horribly slow.

Now, the USB flash drive is fairly slow, so I know I have to make some concessions. However, I'm currently trying to run it on an i7 machine with 8GB of RAM. "free" and "top" both report that the system is using less than 2.7GB...

          total     used     free   shared    buffers   cached
Mem:       7712     2742     4969        0        164     1838
-/+ buffers/cache:   740     6972 
Swap:         0        0        0

... and "df" is telling me that the filesystem is using 4.4GB. So, there should be enough remaining RAM to cache the entire filesystem.

Based upon that, I would think that the only I/O latency I experience should be limited to the time it would take to read the files into the cache the first time. After that, I wouldn't think it would need to fetch them again, and all writes could just be cached in the background, so I shouldn't have to wait for those at all. (Of course, the big wait would probably be when I wanted to shut down, and 4GB of dirty cache needed to be written to the flash).

But, that's not what I'm experiencing at all. Instead, everything is agonizingly slow. Switching the focus to other windows results in the all of the windows going "dim" for about 10 seconds (what does the window-manager need, for this task, from the disk, that it didn't surely write there? And if it wrote it earlier in the windowing session, why isn't in the cache?), and doing something like using apt-get to install something takes several minutes after the .deb file gets downloaded (how is that .deb not already in the cache? How are the new files from the package not being written to the cache? And it's not that the installer is having to go read /var/lib/dpkg/available or /var/lib/dpkg/status because this happens to each package even when I try to install a bunch at once).

I've tinkered with /proc/sys/vm/vfs_cache_pressure, /proc/sys/vm/swappiness, /proc/sys/vm/dirty_writeback_centisecs, /proc/sys/vm/dirty_ratio... all without any significant effect.

I'm clearly unclear on how Linux disk caching works. So, fill me in. Can the kernel be configured to (provided it's got enough RAM for it):

  1. Read files from disk once and then keep them cached, and
  2. Cache all writes and just get them written to the disk during idles (and if that's 20 minutes from now, fine)?

And, if it can do this, what am I missing?

share|improve this question
add comment

1 Answer

USB thumbdrive raw performance

For starters I'd take a look at the USB thumb drive just to make sure that it's operating at an acceptable level. You can use the following 2 commands to measure it's performance:

$ hdparm -t /dev/sdb

$ dd count=100 bs=1M if=/dev/zero of=/media/disk/test oflag=sync

Substitute in the appropriate HDD info for your given setup.

File system

Also take a look at this article on increasing performance of USB thumbdrives from the Ubuntu help site.

References

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.