perf(pruning): cache S3 directory listings by parent to reduce API calls#150
Merged
xe-nvdk merged 1 commit intoBasekick-Labs:mainfrom Jan 23, 2026
Merged
Conversation
Previously, each hour directory was checked individually with a separate ListDirectories call, resulting in ~750 S3 API calls for a 30-day query. Now we cache by parent directory (day level), so all hours within the same day share a single ListDirectories result. Results when querying last 30 days: - S3 API calls: 752 → 33 (23x reduction) - Pruning time: ~38s → ~3s (12x faster)
Member
|
Hey @khalid244, thank you for the PR. I will review this PR. |
xe-nvdk
approved these changes
Jan 23, 2026
Member
xe-nvdk
left a comment
There was a problem hiding this comment.
Code Review: ✅ Approved
Excellent performance optimization! Thoroughly analyzed the implementation.
What this PR does
Caches S3 ListDirectories results at the parent (day) level instead of checking each hour directory individually. For a 30-day query:
- S3 API calls: 752 → 33 (23x reduction)
- Pruning time: ~38s → ~3s (12x faster)
Code Quality Assessment
| Aspect | Status |
|---|---|
| Correctness | ✅ Logic is sound |
| Error handling | ✅ Safe fallback (assumes dir exists on error) |
| Cache key design | ✅ Clean namespace (remote:parent:) |
| Thread safety | ✅ Uses existing mutex-protected globCache |
| Tests | ✅ All 28 pruning tests pass |
Minor observations (not blockers)
- On cache hit, rebuilds child set from slice - acceptable O(24) overhead
- Old cache keys (
remote:) expire naturally via TTL
Cost Impact
For S3-heavy workloads, this reduces LIST API costs significantly (~$0.005/1000 calls).
LGTM - merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Results (30-day query)
Test plan