Server Fault Asked by user156233 on January 31, 2021
Is it possible to set an arbitrary delay for I/O operations?
I would like to learn how do iowait and disk %util impact the performance. There are a lot of tools to stress the disk (bonnie++ etc.) but I’m looking for a way to introduce a delay like the tc (traffic control) tool does for network. It is possible to disable some optimizations with hdparm tool, like set AAM to quiet or disable DMA and switch to PIO mode – which are only a indirect way to decrease I/O.
Look at the "delay" target for device-mapper devices. This is exactly why it exists.
Here's an example of how to get that going:
[root@centos6 ~]# dd if=/dev/zero of=/tmp/100M-of-zeroes bs=1024k count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.141834 s, 739 MB/s
Dev-mapper only maps from one block device to another, not between files and block devices. That's the job of the loopback device.
[root@centos6 ~]# losetup --show --find /tmp/100M-of-zeroes
/dev/loop0
Since this is what dev-mapper will need here in a moment...
[root@centos6 ~]# blockdev --getsize /dev/loop0
204800
# echo "0 204800 delay /dev/loop0 0 200" | dmsetup create dm-slow
(about a 30 second pause here with no output)
The fields in the device mapper setup table in the "echo" command above are:
0
)204800
)delay
)/dev/loop/0
)0
)200
)We only have one line since we're treating the entire device mapper device the same, but this lets you have different sectors with different backing devices, only have some of them slow, only having some of them give errors, etc.
See https://linux.die.net/man/8/dmsetup for more info, including the possibly-also-useful "flakey" mapper type. Authoritative documentation on device-mapper's delay feature is at https://www.kernel.org/doc/Documentation/device-mapper/delay.txt
[root@centos6 ~]# dd if=/dev/mapper/dm-slow of=/dev/null count=25000
25000+0 records in
25000+0 records out
12800000 bytes (13 MB) copied, 10.2028 s, 1.3 MB/s
Yeah, that's pretty slow, especially compared to the original:
[root@centos6 ~]# dd if=/dev/loop0 of=/dev/null count=25000
25000+0 records in
25000+0 records out
12800000 bytes (13 MB) copied, 0.0361308 s, 354 MB/s
So the mapped device is definitely introducing a delay.
I intentionally broke things apart so the process was easy to follow. However, you could easily combine steps above into fewer commands.
Answered by Steve Bonds on January 31, 2021
You can try a simple command like that:
while true
do
find / -type f -exec cat {} ; >/dev/null 2>/dev/null
done
Note: it will not make any modification, just cat
Answered by user251677 on January 31, 2021
You can try using dm_delay to simulate delayed IO for a device. Here is some document you might need: http://www.mjmwired.net/kernel/Documentation/device-mapper/delay.txt and here are some useful links for iostats: iostat - How does %util affect %idle and %iowait https://stackoverflow.com/questions/4458183/how-the-util-of-iostat-is-computed
Answered by oxpa on January 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP