What is an I/O Scheduler:
Input/output (I/O) scheduling is a term used to describe the method computer operating systems decide the order that block I/O operations will be submitted to storage volumes. I/O Scheduling is sometimes called 'disk scheduling'.
I/O schedulers can have many purposes depending on the goal of the I/O scheduler, some common goals are: - To minimise time wasted by hard disk seeks. - To prioritise a certain processes' I/O requests. - To give a share of the disk bandwidth to each running process. - To guarantee that certain requests will be issued before a particular deadline.
Which schedulers are available? CFQ Deadline VR Noop Anticipatory BFQ FIOPS SIO (Simple) Row ZEN Sioplus FIFO Tripndroid Test
Things to look out for in an I/O scheduler:
There are many I/O schedulers available on android, but there are some important things people should look out for before selecting their new scheduler:
- Speed - The more the better!!!! Usually having lots of speed equates to lower battery life, so it is best to balance this out.
- Battery life - More of this means more battery life!!! Being very battery friendly usually means less speed (or sometimes smoothness), so it's best to balance this out.
- Stability - Some schedulers are plain unstable and some are rock solid. Of course people would want a stable I/O scheduler!!!
- Multitasking capabilities - An important factor to I/O schedulers. Some schedulers can handle lots of apps, some can't. Usually being more multitasking capable equates to higher i/o latency, so it is best to balance this out. - Smoothness (or Fluidity) - This is not the same as speed, a scheduler can be fast but it doesn't mean it is smooth. A way to test this is to scroll down/up pages or open and close apps. Of course, more smoothness = awesome phone experience
Descriptions:
Anticipatory: Anticipatory scheduling is an algorithm for scheduling hard disk input/output. It seeks to increase the efficiency of disk utilization by "anticipating" synchronous read operations. It is very rare to see this scheduler on mobile phones.
Benefits: - Requests of read accesses are never treated secondarily, that has equally good reading performance on flash drives like noop. Disadvantages: - Requests from process operations are not always available - Reduced write performance on high-performance hard drives - Not very common in most kernels CFQ: Completely Fair Queuing scheduler maintains a scalable per-process I/O queue and attempts to distribute the available I/O bandwidth equally among all I/O requests. Each per-process queue contains synchronous requests from processes. Time slice allocated for each queue depends on the priority of the 'parent' process. V2 of CFQ has some fixes which solves process' i/o starvation and some small backward seeks in the hope of improving responsiveness.
Benefits: - Has a well balanced I / O performance - Excellent on multiprocessor systems - Regarded as a stable I/O scheduler - Good for multitasking Disadvantages: - Some users report media scanning takes longest to complete using CFQ. This could be because of the property that since the bandwidth is equally distributed to all i/o operations during boot-up, media scanning is not given any special priority. - Jitter (worst case delay) can sometimes be very high because the number of competing with each other process tasks - Under constant load, the phone will experience increased I / O latency due to the way how the scheduler tries to create 'fairness' Deadline: The goal of the Deadline scheduler is to attempt to guarantee a start service time for a request. It does that by imposing a deadline on all I/O operations to prevent starvation of requests. It also maintains two deadline queues, in addition to the sorted queues (both read and write). Deadline queues are basically sorted by their deadline (the expiration time), while the sorted queues are sorted by the sector number. Before serving the next request, the Deadline scheduler decides which queue to use. Read queues are given a higher priority, because processes usually block on read operations. Next, the Deadline scheduler checks if the first request in the deadline queue has expired. Otherwise, the scheduler serves a batch of requests from the sorted queue. In both cases, the scheduler also serves a batch of requests following the chosen request in the sorted queue. Benefits: - Nearly a real-time scheduler. - Excels in reducing latency of any given single I/O - Best scheduler for database access and queries. - Does quite well in benchmarks, most likely the best - Like noop, a good scheduler for solid state/flash drives Disadvantages: - If the phone is overloaded, crashing or unexpected closure of processes can occur ROW:
The ROW IO scheduler was developed with the mobile devices needs in mind. In mobile devices, we favor user experience upon everything else, thus we want to give READ IO requests as much priority as possible. In mobile devices we won't have as much parallel threads as on desktops. Usually it's a single thread or at most 2 simultaneous working threads for read & write. Favoring READ requests over WRITEs decreases the READ latency greatly. The main idea of the ROW scheduling policy is: If there are READ requests in pipe - dispatch them but don't starve the WRITE requests too much. Benefits: - Faster UI navigation and better overall phone experience - Faster boot times and app launch times Disadvantages: - Not great for heavy multitasking - Slower write speeds SIO (Simple): Simple I/O scheduler aims to keep minimum overhead to achieve low latency to serve I/O requests. No priority quesues concepts, but only basic merging. Sio is a mix between noop & deadline. No reordering or sorting of requests. Benefits: - It is simple and stable. - Minimized starvation for inquiries - Good battery life Disadvantages: - Slow random write speeds on flash drives as opposed to other schedulers. - Sequential read speeds on flash drives are not as good as other IO schedulers Noop: Inserts all the incoming I/O requests to a First In First Out queue and implements request merging. Best used with storage devices that does not depend on mechanical movement to access data (yes, like our flash drives). Advantage here is that flash drives does not require reordering of multiple I/O requests unlike in normal hard drives. Benefits: - Serves I/O requests with least number of cpu cycles. - Is suitable for flash drives because there is no search errors - Good data throughput on db systems - Good battery life - Does great in benchmarks - Also a very reliable IO scheduler Disadvantages: - Reducing the number of CPU cycles corresponds to a simultaneous decline in performance - Not the most responsive I/O scheduler - Not very good at multitasking (especially heavy workloads) VR: Unlike other scheduling software, synchronous and asynchronous requests are not handled separately, but it will impose a fair and balanced within this deadline requests, that the next request to be served is a function of distance from the last request. Benefits: - Generally excels in random writes. Disadvantages: - Performance variability can lead to different results (Only performs well sometimes) - Sometimes unstable and unreliable BFQ: Instead of time slices allocation by CFQ, BFQ assigns budgets. Disk is granted to an active process until it's budget (number of sectors) expires. BFQ assigns high budgets to non-read tasks. Budget assigned to a process varies over time as a function of it's behavior. Benefits: - Has a very good USB data transfer rate. - The best scheduler for playback of HD video recording and video streaming (due to less jitter than CFQ Scheduler, and others) - Regarded as a very precise working Scheduler - Delivers 30% more throughput than CFQ - Being constantly updated - Good for multitasking, more responsive than CFQ Disadvantages: - Not the best scheduler for benchmarks - Higher budgets that were allocated to a process that can affect the interactivity and bring with it increased latency.
ZEN:
ZEN scheduler is based on the VR Scheduler. It's an FCFS (First come, first serve) based algorithm, but it's not strictly FIFO. ZEN does not do any sorting. It uses deadlines for fairness, and treats synchronous requests with priority over asynchronous ones. Other than that, it's pretty much the same as no-op blended with VR features. Benefits: - Well rounded IO Scheduler - Very efficient IO Scheduler - More stable than VR, more polished Disadvantages: - Performance variability can lead to different results (Only performs well sometimes) - Not found in all kernels
Sioplus:
Based on the original SIO scheduler with improvements. Functionality for specifying the starvation of async reads against sync reads; starved write requests counter only counts when there actually are write requests in the queue; fixed a bug). Benefits: - Better read and write speeds than previous SIO scheduler Disadvantages: - Fluctuations in performance may be observed - Not found in all kernels FIOPS (Fair IOPS): This new I/O scheduler is designed around the following assumptions about Flash-based storage devices: no I/O seek time, read and write I/O cost is usually different from rotating media, time to make a request depends upon the request size, and high through-put and higher IOPS with low-latency. FIOPS (Fair IOPS) ioscheduler tries to fix the gaps in CFQ. It's IOPS based, so it only targets for drive without I/O seek. It's quite similar like CFQ, but the dispatch decision is made according to IOPS instead of slice. Benefits: - Achieves high read and write speeds in benchmarks - Faster app launching time and overall UI experience - Good battery life Disadvantages: - Not very common in most kernels - Not the most responsive IO scheduler (Can make phone lag) - Not good at heavy multitasking FIFO (First in First Out): First in First Out Scheduler. As the name says, it implements a simple priority method based on processing the requests as they come in. Benefits: - Serves I/O requests with least number of cpu cycles. - Is suitable for flash drives because there is no search errors - Good data throughput on db systems Disadvantages: - Reducing the number of CPU cycles corresponds to a simultaneous decline in performance - Not very good at multitasking Tripndroid: A new I/O scheduler based on noop, deadline and vr and meant to have minimal overhead. Made by TripNRaVeR Benefits: - Great at IO performance and everyday multitasking - Well rounded and efficient IO scheduler - Very responsive I/O scheduler (Compared to FIOPS) Disadvantages: - Not found in all kernels - Performance varies between different devices (Some devices perform really well) Test: The test I/O scheduler is a duplicate of the noop scheduler with addition of test utility.It allows testing a block device by dispatching specific requests according to the test case and declare PASS/FAIL according to the requests completion error code.
Benefits: - Same as noop, but can be beneficial to kernel developers Disadvantages: - Same as noop
I/O Read-Ahead cache If you've used a custom kernel, you probably have heard of a term called Read Ahead cache or size. It's basically a cache for files that have been opened recently on your mobile device, so that they can be quickly accessed again if needed. By android default, this value has been set to 128kB. Usually having more cache means that more files can be cached, this can mean higher read and write speeds, but also this can result in more i/o latency. There is a point where increasing the I/O read ahead will have no benefit to read/write speeds.
Recommendations: For stability: Use 128kB read-head value For performance: Use 2048kB read-head value For any internal storage: Use 128kB read-ahead value For external SD cards with less than 8GB: Use 128kB read-head value For 16GB external SD cards: Use 1024kB read-head value For 32GB external SD cards: Use 2048kB read-head value For 64GB external SD cards: Use 2048kB read-head value What to remember: - More isn't always better! A higher read-ahead cache value can sometimes introduce lag during intensive read and write processes (I know this contradicts what we've been told). This is because the cache can not keep up with the systems demands! This includes during playback of online video content. This only applies to older devices like the Samsung Galaxy S2 or older. - Some SD cards can't handle high read ahead cache values, so make sure you have a genuine high quality SD card. - Default is good enough for most people, but isn't the best for performance - Not all kernels allow users to change the I/O read ahead - Performance difference varies between devices
Recommended IO schedulers:
For everyday usage: - SIO (My personal favourite) - ZEN (Second choice) - Tripndroid (Third choice) - ROW (Forth choice) - NOOP - CFQ - Deadline For battery life: - NOOP (First choice) - FIOPS (Second choice) - SIO (Third choice) - ROW (Forth choice) - FIFO For gaming: - ZEN (First choice) - Tripndroid (Second choice) - ROW (Third choice) - SIO - Deadline - CFQ For performance(Benchmarking): - FIOPS (First choice) - Deadline (Second choice) - Tripndroid (Third Choice) - NOOP - SIO For heavy multitasking: - BFQ (First choice) - CFQ (Second choice) - Deadline (Third choice)
IO Scheduler Comparison
Overall performance:
Best<------------------------------------------------------------------------->Worst FIOPS > Noop > ZEN > Tripndroid > SIO > ROW > SIOplus > VR > Deadline > BFQ > CFQ
Multitasking performance:
Less Apps<------------------------------------------------------------>Many Apps
Noop < FIFO < FIOPS < SIO < SIOplus < ROW < Tripndroid < ZEN < Deadline < VR < CFQ < BFQ
Battery life:
Best<-------------------------------------------------------------------------> Worst Noop > FIFO > FIOPS > SIO > SIOplus > ROW > ZEN > Tripndroid > Deadline > VR > CFQ > BFQ
In the end, the best i/o governor can not be easily be decided from anyone on the internet, therefore you will need to choose a scheduler that would satisfy your needs and one that you think works the best.