From 8f520e52d7d4081a0835374c7a448116baac64ab Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 20:39:26 +0100 Subject: Turn the bucket count into a knob, but keep cleaner wake-ups at a constant rate --- ot_clean.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ot_clean.h') diff --git a/ot_clean.h b/ot_clean.h index e069ee0..0592791 100644 --- a/ot_clean.h +++ b/ot_clean.h @@ -9,8 +9,17 @@ /* The amount of time a clean cycle should take */ #define OT_CLEAN_INTERVAL_MINUTES 2 -/* So after each bucket wait 1 / OT_BUCKET_COUNT intervals */ -#define OT_CLEAN_SLEEP (((OT_CLEAN_INTERVAL_MINUTES) * 60 * 1000000) / (OT_BUCKET_COUNT)) +/* How often the cleaner may wake. A full sweep takes OT_CLEAN_INTERVAL_MINUTES. + The clean operations per wake is goverend by OT_BUCKET_COUNT_BITS, + set by the Makefile. + At the default of 1024 buckets this works out at one bucket every + 117 ms. */ +#define OT_CLEAN_MAX_WAKES_PER_SECOND 10 + +#define OT_CLEAN_WAKE_BUDGET ((OT_CLEAN_INTERVAL_MINUTES) * 60 * (OT_CLEAN_MAX_WAKES_PER_SECOND)) +#define OT_CLEAN_BUCKETS_PER_WAKE (((OT_BUCKET_COUNT) + (OT_CLEAN_WAKE_BUDGET) - 1) / (OT_CLEAN_WAKE_BUDGET)) +#define OT_CLEAN_WAKES ((OT_BUCKET_COUNT) / (OT_CLEAN_BUCKETS_PER_WAKE)) +#define OT_CLEAN_SLEEP (((OT_CLEAN_INTERVAL_MINUTES) * 60 * 1000000) / (OT_CLEAN_WAKES)) void clean_init(void); void clean_deinit(void); -- cgit v1.3