Get dedup hash table stats; reduce slots to 32.

This commit is contained in:
Dianne Skoll
2024-11-12 21:56:27 -05:00
parent 52fc89ddc7
commit 342c229a57
4 changed files with 39 additions and 8 deletions

View File

@@ -17,7 +17,7 @@
#include <stdlib.h>
#include <string.h>
#define DEDUPE_HASH_SLOTS 64
#define DEDUPE_HASH_SLOTS 32
typedef struct dedupe_entry {
struct dedupe_entry *next;
int trigger_date;
@@ -173,3 +173,27 @@ InitDedupeTable(void)
DedupeTable[i] = NULL;
}
}
void
get_dedupe_hash_stats(int *total, int *maxlen, double *avglen)
{
int len;
int i;
DedupeEntry *e;
*maxlen = 0;
*total = 0;
for (i=0; i<DEDUPE_HASH_SLOTS; i++) {
len = 0;
e = DedupeTable[i];
while (e) {
len++;
(*total)++;
e = e->next;
}
if (len > *maxlen) {
*maxlen = len;
}
}
*avglen = (double) *total / (double) DEDUPE_HASH_SLOTS;
}

View File

@@ -66,9 +66,11 @@ exitfunc(void)
fflush(stdout);
fflush(stderr);
get_var_hash_stats(&total, &maxlen, &avglen);
fprintf(stderr, " Var hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
fprintf(stderr, " Var hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
get_userfunc_hash_stats(&total, &maxlen, &avglen);
fprintf(stderr, "Func hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
fprintf(stderr, " Func hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
get_dedupe_hash_stats(&total, &maxlen, &avglen);
fprintf(stderr, "Dedup hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
UnsetAllUserFuncs();
print_expr_nodes_stats();
}
@@ -158,6 +160,7 @@ int main(int argc, char *argv[])
ShouldCache = (Iterations > 1);
while (Iterations--) {
PerIterationInit();
DoReminders();
if (DebugFlag & DB_DUMP_VARS) {
@@ -197,7 +200,6 @@ int main(int argc, char *argv[])
}
}
if (Iterations) {
PerIterationInit();
DSEToday++;
}
}

View File

@@ -247,8 +247,11 @@ extern int _private_sub_overflow(int a, int b);
void print_sysvar_tokens(void);
void print_builtinfunc_tokens(void);
void print_remind_tokens(void);
/* Stats for -ds output */
void get_var_hash_stats(int *total, int *maxlen, double *avglen);
void get_userfunc_hash_stats(int *total, int *maxlen, double *avglen);
void get_dedupe_hash_stats(int *total, int *maxlen, double *avglen);
/* Dedupe code */
int ShouldDedupe(int trigger_date, int trigger_time, char const *body);

View File

@@ -5837,8 +5837,9 @@ Barf
DEBUG +s
# Don't want Remind to queue reminders
EXIT
Var hash: total = 141; maxlen = 4; avglen = 2.104
Func hash: total = 15; maxlen = 2; avglen = 0.484
Var hash: total = 141; maxlen = 4; avglen = 2.104
Func hash: total = 15; maxlen = 2; avglen = 0.484
Dedup hash: total = 0; maxlen = 0; avglen = 0.000
Expression nodes allocated: 128
Expression nodes high-water: 73
Expression nodes leaked: 0
@@ -13290,8 +13291,9 @@ Parsed expression: isany("foo", 1 + 1, 2:00 + 1, '2021-01-01' + 1, '2021-01-01@1
"f" + "oo" => "foo"
isany("foo", 2, 02:01, 2021-01-02, 2021-01-01@14:01, "foo", ?) => 1
No reminders.
Var hash: total = 1; maxlen = 1; avglen = 0.015
Func hash: total = 0; maxlen = 0; avglen = 0.000
Var hash: total = 1; maxlen = 1; avglen = 0.015
Func hash: total = 0; maxlen = 0; avglen = 0.000
Dedup hash: total = 0; maxlen = 0; avglen = 0.000
Expression nodes allocated: 512
Expression nodes high-water: 499
Expression nodes leaked: 0