Configure.help speedup(no 'sed', builds byte index)

Adam Heath (adam@brainiac.egr.msu.edu)
Wed, 28 Jan 1998 00:34:09 -0500 (EST)


I have written a C program that parses the Configure.help file, and builds
and index to speed up access.

Here is a test, using the old way(sed), and the new way.

root@adam $time sed -n "/^$var[ ]*\$/,\${
/^$var[ ]*\$/d
/^#.*/d
/^[ ]*\$/q
s/^ //
p
}" Documentation/Configure.help;time scripts/help
extract $var
#--- This is the output of sed.
Say Y if you have such a thing. This driver is also available as a
module called pms.o ( = code which can be inserted in and removed
from the running kernel whenever you want). If you want to compile
it as a module, say M here and read Documentation/modules.txt.

#--- This is the time info for sed.
real 0m0.172s
user 0m0.170s
sys 0m0.000s
#--- Debuggin info from scripts/help, won't exist in final.
adding file(Documentation/Configure.help) to index.
adding dir(Documentation/config) to index.
adding file(Documentation/config/test2) to index.
adding file(Documentation/config/test) to index.
#--- Message text. I haven't found a way to strip the spaces on the
#--- right.
Say Y if you have such a thing. This driver is also available as a
module called pms.o ( = code which can be inserted in and removed
from the running kernel whenever you want). If you want to compile
it as a module, say M here and read Documentation/modules.txt.

#--- Time info for scripts.help. This includes the time to build the
#--- index(it didn't exist, so it was autocreated), and the time to
#--- extract the help.
real 0m0.060s
user 0m0.040s
sys 0m0.020s

These times are on a P166MMX(375.19),with var=CONFIG_VIDEO_PMS, the last
one in the file(for 2.1.82). As you can see, even on my fast system, the
program is much faster. I have patched oldconfig, config, xconfig, and
menuconfig to all call the external program.

I am not releasing a patch right now, as I want to clean up the code and
add some help, error handling. Also, the program not only reads in
Documentation/Configure.help, but any separate files that happen to be in
Documentation/config/.

What follows is a technical discussion of how I did it. I am wondering if
it would work on other platforms. Anyone care to comment?

---
When building the index, I used mmap on the input help files.  I treat the
memory segment as a string, and use strstr to do my searching.  As I find
each CONFIG_* line, I change the ending char to '\0' temporarily, to make
processing easier.

When extracting the help, I mmap the index, find the CONFIG_* var, and then mmap the file that the help text is in.

My main concern is how mmap will work on other platforms. The index file is a simple format: "<varname> <helpfile> <start> <end>", with everything stored as a string. Does anyone see anyone problems with this approach?