When I copy files to and from USB devices (camera, HDD, memory card) my system becomes very slow. For example if I want to close a window I move the mouse but it takes about 2 seconds or more before the mouse cursor moves. When I finally get the cursor over the x and click it nothing happens for 10+ seconds. I’ve tried this with all desktop effects disabled but the issue persists.
Software: Linux Mint 9 KDE
Hardware:
- Asus SLI motherboard
- NVidia 6600 GPU
- 2 GB Ram
- 2 GB Swap
- AMD Athlox X2 @ 3800+
To me this hardware should not have any issues running this software and it doesn’t until I copy files using USB. Where should I start looking to figure this one out? I’m kind of thinking the graphics driver may be part of the problem but I don’t know for sure.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There seems to be a problem with huge pages in linuxes memory management. It rarely occurs, but sounds like you have observed it.
Cause
This is my grossly simplified account of what, according to the article, happens.
If unlucky, a process gets stuck the moment it issues a memory access. That’s because when transparent huge pages is enabled, a memory access may trigger synchronous compaction (defragmentation of main memory,) synchronous meaning the memory access does not finish before the compaction does. This in itself is not a bad thing. But if write-back (of, e.g., buffered data to USB) happens to take place at the same time, compaction in turn is likely to stall, waiting for the write-back to finish.
So, any process could end up waiting for a slow device to finish writing buffered data.
Cure
Upgrading main memory, as the OP did, might help delay the problem. But for those who don’t consider that an option, there are two obvious workarounds. Both involve recompiling the kernel:
- disabling the transparent huge pages feature
- applying Mel’s patch as mentioned in the article
Method 2
This sounds similar to my question here (where an answer pointed me to this question):
But the theory is completely different, and the solution I used is unrelated to yours, but works perfectly.
I was using rsync, so all I had to do was use the –drop-cache option. (which makes the copy a bit slower as a side effect)
Method 3
The only trick I found that really works:
Gnome, nautilus copy files to USB stops at 100% or near
If you want to try some power-user tricks, you can reduce the size of the buffer that Linux uses by setting /proc/sys/vm/dirty_bytes to something like 15728640 (15 MB). This means the application can’t get more than 15MB ahead of its actual progress.
A side effect is that your computer might have lower data-writing throughput with this setting, but on the whole, I find it helpful to see that a program is running a long time while it writes lots of data vs. the confusion of having a program appear to be done with its job but the system lagging badly as the kernel does the actual work. Setting dirty_bytes to a reasonably small value can also help prevent your system from becoming unresponsive when you’re low on free memory and run a program that suddenly writes lots of data.
But, don’t set it too small! I use 15MB as a rough estimate that the kernel can flush the buffer to a normal hard drive in 1/4 of a second or less. It keeps my system from feeling “laggy”.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0