[PATCH 3/3] parse_config: use getline to read config

Timo Teräs timo.teras at iki.fi
Sun Jun 19 19:26:40 UTC 2011


On 06/19/2011 02:08 PM, Denys Vlasenko wrote:
> I just tested it again on Fedora 15, which has bigger modules.dep.
> (My machine's modules.dep is 41k, F15's is 224k).
> 
> On both machines speedup is not so big. Hash seems to help more then getline:
> on F15, it reduced run time from 19 to 16 seconds, while getline won
> ~0.5 sec only.
> 
> Don't take me wrong, I'm not saying the patches are not good.
> I am saying we need to figure out how much *each* patch speeds up
> modprobe, and in what conditions (IOW: why you see big speedup,
> and I see small one), so that we can document it in comments
> and save some head scratching for future hackers.
> 
> Let's take a more detailed look.
> 
> How big is your modules.dep (bytes and lines)?
> 
> Can you send me your .config?

For busybox, I have make allyesconfig, except FORCE_MMU disabled, and
"disable optimizations" was disabled so I got -O2. Some other minor
things that caused compile problems.

Kernel is standard Ubuntu -generic.

> Can you send me timing results and bloatcheck for both patches?
> 
> How much speedup you get if you use getc_unlocked instead of getline
> (see attached patch)?

Your patch doesn't work. You probably meant #ifdef *_unlocked. But that
doesn't work either as those are functions, not #defines. I did try just
one line change in parse_config.c changing getch to _unlocked.

Results are for 100 iterations of modprobing non-existing module (which
is good test since then it parses the full modules.dep).

baseline busybox

real    0m5.449s
user    0m4.956s
sys     0m0.200s

hashing, +60 bytes

real    0m3.949s
user    0m3.520s
sys     0m0.208s

getline, +80 bytes

real    0m3.397s
user    0m2.992s
sys     0m0.236s

hashing + getline, +145 bytes (to baseline, apparently the extra 5 bytes
come from alignment changes causing need of extra padding bytes)

real    0m2.050s
user    0m1.636s
sys     0m0.184s

unlocked getch change only, +-0

real    0m4.231s
user    0m3.832s
sys     0m0.200s

---

As suggested by Rich, unlocked is a speed up, but not as major as
getline. And both, hashing and getline give a considerable speed up here.

Tests run on moderate laptop (Core2 Duo T7300, 2*4000 bogomips), running
Linux Mint (= glibc). Against standard kernel modules.dep which is 300kB
or 3075 lines. getline speed-up on uclibc is not probably as large,
since uclibc getline is lame and needs performance optimization as
noticed before. Actually, same applies to also fgets/gets in uclibc. All
the line readers suck there as they use getc_unlocked() loop instead of
doing memchr on the buffer.

Thinking also more, if using fgets instead of getline, the resulting
code might be slightly smaller in size. As the getline implementation
needs two line buffers for the continuation handling.

- Timo


More information about the busybox mailing list