linux/scripts/kconfig
Andi Kleen e66f25d7d1 Improve kconfig symbol hashing
While looking for something else I noticed that the symbol
hash function used by kconfig is quite poor. It doesn't
use any of the standard hash techniques but simply
adds up the string and then uses power of two masking,
which is both known to perform poorly.

The current x86 kconfig has over 7000 symbols.

When I instrumented it showed that the minimum hash chain
length was 16 and a significant number of them was over
30.

It didn't help that the hash table size was only 256 buckets.

This patch increases the hash table size to a larger prime
and switches to a FNV32 hash. I played around with a couple of hash
functions, but that one seemed to perform best with reasonable
hash table sizes.

Increasing the hash table size even further didn't
seem like a good idea, because there are a couple of global
walks which walk the complete hash table.

I also moved the unnamed bucket to 0. It's still the longest
of all the buckets (44 entries), but hopefully it's not
often hit except for the global walk which doesn't care.

The result is a much nicer distribution:
(first column bucket length, second number of buckets with that length)

1: 3505
2: 1236
3: 294
4: 52
5: 3
47: 1		<--- this is the unnamed symbols bucket

There are still some 5+ buckets, but increasing the hash table
even more would be likely not worth it.

This also cleans up the code slightly by removing hard coded
magic numbers.

I didn't notice a big performance difference either way
on my Nehalem system, but I presume it'll help somewhat
on slower systems.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
2010-02-02 14:33:55 +01:00
..
lxdialog kconfig: variable argument lists needs `stdarg.h' 2009-07-17 23:05:05 +02:00
.gitignore gitignore: ignore Kconfig i18n files 2009-06-09 22:37:47 +02:00
check.sh kbuild: check if we can link gettext not just compile 2007-10-12 21:13:50 +02:00
conf.c kbuild: add static to prototypes 2009-09-20 12:27:44 +02:00
confdata.c kbuild: generate modules.builtin 2009-12-12 13:08:16 +01:00
expr.c menuconfig: wrap long help lines 2010-02-02 14:33:55 +01:00
expr.h Improve kconfig symbol hashing 2010-02-02 14:33:55 +01:00
gconf.c kconfig: make use of menu_get_ext_help in gconfig 2009-09-20 12:27:42 +02:00
gconf.glade gconfig: disable "typeahead find" search in treeviews 2009-09-20 12:27:43 +02:00
images.c
kconfig_load.c
kxgettext.c kbuild: add static to prototypes 2009-09-20 12:27:44 +02:00
lex.zconf.c_shipped kconfig: Mark various internal functions static 2009-11-15 15:00:16 -08:00
lkc_proto.h kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
lkc.h kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
Makefile kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
mconf.c kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
menu.c kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
nconf.c nconfig: minor fix 2010-02-02 14:33:55 +01:00
nconf.gui.c nconfig: mark local functions as such 2010-02-02 14:33:55 +01:00
nconf.h kconfig: new configuration interface (nconfig) 2010-02-02 14:33:55 +01:00
POTFILES.in kconfig: gettext support for lxdialog 2008-01-28 23:14:39 +01:00
qconf.cc kconfig: make use of menu_get_ext_help in qconfig 2009-09-20 12:27:41 +02:00
qconf.h kconfig/xconfig: sync main view with search dialog current menu 2007-05-02 20:58:08 +02:00
streamline_config.pl kconfig: Fix make O=<dir> local{mod,yes}config 2009-11-20 09:45:55 -05:00
symbol.c Improve kconfig symbol hashing 2010-02-02 14:33:55 +01:00
util.c menuconfig: wrap long help lines 2010-02-02 14:33:55 +01:00
zconf.gperf kconfig: Mark various internal functions static 2009-11-15 15:00:16 -08:00
zconf.hash.c_shipped kconfig: Mark various internal functions static 2009-11-15 15:00:16 -08:00
zconf.l kconfig: Mark various internal functions static 2009-11-15 15:00:16 -08:00
zconf.tab.c_shipped Improve kconfig symbol hashing 2010-02-02 14:33:55 +01:00
zconf.y Improve kconfig symbol hashing 2010-02-02 14:33:55 +01:00