bind9/lib
Ondřej Surý 5eec9a2ebb
Change the .inuse member of isc_mem to be per-thread/per-loop
The .inuse member was causing a lot of contention between threads using
the same memory context.  Scather the .inuse and .overmem members of
isc_mem_t structure to be an per-tid array of variables to reduce the
contention as the writes are now independent of each other.

The array uses one tad bit nasty trick, as ISC_TID_UNKNOWN is now -1,
the array has been sized to fit the unknown tid with [-1] index into the
array accomplished with `ctx->stat = &ctx->stat_s[1];`.  It will not win
a beauty contest, but it works seamlessly by just passing `isc_tid()` as
an index into the array.

The caveat here is that gathering the real inuse value requires walking
the whole array for all registered tid values (isc_tid_count()).  The
gather part happens only when statistics are being gathered or when
isc_mem_isovermem() is called.  As the isc_mem_isovermem() call happens
only when new data is being added to cache or ADB, it doesn't happen on
the hottest (read-only) path and according to the measurements, it
doesn't slow down neither the cold cache nor the hot cache latency.
2025-06-30 13:23:17 +02:00
..
dns Convert the isc/tid.h to use own signed integer isc_tid_t type 2025-06-28 13:32:12 +02:00
isc Change the .inuse member of isc_mem to be per-thread/per-loop 2025-06-30 13:23:17 +02:00
isccc replace the build system with meson 2025-06-11 10:30:12 +03:00
isccfg Use clang-format-20 to update formatting 2025-06-25 12:44:22 +10:00
ns Convert the isc/tid.h to use own signed integer isc_tid_t type 2025-06-28 13:32:12 +02:00
.gitignore The isc/platform.h header has been completely removed 2021-07-06 05:33:48 +00:00
meson.build replace the build system with meson 2025-06-11 10:30:12 +03:00