![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Ultimate Coffee Grinder
![]() Join Date: Oct 2004
Location: Cambridge. MA
Beans: 5,070
Ubuntu 8.10 Intrepid Ibex
|
Improve (potentially halve) login time by using readahead
NOTE: This tip NO LONGER APPLIES to Ubuntu 9.10 and higher -- these releases use a new "sreadahead" subsystem that takes care of reprofiling automatically whenever the bootup sequence changes (and also monthly).
PREFACE: It has been well-documented that Ubuntu's readahead system during boot significantly cuts down on boot time by reducing hard disk seeking via precaching commonly-used files during bootup. This feature, however, only lasts up to the GDM screen. The average modern PC should be able to boot Ubuntu from GRUB to the GDM screen in under 30 seconds -- roughly half of what it would be if readahead were to be turned off. For me, I start a lot of things when I log into my GNOME session. My laptop boots from GRUB to GDM in about 14 seconds, but from the moment I log in to a full desktop is nearly 40 seconds, most of the time the disk is seeking like crazy. This led me to wonder, is it possible to extend readahead's benefits to accelerate the login sequence? RISK/KNOWLEDGE DISCLAIMER: This guide asks you to use the command-line to issue some commands, and uses the readahead-list and readahead-watch applications to profile a bootup. Changes to the system are easily reversible and the worst negative impact would be a reduction in login speed (the irony!). Of course, since you will be doing some things with root access, failure to correctly type in some commands may lead to permanent damage to your software or data. These changes are unsupported by Ubuntu developers. SYSTEM SPECS: Ubuntu Gutsy on Core Duo 1.66GHz with 1GB RAM. Slow laptop 5400RPM drive. You probably shouldn't try this unless you have more than 512MB RAM. System was rebooted cleanly and I inputted my login when all disk activity stopped. Then, I logged in and waited for all disk activity to stop again. This login time is what I aim to reduce. On my particular system, with a highly customized GNOME session, this login time without optimization is: 40 seconds. A subsequent login (where everything would be cached, ideal boot speed with disk bottleneck removed) takes: 13 seconds. I will try to get as close to that as possible! PART 1: Profile Login Sequence First, we need to ask readahead to monitor a login sequence and make note of all the files read during this period. Advanced users may point out that during bootup, there is a GRUB argument "profile" that causes Ubuntu to optimize bootup. We will need to essentially manually replicate what this boot option does, but save the output to a different file. First, let's store our readahead list into a ~/.readahead directory. Code:
mkdir ~/.readahead Code:
sudo readahead-watch -o ~/.readahead/gnome.root / after you are fully logged in, press CTRL+ALT+F1 to go back to your terminal, then run: Code:
sudo killall readahead-watch sudo chown jdong:jdong ~/.readahead -R Code:
cat ~/.readahead/gnome.root | xargs -i ls -lk {} | sort -rn -k +5 | less
If you have home on a different partition as root, you should repeat Part 1 for each partition, replacing gnome.root with a different name, and replacing the mountpoint / with each interested mountpoint. PART 2: Hooking this into the login sequence. Next, we need to tell Ubuntu to do this readahead on every login. I am going to use /etc/X11/Xsession.d for this, but if you have another preferred way to execute things before everything loads, be my guest! Create a file called /etc/X11/Xsession.d/00readahead and put this in it: Code:
for list in ~/.readahead/*; do readahead-list $list & done wait "hang" at the orange screen while the disk works without much grinding, then once that is done the bootup should soar as if it were a fully cached login. This brings my login session to around 30 seconds, a notable improvement. PART 3: Hook into bootup sequence Often times, we don't log in immediately when the prompt comes up. We might be getting a cup of coffee, or an entire lab might be turned on before students arrive. It makes sense to cache a login as a part of bootup. Open up /etc/rc.local in your favorite text editor, and before the exit 0 statement, add: Code:
for list in /home/jdong/.readahead/*; do readahead-list $list done Now, reboot, and wait for all disk activity to stop before logging in. This time, I get a login speed of 19 seconds. You might have two common questions at this point: 1. How much time does it take to call readahead again on files that have been cached once already? About 0.05 seconds to call readahead on the same list a second time 2. How much overhead does it add to bootup if the background readahead was still going, and you tried to log in? About 2 seconds on my setup CONCLUSION: In my case, applying this readahead hack lead to a 10-second improvement in login speed in the worst-case scenario, and a remarkable doubling in login speed when the system idles at the login prompt for a few seconds. This is a pretty appreciable improvement and it would be nice if a nicer version of this hack can be added to Ubuntu. The basic idea should be fairly simple to adapt to an /etc/readahead/readahead.gnome file representative of the default system and hooked by an Xsession.d script. Potential follow-ups? Many more applications come to mind as taking a long time to load while the disk grinds (Firefox? Openoffice? Eclipse?). You can use a procedure very similar to this to write a "wrapper script" that first performs a readahead-list call on a list, then call the application with the original arguments. I'd be interested to hear of any improvements gained by that method. Undoing This Tip Remove, remove, remove! Delete the ~/.readahead directory, delete /etc/X11/Xsession.d/00readahead, and delete the line you added to /etc/rc.local Last edited by jdong; November 2nd, 2009 at 10:40 AM.. |
|
|
|
|
|
#2 |
|
Just Give Me the Beans!
![]() Join Date: Feb 2007
Location: San Francisco
Beans: 73
Ubuntu 6.10 Edgy
|
Re: Improve (potentially halve) login time by using readahead
F
|
|
|
|
|
|
#3 |
|
Ultimate Coffee Grinder
![]() Join Date: Oct 2004
Location: Cambridge. MA
Beans: 5,070
Ubuntu 8.10 Intrepid Ibex
|
Re: Improve (potentially halve) login time by using readahead
Thanks, fixed.
|
|
|
|
|
|
#4 |
|
Just Give Me the Beans!
![]() Join Date: Feb 2007
Location: San Francisco
Beans: 73
Ubuntu 6.10 Edgy
|
Re: Improve (potentially halve) login time by using readahead
WOW!
Great how-to. I only did the first 2 parts (since I auto login to my main user there's no wait before login -- should I go ahead and do part 3?) but hot damn my login is fast. Ubuntu already beat XP (about 1/5 the time) but now I'm up and running less than a minute after hitting the power button. PS: When I did this, CTRL+ALT+F7 got me back into the wonderful world of X -- not CTRL+ALT+F8 This should DEFINITELY be a part of all future Ubuntu releases. |
|
|
|
|
|
#5 | |
|
Ultimate Coffee Grinder
![]() Join Date: Oct 2004
Location: Cambridge. MA
Beans: 5,070
Ubuntu 8.10 Intrepid Ibex
|
Re: Improve (potentially halve) login time by using readahead
Quote:
If you auto-login, there is no reason to do part 3. That's more for people who find themselves booting up and having the computer wait for you to log in. |
|
|
|
|
|
|
#6 |
|
Way Too Much Ubuntu
![]() Join Date: Aug 2005
Location: CA
Beans: 252
Ubuntu 9.04 Jaunty Jackalope
|
Re: Improve (potentially halve) login time by using readahead
Sweet. I'm assuming that the file
Code:
/gnome.root / I'm running Kubuntu, and I just want to make sure I don't need to change anything. If my thinking is correct, I could either leave the filename alone, since it really doesn't matter, or change it to kde.root and have the same impact, is that correct? thanks, jimbo
__________________
|
|
|
|
|
|
#7 |
|
Ultimate Coffee Grinder
![]() Join Date: Oct 2004
Location: Cambridge. MA
Beans: 5,070
Ubuntu 8.10 Intrepid Ibex
|
Re: Improve (potentially halve) login time by using readahead
gnome.root is just an arbitrary name, you can call it whatever you want. This procedure works with whatever login session you use.
|
|
|
|
|
|
#8 |
|
Not much coffee nor Ubuntu
![]() Join Date: Mar 2007
Location: $HOME (Washington State)
Beans: 4,583
Ubuntu 8.10 Intrepid Ibex
|
Re: Improve (potentially halve) login time by using readahead
Thanks for this howto! It worked great for me! Before it took ~30 seconds to go from Login Screen (with no disk usage) to Desktop (with no disk usage). Now, it is very quick!
__________________
See my themes here! | Dont preach Linux, mention it | Make GNOME Themes
I'm no longer on here. If you want to talk to me, go to noost.org. My DeviantArt | Linux user #461096 | Ubuntu user #15753 |
|
|
|
|
|
#9 |
|
Gee! These Aren't Roasted!
![]() |
Re: Improve (potentially halve) login time by using readahead
i wish i could claim such results on my machine, but i think readahead kind of misbehaves here : it actually slows down things very much (i noticed very high disk activity, so i suspect there's something wrong with caching - may i add there's no big file to be cached, but there seems to be a lot of small files).
note that this does not seems specific to this trick, because last time i added "profile" to my kernel grub entry (in order to speed up next booting processes using readahead), my bootcharts jumped from 60-65 seconds, to somewhere near 200 seconds. Culprit was : readahead. it would generate high disk activity for about 140 seconds. maybe my ubuntu installation is getting old and messy…
__________________
Kubuntu on ACER Aspire 9800 series laptop (9814 WKMi) My Kubuntu KDM themes what goes up must come down... |
|
|
|
|
|
#10 |
|
Ultimate Coffee Grinder
![]() Join Date: Oct 2004
Location: Cambridge. MA
Beans: 5,070
Ubuntu 8.10 Intrepid Ibex
|
Re: Improve (potentially halve) login time by using readahead
Hmm, how much RAM do you have?
Also, have you used the last command in part 1 to check what sizes are the files Readahead wants to load? I suspect there's some sort of large ISO image or something that Readahead is thinking it should load into RAM, but it really shouldn't. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|