Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Drive_Manager | Allow to switch I/O scheduler #2233

Closed
Generator opened this issue Nov 10, 2018 · 5 comments
Closed

DietPi-Drive_Manager | Allow to switch I/O scheduler #2233

Generator opened this issue Nov 10, 2018 · 5 comments

Comments

@Generator
Copy link


name: Feature request
about: CFQ for better HDD performance


About:

Dietpi sets the HDDs elevator to deadline on boot for all storage devices, for better performance HDD should use CFQ instead.

Solution:

Create a udev rule to set HDD drives with CFQ and SDCARD/SSD devices with deadline

Example:
/etc/udev/rules.d/60-ioschedulers.rules

# set scheduler for non-rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*|nvme[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
# # set scheduler for rotating disks
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq"

$ cat /sys/block/sd*/queue/scheduler
noop deadline [cfq]
$ cat /sys/block/mmcblk*/queue/scheduler
noop [deadline] cfq

Additional context:

The Completely Fair Queuing (CFQ) approaches the problem differently by allocating a timeslice and a number of allowed requests by queue depending on the priority of the process submitting them. It supports cgroup that allows to reserve some amount of I/O to a specific collection of processes. It is in particular useful for shared and cloud hosting: users who paid for some IOPS want to get their share whenever needed. Also, it idles at the end of synchronous I/O waiting for other nearby operations, taking over this feature from the anticipatory scheduler and bringing some enhancements. Both the anticipatory and the elevator schedulers were decommissioned from the Linux kernel replaced by the more advanced alternatives presented above.

https://wiki.archlinux.org/index.php/Improving_performance#Input.2Foutput_schedulers

@Generator Generator changed the title Use CFQ for HDDs Use CFQ scheduler for HDDs Nov 10, 2018
@Fourdee
Copy link
Collaborator

Fourdee commented Nov 11, 2018

@Generator

Many thanks for the info 👍

We'll review this when possible and assess if a roll-out is beneficial.

@MichaIng MichaIng added this to the Planned for implementation milestone Feb 27, 2019
@MichaIng MichaIng changed the title Use CFQ scheduler for HDDs System | Use CFQ scheduler for HDDs Feb 27, 2019
@MichaIng MichaIng modified the milestones: Planned for implementation, v6.24 May 11, 2019
@MichaIng MichaIng modified the milestones: v6.24, v6.25 May 15, 2019
@MichaIng
Copy link
Owner

MichaIng commented Jun 3, 2019

@Generator
I want to implement this with v6.25.

deadline is btw only for RPi and done by default cmdline.txt that comes with Raspbian. Indeed this does not make much sense rot rotating disks.

One question is:

  • I am not 100% sure if all kernels that we ship supports rotational/non-rotational detection, although sure enough. Just read on old docs that /sys/block/*/queue/rotational does/did not always exist or show correct values.
  • Perhaps we should allow to set custom schedulers for each drive via dietpi-drive_manager? Do you know if it is possible to add additional udev rules for specific drives that override the ones you suggested above? Although I could just test this myself quickly 😉.

Ah hmm, on my RPi2 (Buster, kernel 4.19) the available schedulers are different:

2019-06-03 23:37:20 root@micha:/tmp# cat /sys/block/{sd,mmc}*/queue/scheduler
[mq-deadline] kyber none
[mq-deadline] kyber none
[mq-deadline] kyber none
  • Actually it looks like, if custom kernels, usually shipped with/for SBCs, support different I/O scheduler sets, we can only allow to change the scheduler via dietpi-drive_manager, by estimating the supported list first.

@Generator
Copy link
Author

The only other way that i know is with lsblk

$ lsblk -d -o name,rota
NAME    ROTA
sda        1
mmcblk0    0

See 5 Commands to Know If a Disk is SSD or HDD in Linux

@MichaIng
Copy link
Owner

MichaIng commented Jun 3, 2019

@Generator
As above, we can anyway not ship fixed udev rules since the supported schedulers are different.
On VM Stretch (kernel 4.9) it's as one finds it on most online docs and guides about this topic, CFQ set by default, as we do not touch it:

root@VM-Stretch:~# cat /sys/block/sda/queue/scheduler
noop deadline [cfq]

On VM Buster (kernel 4.19) as well mq-deadline (like RPi kernel 4.19) is available, but no CFQ or BFQ at all:

root@VM-Buster:~# cat /sys/block/sda/queue/scheduler
[mq-deadline] none

Quick search didn't show much about kyber, besides it is developed by Facebook 🤔.

@MichaIng MichaIng changed the title System | Use CFQ scheduler for HDDs DietPi-Drive_Manager | Allow to switch I/O scheduler Jun 8, 2019
@MichaIng
Copy link
Owner

MichaIng commented Jun 9, 2019

PR merged: #2902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants