mirror of
https://github.com/amir20/dozzle.git
synced 2026-06-23 04:10:12 +00:00
a79ffdaf50
Co-authored-by: Dhaval Patel <dhavu262@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
Go Performance Reviewer Memory
Hot Paths Identified
- Stats processing pipeline:
ContainerStatsListener.enrich()-> channel ->Manager.processStatEvents()->processStatEvent(). Runs continuously for every container stat tick (~1/sec per container). - Log processing pipeline:
ContainerLogListener->logChannel(buffered 1000) ->Manager.processLogEvents()->processLogEvent(). Every log line from matched containers flows here. - Both pipelines do
expr.Run()per subscription per event -- compiled programs are cached but still run per-event.
Architecture Notes
ContainerStore.SubscribeStatsandSubscribeEventsboth callstatsCollector.Start/Stop-- multiple subscribers share the same collector. Stop-on-cancel can interfere across subscribers.xsync.Map(from puzpuzpuz/xsync/v4) used extensively for concurrent maps. No built-in TTL/eviction.ContainerStatEventcarries fullContainer+Hoststructs by value through channels.Containeris ~200+ bytes (strings, map, RingBuffer pointer, times).- TTL caches in both listeners (
cachedContainerInfo) lack eviction -- grow unboundedly with container churn.
Existing Patterns
- Semaphore-based concurrency limiting:
sendSem(weighted 5) for notification dispatch,maxFetchParallelism(30) for container fetching. - Lazy stats collection: stats collector starts on first subscriber, stops when last unsubscribes (but the multi-subscriber Stop race exists).
sync.Poolnot currently used in notification/stats paths.- Cooldown tracking via
xsync.Map[string, time.Time]per subscription -- also no eviction.
Key File Paths
internal/container/container_store.go-- Container store with stats collector lifecycleinternal/notification/processing.go-- Log + stat event processing (hot path)internal/notification/stats_listener.go-- Stats subscription and enrichmentinternal/notification/log_listener.go-- Log stream managementinternal/notification/manager.go-- Subscription CRUD and listener orchestrationinternal/notification/types.go-- Subscription matching (expr evaluation)