Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 303044 - sys-apps/ureadahead ebuild request
Summary: sys-apps/ureadahead ebuild request
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal with 1 vote (vote)
Assignee: Default Assignee for New Packages
URL: https://launchpad.net/ureadahead
Whiteboard:
Keywords:
Depends on: 310093
Blocks:
  Show dependency tree
 
Reported: 2010-02-01 00:15 UTC by lordcris
Modified: 2011-05-21 08:32 UTC (History)
16 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
sys-apps/ureadahead/ureadahead-0.100.0.ebuild (ureadahead-0.100.0.ebuild,892 bytes, text/plain)
2010-02-02 15:17 UTC, lordcris
Details
sys-apps/ureadahead/files/ureadahead.rc (ureadahead.rc,999 bytes, text/plain)
2010-02-02 15:17 UTC, lordcris
Details
dev-libs/libnih/libnih-1.0.0.ebuild (libnih-1.0.0.ebuild,464 bytes, text/plain)
2010-02-02 15:17 UTC, lordcris
Details
updated ebuild (ureadahead-0.100.0.ebuild,1.24 KB, text/plain)
2010-03-18 14:39 UTC, Bruno 'brubru' Tarquini
Details
new init.d script (ureadahead.initd,1.32 KB, text/plain)
2010-03-18 14:47 UTC, Bruno 'brubru' Tarquini
Details
init.d trying to follow Xake's advices (ureadahead.initd,2.04 KB, text/plain)
2010-03-18 22:22 UTC, Bruno 'brubru' Tarquini
Details
profile for a normal boot (bootchart_normal.svg,233.13 KB, image/svg)
2010-04-15 08:48 UTC, Bruno 'brubru' Tarquini
Details
profile for ureadahead (bootchart_ureadahead.svg,174.34 KB, image/svg)
2010-04-15 08:49 UTC, Bruno 'brubru' Tarquini
Details
Bootchart with ureadahead in init process (bootchart_no.png,181.29 KB, image/png)
2010-08-07 10:40 UTC, Genkaku
Details
Bootchart with NO ureadahead in init process (bootchart_ur.png,226.14 KB, image/png)
2010-08-07 10:40 UTC, Genkaku
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lordcris 2010-02-01 00:15:28 UTC
We need an init script wich loads ureadahead for fast boot.

Reproducible: Always
Comment 1 lordcris 2010-02-02 15:17:01 UTC
Created attachment 218183 [details]
sys-apps/ureadahead/ureadahead-0.100.0.ebuild

courtesy of mantoo  and tgR10

sys-apps/ureadahead/ureadahead-0.100.0.ebuild
Comment 2 lordcris 2010-02-02 15:17:26 UTC
Created attachment 218185 [details]
sys-apps/ureadahead/files/ureadahead.rc
Comment 3 lordcris 2010-02-02 15:17:47 UTC
Created attachment 218187 [details]
dev-libs/libnih/libnih-1.0.0.ebuild
Comment 4 lordcris 2010-02-02 15:19:16 UTC
i've attached the two ebuild posted on gentoo forum.
don't forget to update sys-kernel/linux-headers to 2.6.30-r1
and sys-libs/glibc to 2.11-r1
Comment 5 Xake 2010-03-12 07:41:55 UTC
(In reply to comment #2)
> Created an attachment (id=218185) [details]
> sys-apps/ureadahead/files/ureadahead.rc
> 

I think I actually would see two of these,
on early (that only needs root) and then one for localmount that passes external mount points onto the ureadahead command line (just like ubuntu does it).

That would also need changes to the libnih ebuild (pass --disable-static and --libdir=/$(get_libdir) to the econf and remove *.la) and changes to the ureadahead ebuild (add --sbindir=/sbin).

Also does ureadahead stop tracing when boot is done with your initscript?
Comment 6 Bruno 'brubru' Tarquini 2010-03-18 14:39:29 UTC
Created attachment 224121 [details]
updated ebuild

Changes:
 * mores deps, some checks on the kernel config
 * binary in /sbin instead of /usr/bin
 * new init.d, as ureadahead act like a service not a daemon (it stop at end of boot)

I opened a new bug for libnih (bug: 310093)
Comment 7 lordcris 2010-03-18 14:42:13 UTC
brublu,
could you post also the ureadahead.initd file?
thanks

Comment 8 Bruno 'brubru' Tarquini 2010-03-18 14:47:34 UTC
Created attachment 224123 [details]
new init.d script

This script have only been tested with openrc.

If you have a separate partition for /var, put it in boot runlevel, either you can try to run it in sysinit runlevel.

I stop the tracing with a timeout (60sec), I tried to send a TERM signal at the end of the default runlevel with a script like:

depend() {
    after '*'
}
start() {
    start-stop-daemon --stop --name ureadahead
}

But the boot time was worse (not enough data cached/wrong data cached).
Comment 9 Xake 2010-03-18 15:50:49 UTC
(In reply to comment #8)
> Created an attachment (id=224123) [details]
> new init.d script
> 
> This script have only been tested with openrc.
> 
> If you have a separate partition for /var, put it in boot runlevel, either you
> can try to run it in sysinit runlevel.
> 

This does not handle if you have a /var/lib/ureadahead in your / and /usr is mounted from elsewhere.
During boot you probably want files from /usr readahead also.

I think two files (like ubuntus ureadahead and ureadahead-other) is the way to go, one reading files for /, and the other reading files from specified mountpoints.

Also do ureadahead really readahead files from other mountpoint then / if you do not specify them (i.e. if you have /, /usr as two mountpoints and do not give ureadahead any options, will it read ahead both or just from /)?
Comment 10 Bruno 'brubru' Tarquini 2010-03-18 22:22:11 UTC
Created attachment 224199 [details]
init.d trying to follow Xake's advices

Ok, now the init script have two phases:

step 1:
 - run ureadahead without args so it read-ahead the root (/)
 - it may do tracing for all the system (force-tracing on cmdline, outdated
   packs files)

step 2:
 - iterate all /var/lib/ureadahead/*.pack files and run ureadahead on it
   (this will read-ahead mountpoints: /home, /usr...)

with only ureadahead in boot level (rc-update add ureadahead boot), the two phases are run after localmount in order. But, if you make a symlink like this:
«ln -s ureadahead /etc/init.d/ureadahead.early»
and add it to sysinit:
«rc-update add ureadahead.early sysinit»

then, the phases are split in the two runlevels:
 step1 in sysinit
 step2 in boot

Well, as ureadahead can run with several modes (HDD, SDD, tracing, forced tracing, multiple mountpoints or not...), it's not easy to figure out all possibles paths. There can be bugs/race conditions if two processes (one tracing, one reading) work at the same time.

Tested here with an HDD and only one mountpoint (/home)
Comment 11 Arthur Spitzer 2010-04-14 11:19:50 UTC
(In reply to comment #10)
> Tested here with an HDD and only one mountpoint (/home)
Bruno, with your setup, does ureadahead decrease your boottime? Can you show some comparing times or even bootcharts?
Comment 12 Bruno 'brubru' Tarquini 2010-04-15 08:48:42 UTC
Created attachment 227865 [details]
profile for a normal boot

Follow two bootcharts of my setup done after a fresh tracing.

I modified bootchart to stop 30sec after X has started (instead of 5s), so I can see the start of xfce. I doesn't use any desktop manager but a script with su USER + startx.
My HDD is a Maxtor 6Y080P0, YAR41BW0, max UDMA/133 (PATA) so not really fast (around 50MB/sec from hdparm), but with ureadahead, there is a peak at 45MB/s (instead of 20MB/s)

By looking the end of CPU and Disk utilization, I have a boot of 59s for normal and 41s for ureadaread, so 18s wons ! We can see that ureadahead takes long time to run (~16s) so Xorg starts later (at 31 instead of 21) but the load of xfce is then really fast, so this is a global win.

It would be interesting to see some bootcharts from a SSD setup.
Comment 13 Bruno 'brubru' Tarquini 2010-04-15 08:49:23 UTC
Created attachment 227867 [details]
profile for ureadahead
Comment 14 Martin Benz 2010-04-23 15:47:29 UTC
Which kernel options under kernel hacking / tracers are needed? In the message for ureadahead it says you need to activate Trace process context switches and events (ENABLE_DEFAULT_TRACERS) too, but that option isn't avaiable with gentoo-sources and zen-sources 2.6.33...
Comment 15 Xake 2010-04-25 15:50:56 UTC
(In reply to comment #14)
> Which kernel options under kernel hacking / tracers are needed? In the message
> for ureadahead it says you need to activate Trace process context switches and
> events (ENABLE_DEFAULT_TRACERS) too, but that option isn't avaiable with
> gentoo-sources and zen-sources 2.6.33...

Just search for it (use '/' in make menuconfig) because some options enable it (and makes it disapperes from menuconfig) so it is possible you have it enabled even if you cannot find it.
Comment 16 gpiez 2010-06-02 11:58:36 UTC
It works for me with kernel-2.6.34 and the mentioned patch. I have /var on a separate mountpoint (other mount points are /usr, /home, /boot).

With ureadahead.early in sysinit I doesn't seem to work for me, but after I removed it and left only ureadahead in the boot runlevel ist works. 

Boot times are down from ~80 second to ~60 seconds into kde with a running firefox :-)
Comment 17 Pooky 2010-06-20 00:28:32 UTC
There's a problem the newest ebuild that was posted. When ureadahead installs it will create the /var/lib/ureadahead folder if it doesn't exist, but it fails to create a /var/lib/ureadahead/debugfs folder. This will cause ureadahead to spit out "ureadahead: Error while tracing: No such file or directory" for most users. 

The issue here is that ureadahead checks if debugfs is already mounted at /sys/kernel/debug, and if it's not it will attempt to mount it at /var/lib/ureadahead/debugfs. In my opinion ureadahead should always use the normal mount point of /sys/kernel/debug, but the author doesn't seem to agree. At least the fix is simple:
mkdir /var/lib/ureadahead/debugfs

This logic is also the cause of ureadahead.early failing for users with a seperate /var partition. Unless you have debugfs mounted very early it will attempt to mount one under the folder in /var, which doesn't exist yet. Fixing this is a bit more complicated, you need to change where ureadahead mounts debugfs when it doesn't find one already mounted by patching the source code as such:

Alter line 78 of src/trace.c from
#define PATH_DEBUGFS_TMP "/var/lib/ureadahead/debugfs"
to:
#define PATH_DEBUGFS_TMP "/sys/kernel/debug"

Or even better, just remove line 78 and then change lines 138 and 141 to use PATH_DEBUGFS instead of PATH_DEBUGFS_TMP.

Since this patch will also fix the missing directory problem, should the new ebuild patch the source code or just make the missing folder? I vote patch, but would like other opinions on the matter. 
Comment 18 Genkaku 2010-08-05 15:26:40 UTC
On my machine ureadahead was always erorring with: "ureadahead: Error while tracing: No such file or directory", even doing mkdir /var/lib/ureadahead/debugfs did not help. But the solution posted above:
(> Alter line 78 of src/trace.c from
> #define PATH_DEBUGFS_TMP "/var/lib/ureadahead/debugfs"
> to:
> #define PATH_DEBUGFS_TMP "/sys/kernel/debug" )
and applying the patch to the kernel have helped.

The thing is that my bootchart clearly states that xfce is not read ahead. I do not use any graphical login manager like xdm/kdm.

Is there a possibility to make ureadahead trace apps after boot process?
Comment 19 Bruno 'brubru' Tarquini 2010-08-05 18:49:03 UTC
@gentaku from private message:

To make bootchart run longer after the boot,
I simply patched bootchartd like this:

--- script/bootchartd	2005-11-13 18:40:01.000000000 +0100
+++ /sbin/bootchartd	2009-09-03 16:42:00.000000000 +0200
@@ -101,7 +101,7 @@
 		# Write the time (in jiffies).
 		read uptime < /proc/uptime
 		uptime=${uptime%% [0-9]*}
-		uptime=${uptime/./}
+		uptime=${uptime%%.*}${uptime##*.}
 		echo $uptime
 
 		# Log the command output
@@ -127,7 +127,7 @@
 	while [ -f "$BOOTLOG_LOCK" ]; do
 		if [ -n "$( pidof $exit_proc )" ]; then
 			# Give the exit process some time to start
-			sleep 5
+			sleep 30
 			# Flush the log files
 			stop
 			return
@@ -247,7 +247,7 @@
 		killall -USR1 bootchartd
 		;;
 	*)
-		echo $"Usage: $0 {init|start|stop}"
+		echo "Usage: $0 {init|start|stop}"
 		;;
 esac

The sleep thing in wait_boot() is important.
Looking in code, if you don't use any dm, i think you should be in initlevel 2 or 3 (from inittab) so bootchart will use exit_proc="mingetty agetty rungetty getty" to stop the log.

@on debugfs problem:
I've put "need sysfs" in the initscript so debugfs should be mounted on /sys/kernel/debug. Beware, my script is OpenRC only.

The early script trick isn't for a /var separated and there is no checks when the script is run so it make the default script run badly after. More checks on this would be good.
Eventually, months after, I fail to read my-self... maybe time to rework the logic in it !

;-)

Cheers.
Comment 20 Genkaku 2010-08-06 15:50:08 UTC
(In reply to comment #19)
Yes, yesterday I've managed to prolong bootchartd run time. With that I clearly saw that ureadahead didn't trace X server / xfce. And ls -sh /var/lib/ureadahead/
gives
4,0K debugfs  4,0K lib64.rc.init.d.pack  352K pack
which is obviously too small to have X and xfce in it.

Ureadahead should run longer - for it does on e.g. Ubuntu,
but not here... I wonder why :>
Comment 21 Bruno 'brubru' Tarquini 2010-08-06 16:26:20 UTC
(In reply to comment #20)
> Yes, yesterday I've managed to prolong bootchartd run time. With that I clearly
> saw that ureadahead didn't trace X server / xfce. And ls -sh
> /var/lib/ureadahead/
> gives
> 4,0K debugfs  4,0K lib64.rc.init.d.pack  352K pack
> which is obviously too small to have X and xfce in it.

with somthing like:

 ureadahead --dump <pack> | grep "^/"

you can see what files are read by ureadahead

> 
> Ureadahead should run longer - for it does on e.g. Ubuntu,
> but not here... I wonder why :>
> 

timeout is set by default to 60sec in /etc/init.d/ureadahead
change this by putting:

tracing_timeout=120...

in /etc/conf.d/ureadahead (create it if need)

Too, I think you can put a very long value and send TERM or INT to the process to stop it manually when you want.
Comment 22 Genkaku 2010-08-07 10:39:08 UTC
Thank you very much! Now I see clearly that xfce had been traced after setting timeout to 120s.

Now I would love if somebody helped me with interpretation of bootchart graph.

The problem is I am very uncertain when system has stopped loading.

I'm giving two charts, one with and one without ureadahead.
Any help would be appreciated.
Comment 23 Genkaku 2010-08-07 10:40:01 UTC
Created attachment 241757 [details]
Bootchart with ureadahead in init process
Comment 24 Genkaku 2010-08-07 10:40:33 UTC
Created attachment 241759 [details]
Bootchart with NO ureadahead in init process
Comment 25 Jordan 2010-08-11 19:06:10 UTC
I'm trying to get ureadahead working and I keep getting
>ureadahead: Error while tracing: No such file or directory
I changed the debugfs directory in the source code and made the /var/lib/ureadahead folder but it still appears.
Comment 26 Bruno 'brubru' Tarquini 2010-08-11 20:00:48 UTC
@for ALL

please, give your configuration:
- SSD/HDD
- separat partitions /, /home, /var, /usr...
- OpenRC !

This bug is for debugging the ebuild and his init script, feedbacks are welcome !

@gentaku

looking your pics (swapped, it seems), I would look after the wicd service which delay the boot a little, maybe you can play with the /etc/rc.conf:rc_depend_strict option and/or rc_hotplug
Try to start the network as late as possible (after X).

(OT) Others rules are:
 * as many driver built-in in kernel.
 * avoid hot-plugged service by udev.
look at http://lwn.net/Articles/299483/ and others google things...

@jordan

Can you check if you have debugfs mounted on /sys/kernel/debug/
if so, have you thoses files under it:

./tracing/available_events (grep for "fs:")
./tracing/available_tracers
./tracing/trace
./tracing/tracing_enabled
./tracing/events/fs
./tracing/events/fs/do_sys_open
./tracing/events/fs/uselib
./tracing/events/fs/open_exec

Too, check write permission for /var/lib/ureadahead
Comment 27 Berend Dekens 2010-09-20 11:25:57 UTC
(In reply to comment #26)
> @jordan
> 
> Can you check if you have debugfs mounted on /sys/kernel/debug/
> if so, have you thoses files under it:
> 
> ./tracing/available_events (grep for "fs:")
> ./tracing/available_tracers
> ./tracing/trace
> ./tracing/tracing_enabled
> ./tracing/events/fs
> ./tracing/events/fs/do_sys_open
> ./tracing/events/fs/uselib
> ./tracing/events/fs/open_exec
> 
> Too, check write permission for /var/lib/ureadahead
> 
I too get the error even after creating the debugfs directory (which imho should be created in the current ebuild, even if its a temporary fix).

The tracing directory however does not have the "fs" subdirectory. I am currently applying the "optional" patch (which everyone seems to be applying regardless) to see if that fixes the problem.