From 9eb930eebba24045d4e16bfa7b248464e7bd8f1d Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 1 Oct 2020 00:00:00 -0500 Subject: [PATCH] library: tweak that history hash algorithm, api 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 --- proc/pids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proc/pids.c b/proc/pids.c index 9be91a3a..cd3d9618 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -553,7 +553,7 @@ enum pids_item PIDS_logical_end = MAXTABLE(Item_table); // ___ History Support Private Functions |||||||||||||||||||||||||||||||||||||| // ( stolen from top when he wasn't looking ) ------------------------------- -#define HHASH_SIZE 1024 +#define HHASH_SIZE 4096 #define _HASH_PID_(K) (K & (HHASH_SIZE - 1)) #define Hr(x) info->hist->x // 'hist ref', minimize stolen impact