🧹 chore: avoid locking in gc() if nothing to delete#3765
🧹 chore: avoid locking in gc() if nothing to delete#3765gaby merged 1 commit intogofiber:mainfrom arturmelanchyk:storage
Conversation
WalkthroughThe gc routine in internal/memory/memory.go adds an early continue when no expired entries are found, skipping acquisition of the write lock. Control flow is adjusted only within the garbage collection path. No exported APIs or error handling are changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as Ticker/Timer
participant M as MemoryStore
participant R as RWMutex
T->>M: Trigger gc()
M->>M: Scan for expired entries
alt Expired entries found
M->>R: Acquire write lock
M->>M: Delete expired keys
M-->>R: Release write lock
else No expired entries
note right of M: New behavior: continue early\n(no write lock)
end
M-->>T: GC cycle completes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3765 +/- ##
=======================================
Coverage 91.42% 91.42%
=======================================
Files 113 113
Lines 11874 11874
=======================================
Hits 10856 10856
Misses 750 750
Partials 268 268
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Avoid unneeded locking in gc()
Changes introduced
List the new features or adjustments introduced in this pull request. Provide details on benchmarks, documentation updates, changelog entries, and if applicable, the migration guide.
Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/directory for Fiber's documentation.Commit formatting
Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md