library: tweak that history hash algorithm, <pids> 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 <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-10-01 00:00:00 -05:00 committed by Craig Small
parent e2b0f8b0af
commit 9eb930eebb

View File

@ -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