Skip to content

Conversation

@ljluestc
Copy link

@ljluestc ljluestc commented Jun 8, 2025

Add Stress Test and Config Optimizations for Cleanup Blocking (#259)

This PR addresses #259, which questions if BigCache's cleanup process blocks workflow under heavy load and requests a code fix and test.

Changes

  • Stress Test: Added stress_test.go to simulate heavy load (50 goroutines, 10k ops each) to test cleanup behavior under high-throughput conditions.
  • Config Tuning:
    • Shards: 1024 to reduce lock contention.
    • CleanWindow: 1s for frequent cleanup.
    • HardMaxCacheSize: 512MB to cap memory.
    • LifeWindow: 10m for timely expiration.
  • Manual GC: Added periodic runtime.GC() (every 1m) to reclaim memory.
  • Monitoring: Added MemStats logging to track memory usage.

How It Addresses #259

  • stress_test.go replicates heavy load with key overwrites, verifying cleanup doesn’t block Set/Get operations.
  • Tuned config minimizes contention and ensures frequent cleanup.
  • GC calls prevent memory growth from lazy eviction.

@cristaloleg
Copy link
Collaborator

Why so many unrelated changes? AI ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants