Can I simulate a slow hard drive?
Solution 1
Use nbd, the Network Block Device, and then rate limit access to it using say trickle
.
sudo apt-get install nbd-client nbd-server trickle
Solution 2
# echo 1 > /proc/sys/vm/drop_caches
That'll slow you down :)
It'll force you to read from disk, instead of taking advantage of the cached page.
If you really wanted to get sophisticated you could do something like fake a read error every nth time using the scsi fault injection framework.
http://scsifaultinjtst.sourceforge.net/
Solution 3
Have a USB 1.1 hub? Or a slow SD card? They'll get you down to under 10mbps.
Solution 4
You can use a Virtual Machine and throttle disk access ... here are some tips about how do it in Virtualbox 5.8. Limiting bandwidth for disk images https://www.virtualbox.org/manual/ch05.html#storage-bandwidth-limit
Solution 5
This is by no means a complete solution, but it may help in conjunction with other measures: There is an I/O scheduler much like a process scheduler, and it can be tweaked.
Most notably, you can actually choose amongst different schedulers:
~# cat /sys/block/sda/queue/scheduler
noop anticipatory deadline [cfq]
~# echo "deadline" > /sys/block/sda/queue/scheduler
~# cat /sys/block/sda/queue/scheduler
noop anticipatory [deadline] cfq
~#
deadline
may help you get more strongly reproducible results.
noop
, as its name implies, is insanely dumb, and will enable you to wreck absolute havoc on I/O performance with little effort.
anticipatory
and cfq
both try to be smart about it, though cfq
is generally the smarter of the two. (As I recall, anticipatory
is actually the legacy scheduler from right before the kernel started supporting multiple schedulers.)
Related videos on Youtube
Comments
-
RusGraf over 1 year
I have hunch that a certain intermittent bug might only manifest itself when there is a slow disk read rate. Troubleshooting is difficult because I can't reliably reproduce it.
Short of simply gobbling IO with a high priority process, is there any way for me to simulate having a slow hard drive?
-
Jeremy over 13 yearsI remember seeing a command to tell harddrives to run at certain bus speeds. I'll see if I can dig it out.
-
Jeremy over 13 years
man hdparm
take a look at the -X option maybe? There are quite a few things in there you could use to slow down your drive, but some of them risk doing nasty things to the data! -
Jeremy over 13 yearsAlso, try mounting a network share as a folder (google is your friend), maybe even over wifi, if that is plausible.
-
poolie over 13 yearsThis isn't a direct answer, but: if I had an intermittent bug like this, I would probably try running the process under Valgrind (if it was in a compiled language), because that would likely capture IO race conditions.
-
poolie over 13 yearsAre you talking about a bug in an application, or the kernel, or a device driver? Or you don't know at all? It might help if you explained more.
-
RusGraf over 13 years@poolie It's this problem. It stopped happening on one computer when I installed an SSD.
-
poolie over 13 yearsOK, I think it is highly likely to be what Jacob said on that bug, that
gnome-settings-daemon
is crashing, probably related to the timing of different components starting up.
-
-
RobotHumans over 13 yearsnice...not technical enough for the +1 but nice
-
poolie over 13 yearsI think this answer is seen as unhelpful because the mere fact that the process is doing lots of IO may be already known, or not a problem in itself. The issue is that there is some kind of timing-related bug in the way it handles those IOs.
-
The Unix Janitor over 13 years+1 for a pretty cool solution. however, it's not a real test because you not going to the real hard disk device driver, which where the problem may lie.
-
poolie over 13 yearsI didn't think he was talking about a driver bug, but that was just an assumption. Let's see.
-
papukaija about 13 yearsYou should explain what that command actually does.
-
Rich over 8 yearsIs it possible to add the actual command to this answer? At the moment you only show how to install the tools required :)
-
poolie over 8 yearsAs the question says, "Short of simply gobbling IO"....
-
poolie over 8 yearsAs the question says, "Short of simply gobbling IO"....
-
Androbin over 6 yearsNote: This will only drop the caches once. Then it will immediately start caching again. You might wanna wrap that in a loop.
-
ppetraki over 6 years@Androbin I like that idea. You could even add a sleep interval to the loop. Thanks!