[SCRIPT] I/O Scheduler Changer
While spending some time in the Humble ROM thread, the discussion had turned toward changing the phone's I/O Scheduler to improve performance. Some people stated they had used Tegrak to execute the change. Since I personally don't overclock my phone, I decided that paying for Tegrak wasn't worth it to me just for the I/O Scheduler tweak. As such, I wrote a little bash script to handle the change for me.
The script deals only with the five blocks that pertain to the Droid Charge: stl9, stl10, stl11, mmcblk0, and mmcblk1. It also only deals with three scheduler types: noop, deadline, and cfq. These were the only scheduler options available on my phone. Let me know if you have other schedulers available, and I can look into adding them. Also, if you have some reason that another block should be added, let me know what block and why.
Installation / Use
- Root access is required!
1. Place the script in the location of your choosing, most likely on your SDCard, and remove the .txt from the end of the file name
2. Run the script via command line or the Script Manager app (it must
be run as root!)
3. The script will show you the phone's current I/O Scheduler settings
4. The script will prompt you to choose a new I/O Scheduler setting
5. After you make a selection, the script will create a secondary script, /data/99CilSchedChanger.sh, which is the script that actually makes the scheduler change. If the script already exists (any time after the initial running of the script, for example), it will be recreated
6. The script will then run /data/99CilSchedChanger.sh to make the change and display the results
7. (optional) Set /data/99CilSchedChanger.sh to run on boot, which can be done with either the Script Manager app or by soft-linking it to your init.d directory (if your ROM allows init.d usage)
: To access 99CilSchedChanger.sh within /data, you will need to set Script Manager to browse as root. You can do so by doing the following:
1. Press the menu button
2. Select Browse
3. Press the menu button
4. Select More
5. Select Advanced options
6. Select Config
7. Check "Browse as Root"
What is an I/O Scheduler?
An I/O (input/output) scheduler exists to prioritize requests to storage. Its main purpose is to increase read/write performance.
Why would I want to change my I/O Scheduler?
The default I/O Scheduler on the Droid Charge is cfq. This stands for Completely Fair Queuing. Cfq was created to prioritize I/O requests in a way that minimizes the distance that a hard drive's head needs to move. As such, it speeds up all of the requests, since it's not moving the hard drive's head from one end of the drive to the other and back. There's just one problem... our phones use flash memory, which have no physically moving parts. This means that cfq is not necessarily the best scheduler for our purposes.
What are "noop" and "deadline"?
The noop and deadline schedulers have been shown to improve performance on our phones. Noop is pretty much what is says: no operation. It doesn't use any algorithm to prioritize I/O requests. It's pretty much first come, first served. Deadline is a scheduler that places a, well, deadline on I/O requests. This essentially tells the scheduler that this I/O request needs to be fulfilled by 'x' time. This can prevent one process from monopolizing I/O.
Which scheduler is the best for my phone?
Most discussion has shown that both noop and deadline give better performance than cfq. Which of the two is better, though, is up for debate. Try both and see which feels snappier to you!
Do I need to reboot after changing my I/O Scheduler?
No. Changes are made dynamically and a reboot is not required.
What if I want to go back to default/uninstall?
If you want to go back to default, simply run the script again and choose the option for cfq. This is the default I/O Scheduler for the Droid Charge, so choosing that option will make your phone as if the script was never run. If you want to uninstall the script, simply delete /data/99CilSchedChanger.sh and CilSchedChngCtrl.sh (from wherever you placed it).
- Code cleanup and commenting is done: The code is now consistant on whether or not to use an end-of-line semi-colon, all code blocks are commented properly, and variables are unset when no longer needed
- Code comments header was added. This includes version number, link to this thread, and author information
- Before and after displays were changed to parse out only the currently used scheduler (rather than showing the raw output, as the last version did)
- The menu system was completely re-written to be dynamic. If you happen to somehow have a scheduler other than cfq, noop, or deadline, then it should be added to the menu. Note: the script pulls the potential menu options from block stl10 (/system)
- /data/99CilSchedChanger.sh is now re-written every time the control script is run, rather than just modifying the default. This should make future releases "cleaner", rather than requiring the end-user to delete /data/99CilSchedChanger.sh. The resource cost is minimal
- /data/99CilSchedChanger.sh can be called directly with a command line option of a scheduler type (for instance, "/data/99CilSchedChanger.sh noop"). This was possible before, but has now been made dynamic. When the control script is run, all possible schedulers are dumped into /data/99CilSchedChanger.sh to be checked against the command line option. This is an entirely optional way to run the script
Have questions? Post them here and I'll do my best to answer them.