]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Feature] Smart destructor preallocation based on pool type and statistics
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 21 Oct 2025 10:41:50 +0000 (11:41 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 21 Oct 2025 10:41:50 +0000 (11:41 +0100)
commitea2a0e5796718739ded60ecf516a0094d74f5317
tree417596157a21caa7c8744571933f8dc416125948
parent962c4ef589abce40adaf8835a1b9c89bfc3caa98
[Feature] Smart destructor preallocation based on pool type and statistics

Implement intelligent preallocation strategy for destructor heap:

Long-lived pools (LONG_LIVED flag):
- Fixed preallocation: 32 destructor slots
- No statistical tracking needed (pool lives entire process lifetime)
- Covers typical module/configuration destructor counts

Short-lived pools (default):
- Statistics-based preallocation using entry point data
- Track maximum destructors seen per entry point
- Cap at 64 slots to prevent excessive preallocation
- Simplified max-tracking logic (replaces exponential growth)

Benefits:
- Long-lived: predictable memory usage, no reallocation overhead
- Short-lived: adaptive to actual usage patterns
- Reduced heap resizing operations during destructor addition
- Memory bounded (32 for long-lived, max 64 for short-lived)

Statistics updated on pool deletion to inform future allocations
from same entry point.
src/libutil/mem_pool.c