From d10c8fccc9f81dd41f89c99facbabca67f8bede8 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 1 Oct 2020 00:00:00 -0500 Subject: [PATCH] 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 --- top/top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index 2afe648d..75ffe60b 100644 --- a/top/top.c +++ b/top/top.c @@ -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