From: Jim Warner Date: Thu, 1 Oct 2020 05:00:00 +0000 (-0500) Subject: library: tweak that history hash algorithm, api X-Git-Tag: v4.0.0~302 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9eb930eebba24045d4e16bfa7b248464e7bd8f1d;p=procps-ng 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 --- 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