mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 09:59:54 +00:00
Implement Phases 1-3 of the performance optimization plan to address issue #1793 - reduce CPU and memory consumption for system-constrained environments. Phase 1 - OPA Module Caching: - Add compiledModules cache to OPAProcessor with thread-safe access - Cache compiled OPA rules to eliminate redundant compilation - Reuse compiled modules with double-checked locking pattern - Expected CPU savings: 30-40% Phase 2 - Map Pre-sizing: - Add estimateClusterSize() to calculate resource count - Pre-size AllResources, ResourcesResult, and related maps - Reduce memory reallocations and GC pressure - Expected memory savings: 10-20% Phase 3 - Set-based Deduplication: - Add thread-safe StringSet utility in core/pkg/utils - Replace O(n) slices.Contains() with O(1) map operations - Use StringSet for image scanning and related resources deduplication - 100% test coverage for new utility - Expected CPU savings: 5-10% for large clusters Full optimization plan documented in optimization-plan.md Related: #1793 Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
332 KiB
332 KiB