You are not logged in.

#1 2011-04-29 07:25:24

jlindgren
Member
Registered: 2011-02-27
Posts: 196

Improved e4rat-preload

I discovered e4rat recently (thanks to the Arch community) and have been quite pleased with it.  But one place where it can be improved is the time it takes to load inodes from the disk before starting /sbin/init.  I've cooked up a replacement for e4rat-preload that takes much less time at this stage (about 1/2 second rather than 3 on my system).  The savings come from (1) using pure C with no external library dependencies, which drops the number of linked .so files from 22 to 3, and (2) preloading only the first 100 files (both inodes and file contents) before starting /sbin/init, then continuing to load the remaining files in parallel with the normal boot sequence.

The source (a C file) is at http://www.box.net/shared/4cpzqtylck.

My results are:
Without e4rat-preload: 19.7 seconds to idle (bootchart http://www.box.net/shared/e9r8z4yjxc)
With existing e4rat-preload: 16.7 seconds to idle (bootchart http://www.box.net/shared/vht1879v7j)
With replacement e4rat-preload: 13.9 seconds to idle (bootchart http://www.box.net/shared/lhortactgi)

I am interested to hear if this makes a difference on other systems as well.

EDIT: I made a small change to the C file.  (The link is still the same.)
EDIT 2: Updated times and bootcharts.

Last edited by jlindgren (2011-04-30 02:00:36)

Offline

#2 2011-04-29 17:56:26

ethail
Member
From: Spain
Registered: 2011-02-10
Posts: 225

Re: Improved e4rat-preload

Feeling like the noob here but how is that modification applied? I mean, do you have to reinstall e4rat switching files, patching something or how...?

Can't test it without knowing how to use it, but sounds interesting.


My GitHub Page

Best Testing Repo Warning: [testing] means it can eat you hamster, catch fire and you should keep it away from children. And I'm serious here, it's not an April 1st joke.

Offline

#3 2011-04-29 18:09:28

jlindgren
Member
Registered: 2011-02-27
Posts: 196

Re: Improved e4rat-preload

Sorry, I should have given some instructions.  You don't have to do anything to your e4rat installation, this is just one executable that will sit side by side with it.

Compile the C file and copy the executable to /usr/sbin:

$ gcc -std=c99 -Wall -O2 -o e4rat-preload-lite e4rat-preload-lite.c
$ strip -s e4rat-preload-lite
$ sudo cp e4rat-preload-lite /usr/sbin

Then use init=/usr/sbin/e4rat-preload-lite instead of init=/usr/sbin/e4rat-preload on the Grub command line.

Offline

#4 2011-04-29 18:29:59

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Improved e4rat-preload

Seems to shave a couple of seconds off the boot, thanks.

Offline

#5 2011-04-29 21:49:09

Haptic
Member
Registered: 2009-09-03
Posts: 149

Re: Improved e4rat-preload

I've found a problem. This doesn't seem to respect e4rat.conf and it fails to find my custom path for the startup.log and causes a kernel panic.

Also, e4rat also complained that the executable should be located in /sbin not /usr/sbin.

Offline

#6 2011-04-29 21:55:41

jlindgren
Member
Registered: 2011-02-27
Posts: 196

Re: Improved e4rat-preload

You'll have to change this line:
#define LIST "/var/lib/e4rat/startup.log"

You can put the executable anywhere you want.

Offline

#7 2011-04-29 23:23:27

Haptic
Member
Registered: 2009-09-03
Posts: 149

Re: Improved e4rat-preload

Ty, that worked. Shaved an additional second off of my boot!

I guess there is somewhere that you can declare where the executable is. e4rat said it couldn't find it /usr/sbin.

Offline

#8 2011-04-29 23:52:07

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,444
Website

Re: Improved e4rat-preload

Maybe submit your code to the author for improvement of the project?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#9 2011-04-30 00:58:09

jlindgren
Member
Registered: 2011-02-27
Posts: 196

Re: Improved e4rat-preload

Haptic wrote:

I guess there is somewhere that you can declare where the executable is. e4rat said it couldn't find it /usr/sbin.

I guess I'm not sure what you mean.  Why should e4rat (and which part) want to know where the executable is?

Offline

#10 2011-04-30 00:58:41

jlindgren
Member
Registered: 2011-02-27
Posts: 196

Re: Improved e4rat-preload

graysky wrote:

Maybe submit your code to the author for improvement of the project?

I may do that.

EDIT: Done.

Last edited by jlindgren (2011-04-30 02:01:43)

Offline

#11 2011-05-04 13:17:33

barbrady
Member
Registered: 2011-05-04
Posts: 1

Re: Improved e4rat-preload

Great!! I installed e4rat today and I tried your improved e4rat-preload on Core 2 Duo E4500, western digital green HDD, arch 64 and KDE 4.6. I measured time "manually" since I press OS selection from grub2 to KDE welcome sound.

Without e4rat-preload: 26s
With existing e4rat-preload: 21s
With replacement e4rat-preload: 19s
Windows 7: 55s

Has somebody tried e4rat + systemd? it improves a lot vs e4rat + normal sysinit?

Offline

#12 2011-12-05 15:43:49

sploit
Member
Registered: 2011-11-26
Posts: 10

Re: Improved e4rat-preload

jlindgren wrote:
graysky wrote:

Maybe submit your code to the author for improvement of the project?

I may do that.

EDIT: Done.

Anyone can tell if this code has already been implemented by the e4rat dev(s)?

Offline

#13 2011-12-06 08:51:25

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: Improved e4rat-preload

Not until we get an e4rat update from the AUR.


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

#14 2011-12-06 09:20:48

graysky
Member
From: /run/user/1000
Registered: 2008-12-01
Posts: 8,444
Website

Re: Improved e4rat-preload

toad - e4rat has been taken into [community] a while ago...


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#15 2011-12-06 10:14:17

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

Hi everyone,

is e4rat-lite still usable? Or is this obsolete now?

Offline

#16 2011-12-06 10:17:33

sploit
Member
Registered: 2011-11-26
Posts: 10

Re: Improved e4rat-preload

Thorsten Reinbold wrote:

Hi everyone,

is e4rat-lite still usable? Or is this obsolete now?

Yup, and I took to effort to add it to AUR:

https://aur.archlinux.org/packages.php?ID=54631

Last edited by sploit (2011-12-06 10:17:50)

Offline

#17 2011-12-06 10:23:25

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

Wow, this was fast. smile

Off-topic: I'm getting some error-messages and I forgot the command to run a terminal-program in english (my system has german locale setting). What command do I have to use?

Offline

#18 2011-12-06 10:32:14

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

I've tested your package from AUR, but it doesn't work for me. I'm using e4rat with systemd, but it seems as if e4rat-preload-lite isn't using the configs from e4rat, so it runs initd and I'm landing in an single user enviroment.

Offline

#19 2011-12-06 10:38:23

sploit
Member
Registered: 2011-11-26
Posts: 10

Re: Improved e4rat-preload

Thorsten Reinbold wrote:

I've tested your package from AUR, but it doesn't work for me. I'm using e4rat with systemd, but it seems as if e4rat-preload-lite isn't using the configs from e4rat, so it runs initd and I'm landing in an single user enviroment.

Did you change the config's location from the default?

Either link it or place it back in the right location.

Default location:
/var/lib/e4rat/startup.log

So you might want to place a link over there...

Last edited by sploit (2011-12-06 10:40:46)

Offline

#20 2011-12-06 10:40:37

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

Sorry, got it now. wink Runs perfect!

Many thanks for this.

sploit wrote:
Thorsten Reinbold wrote:

I've tested your package from AUR, but it doesn't work for me. I'm using e4rat with systemd, but it seems as if e4rat-preload-lite isn't using the configs from e4rat, so it runs initd and I'm landing in an single user enviroment.

Did you change the config's location from the default?

Either link it or place it back in the right location.

Default location:
/var/lib/e4rat/startup.log

So you might want to place a link over there...

No, this wasn't the reason. I just downloaded the source with "makepkg --nobuild", changed the line "#define INIT" in e4rat-preload-lite.c to "/bin/systemd" an compiled it with "makepkg -e --skipchecksums --skipinteg". That did the trick for me.

Last edited by Thorsten Reinbold (2011-12-06 10:43:36)

Offline

#21 2011-12-06 10:41:26

sploit
Member
Registered: 2011-11-26
Posts: 10

Re: Improved e4rat-preload

Thorsten Reinbold wrote:

Sorry, got it now. wink Runs perfect!

Many thanks for this.

That was faster than I could reply smile


You're welcome!

cheers

Offline

#22 2011-12-06 10:46:40

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

Have a look at my edit in the posting above. I guess that e4rat-preload-lite is not recognizing e4rats config file, so I've had to make those changes in the source. Maybe there is room for improvements.

Offline

#23 2011-12-06 10:57:06

sploit
Member
Registered: 2011-11-26
Posts: 10

Re: Improved e4rat-preload

If you can write a script that checks if the user uses systemd or regular init, i'll happily add it. (I'm not running systemd, so it's hard to test)

Offline

#24 2011-12-06 11:03:26

Thorsten Reinbold
Member
From: Germany
Registered: 2011-12-06
Posts: 314

Re: Improved e4rat-preload

Sorry, but I'm not that good. I'm still a humble follower. wink

But as mentioned above: what about to make e4rat-preload-lite look at the main config from e4rat? That would be the best solution (I think), as everyone with systemd will change the setting at this place.


Edit: in the meantime it would be a good Idea to post this information (changing "#define INIT") on the AUR page.

Last edited by Thorsten Reinbold (2011-12-06 11:05:09)

Offline

#25 2011-12-06 11:04:39

toad
Member
From: if only I knew
Registered: 2008-12-22
Posts: 1,775
Website

Re: Improved e4rat-preload

graysky wrote:

toad - e4rat has been taken into [community] a while ago...

Wow! Never noticed smile


EDIT:
Time to update the wiki methinks. However, I haven't used my laptop in a while so I'd rather not do it (yet). Prefer if somebody does it who knows what they are talking about.

Last edited by toad (2011-12-06 11:06:34)


never trust a toad...
::Grateful ArchDonor::
::Grateful Wikipedia Donor::

Offline

Board footer

Powered by FluxBB