Skip to content

Improve storage layer LRU tracking and simplify code - #1

Merged
ovaistariq merged 4 commits into
mainfrom
refactor/storage-layer-improvements
Jul 18, 2025
Merged

ovaistariq merged 4 commits into
mainfrom
refactor/storage-layer-improvements

Conversation

@ovaistariq

Copy link
Copy Markdown
Contributor

Summary

  • Implement async LRU tracking for Get requests without performance penalty
  • Remove conditional maxDiskUsage check - LRU tracking now always happens
  • Simplify DeleteKey function and ensure s.cleaner is never nil

Changes

1. Async LRU Tracking

  • Added accessUpdater component that processes access time updates asynchronously
  • Uses buffered channel (10k capacity) with batched writes every 100ms
  • Non-blocking, best-effort tracking that maintains Get performance
  • Properly shuts down and flushes pending updates on storage close

2. Always Enable LRU Tracking

  • Removed if s.cleaner.maxDiskUsage > 0 check from putLow
  • LRU tracking now happens for all Put operations regardless of disk usage limits

3. Code Simplification

  • Simplified DeleteKey to use atomic batch operations
  • Removed separate InitStorageForTest function
  • Ensured s.cleaner is never nil throughout codebase
  • Added proper size tracking notifications

Benefits

  • Maintains strict "least recently accessed" LRU behavior
  • No performance penalty on Get operations
  • Cleaner, more maintainable code
  • Better atomicity in delete operations

Test Plan

  • Verify existing tests pass
  • Test async LRU tracking behavior under load
  • Verify no performance regression in Get operations
  • Test proper cleanup on storage shutdown

🤖 Generated with Claude Code

ovaistariq and others added 4 commits July 17, 2025 17:53
- Remove conditional maxDiskUsage check - LRU tracking now always happens
- Implement async LRU tracking for Get requests without performance penalty
  - Added accessUpdater component with buffered channel (10k capacity)
  - Batches updates and flushes to RocksDB every 100ms
  - Non-blocking, best-effort tracking that drops updates if buffer is full
- Simplify DeleteKey function with atomic batch operations
- Remove separate InitStorageForTest function
- Ensure s.cleaner is never nil throughout codebase

These changes maintain strict "least recently accessed" LRU behavior while
ensuring Get performance is not impacted by synchronous RocksDB writes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Only track LRU when maxDiskUsage > 0 (when LRU eviction is actually needed)
- Skip accessUpdater initialization when maxDiskUsage = 0
- Avoid time.Now() calls and access index writes when LRU is disabled
- Add UpdateNow() helper to reduce redundant time.Now() calls

This restores performance to baseline levels when LRU eviction is not needed
while still maintaining strict LRU behavior when maxDiskUsage is configured.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Created e2e/ directory for end-to-end integration tests
- Moved demo_ttl_lru.sh to e2e/
- Added README.md documenting the e2e test structure

This provides better organization and separation between unit tests
and end-to-end integration tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…oper e2e test

- Renamed demo_ttl_lru.sh to ttl_lru_test.sh to reflect its purpose as a test
- Updated all references from "Demo" to "Test" throughout the script
- Added proper test verification and exit codes:
  - Verifies TTL cleanup actually removes expired keys
  - Verifies LRU eviction keeps recent keys and evicts old ones
  - Returns exit code 0 on success, 1 on failure
- Updated e2e/README.md to reflect the new script name

The script now functions as a proper automated test that can be used in CI/CD.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@ovaistariq
ovaistariq merged commit 9bc96d4 into main Jul 18, 2025
@ovaistariq
ovaistariq deleted the refactor/storage-layer-improvements branch August 11, 2025 00:06
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants