chroma
chroma copied to clipboard
[ENH] Add log cache
Description of changes
Summarize the changes made by this PR.
- Improvements & Bug fixes
- ...
- New functionality
- This PR adds a cache for the log to reduce the latency of the brute force operator.
- It utilizes foyer (https://github.com/MrCroxx/foyer) as the cache library. Foyer provides in memory as well as hybrid cache which allows us to apply it as block cache.
- The key for the cache entry is collection_id + start_offset, and the value is Arc<[LogRecord]>. To call out, the cache is not yet aligned on a batch boundary. We may want to make the cache key align on the batch boundary to reduce unnecessary caching.
- Cache invalidation is not yet implemented and will be added as a follow up PR based on collection version and log position for the latest compaction.
Test plan
How are these changes tested?
- [x] Tests pass locally with
pytestfor python,yarn testfor js,cargo testfor rust
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?
Reviewer Checklist
Please leverage this checklist to ensure your code review is thorough before approving
Testing, Bugs, Errors, Logs, Documentation
- [ ] Can you think of any use case in which the code does not behave as intended? Have they been tested?
- [ ] Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
- [ ] If appropriate, are there adequate property based tests?
- [ ] If appropriate, are there adequate unit tests?
- [ ] Should any logging, debugging, tracing information be added or removed?
- [ ] Are error messages user-friendly?
- [ ] Have all documentation changes needed been made?
- [ ] Have all non-obvious changes been commented?
System Compatibility
- [ ] Are there any potential impacts on other parts of the system or backward compatibility?
- [ ] Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?
Quality
- [ ] Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)
@MrCroxx Thank you for making Foyer compatible with Rust stable. This PR uses Foyer's memory cache to cache the log records reading from databases in batches. It would be great to have you take a look and offer some insights on the PR.
Hi, @Ishiihara . Thanks to invite me to review this PR. I'll finish it in 2-3 days.
I noticed you introduced both foyer and foyer-memory. IMO, with the latest version (0.8.6), foyer is enouth for most usecases. Is there something that cannot be achieved? Please tell me and I'll export it if necessary.
Hi @Ishiihara , you can run cargo update -p foyer-memory -p foyer-storage -p foyer to upgrade foyer and resolve the comments.