performance: remove significant overhead of decaymap (#1420)

I have ~5% base CPU load on an idle server due to mutex 100x per second.

Signed-off-by: Matthias Dötsch <matze@mdoetsch.de>
This commit is contained in:
Matthias Dötsch 2026-01-22 20:03:17 +01:00 committed by GitHub
parent 23ec1b82a7
commit d2bc5cadb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 2 deletions

View file

@ -146,7 +146,7 @@ func (m *Impl[K, V]) Close() {
func (m *Impl[K, V]) cleanupWorker() { func (m *Impl[K, V]) cleanupWorker() {
defer m.wg.Done() defer m.wg.Done()
batch := make([]deleteReq[K], 0, 64) batch := make([]deleteReq[K], 0, 64)
ticker := time.NewTicker(10 * time.Millisecond) ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()
flush := func() { flush := func() {

View file

@ -32,7 +32,7 @@ func TestImpl(t *testing.T) {
// Deletion of expired entries after Get is deferred to a background worker. // Deletion of expired entries after Get is deferred to a background worker.
// Assert it eventually disappears from the map. // Assert it eventually disappears from the map.
deadline := time.Now().Add(200 * time.Millisecond) deadline := time.Now().Add(700 * time.Millisecond)
for time.Now().Before(deadline) { for time.Now().Before(deadline) {
if dm.Len() == 0 { if dm.Len() == 0 {
break break

View file

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add iplist2rule tool that lets admins turn an IP address blocklist into an Anubis ruleset. - Add iplist2rule tool that lets admins turn an IP address blocklist into an Anubis ruleset.
- Add Polish locale ([#1292](https://github.com/TecharoHQ/anubis/pull/1309)) - Add Polish locale ([#1292](https://github.com/TecharoHQ/anubis/pull/1309))
- Fix honeypot and imprint links missing `BASE_PREFIX` when deployed behind a path prefix ([#1402](https://github.com/TecharoHQ/anubis/issues/1402)) - Fix honeypot and imprint links missing `BASE_PREFIX` when deployed behind a path prefix ([#1402](https://github.com/TecharoHQ/anubis/issues/1402))
- Improve idle performance in memory storage
<!-- This changes the project to: --> <!-- This changes the project to: -->