Were talking about the deadline IO scheduler tunables.
Now, if you’re like most people, you probably don’t give much thought to these little guys. But they can have a big impact on how your system performs. So let’s dive in and see what we’re dealing with here.
First off, read_expire and write_expire. These are the two main tunables for the deadline IO scheduler. When a request enters the queue, it is assigned a deadline based on these values. The goal of this system is to ensure that requests have a start service time within a certain amount of milliseconds.
So if you’re looking for low latency reads and writes, you might want to decrease read_expire and write_expire respectively. But be careful not to make them too small or your system will become unstable. On the other hand, if you need higher throughput, you can increase these values.
Next up is fifo_batch. This tunable controls how many requests are grouped together for servicing. By limiting the number of requests per batch, we can reduce extra seeking and improve latency variation. But again, be careful not to make this value too small or your system will become unresponsive during peak loads.
Finally, there’s writes_starved. This tunable controls how many times reads are given preference over writes before some writes are dispatched. If you have a workload that is heavily read-oriented, you might want to increase this value. But if your system needs more balanced write and read performance, you can decrease it.
Now, we know what you’re thinking. “This all sounds great in theory, but how do I actually implement these tunables?” Here are some handy commands for you:
1. To view the current values of your deadline IO scheduler tunables, run this command:
# This script is used to view the current values of the deadline IO scheduler tunables for improved write and read performance.
# First, we need to check the current value of the "nr_requests" tunable for the "sda" block device.
# This can be done by using the "cat" command to display the contents of the file "/sys/block/sda/queue/nr_requests".
# The "cat" command is used to concatenate and display files, in this case, the file containing the current value of "nr_requests".
cat /sys/block/sda/queue/nr_requests
# This will help to understand the purpose of the script and the changes made to it.
# To improve readability and organization, it is recommended to add comments before each code segment, explaining its purpose and functionality.
# This will make it easier for others to understand and modify the script in the future.
This will show you the value of fifo_batch. Replace “sda” with the name of your device if it’s different.
2. To change a tunable, run this command:
# This line sets the value of fifo_batch to 1024.
# Replace "sda" with the name of your device if it's different.
echo 1024 > /sys/block/sda/queue/fifo_batch
This will set fifo_batch to 1024 for the “sda” device. Again, replace “sda” with your device name if it’s different.
3. To view all available tunables and their current values, run this command:
# This line uses the "cat" command to display the contents of the specified file, which is the "queue" file within the "sda" block device.
# The output is then piped to the "grep" command, which searches for any lines containing "deadline_".
# This allows us to view the current values of all tunables related to the "deadline" I/O scheduler for the "sda" device.
cat /sys/block/sda/queue | grep deadline_
This will show you the current values of read_expire, write_expire, fifo_batch, and writes_starved for the “sda” device. Again, replace “sda” with your device name if it’s different.
And that’s all there is to it! With these simple commands, you can fine-tune your deadline IO scheduler tunables to optimize performance for your specific workload. So go ahead and give them a try! Your system will thank you.
But remember, as with any optimization technique, be careful not to overdo it. Too many changes at once could lead to instability or other unintended consequences. Start small and test thoroughly before making any major adjustments. And always keep backups of your important data just in case something goes wrong!