top: just a small tweak to that history hash algorithm

This patch just raises the size of the hash table used
to calculate elapsed task stuff. The net result should
be less need for 'chaining' under pid hash collisions.

[ the hash scheme is intentionally kept as primitive ]
[ and, therefore, as fast as possible. it employs an ]
[ 'and' approach versus a 'mod' operation since both ]
[ yield similar distribution but the former approach ]
[ was 4 fewer cpu instructions in terms of overhead. ]

[ additionally, for hash collisions, 'chaining' uses ]
[ an array index rather than the usual pointer since ]
[ the HST_t guys may move when they are reallocated. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-10-01 00:00:00 -05:00 committed by Craig Small
parent 3e1c00d051
commit d10c8fccc9

View File

@ -190,7 +190,7 @@ static int HHist_siz; // max number of HST_t structs
static HST_t *PHist_sav, // alternating 'old/new' HST_t anchors
*PHist_new;
#ifndef OFF_HST_HASH
#define HHASH_SIZ 1024
#define HHASH_SIZ 4096
static int HHash_one [HHASH_SIZ], // actual hash tables ( hereafter known
HHash_two [HHASH_SIZ], // as PHash_sav/PHash_new )
HHash_nul [HHASH_SIZ]; // 'empty' hash table image