Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve object storage cache #2522

Conversation

killme2008
Copy link
Contributor

@killme2008 killme2008 commented Sep 29, 2023

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Improve object storage local cache:

  • Replace the lru crate with moka for memory cache management.
  • Modify the cache capacity unit from the number of entries to the size in bytes on the disk. The default capacity is 256 Mib.
  • Implement the async_eviction_listener in moka to remove the evicted files.
  • Invalidate both the memory and disk cache when deleting or writing files.
  • Add gauges metric for the cache.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

Partial work of #2516

@killme2008 killme2008 marked this pull request as ready for review September 29, 2023 17:07
@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Merging #2522 (30349a2) into develop (e3d3332) will decrease coverage by 0.28%.
Report is 8 commits behind head on develop.
The diff coverage is 82.48%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2522      +/-   ##
===========================================
- Coverage    85.27%   84.99%   -0.28%     
===========================================
  Files          729      732       +3     
  Lines       115960   116814     +854     
===========================================
+ Hits         98887    99291     +404     
- Misses       17073    17523     +450     

src/datanode/src/config.rs Show resolved Hide resolved
src/object-store/src/metrics.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
src/object-store/Cargo.toml Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
@killme2008
Copy link
Contributor Author

@evenyag @waynexia PTAL

@killme2008 killme2008 requested review from waynexia and evenyag October 7, 2023 09:22
src/datanode/src/config.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache.rs Outdated Show resolved Hide resolved
src/object-store/src/layers/lru_cache/read_cache.rs Outdated Show resolved Hide resolved
@killme2008
Copy link
Contributor Author

@evenyag Applied the suggestions, thank u. PTAL.

@killme2008 killme2008 requested a review from evenyag October 8, 2023 02:41
src/object-store/src/layers/lru_cache.rs Outdated Show resolved Hide resolved
@killme2008 killme2008 force-pushed the feature/object-store-cache-improvements branch from c7a5f33 to 30349a2 Compare October 8, 2023 03:16
@killme2008 killme2008 enabled auto-merge October 8, 2023 03:17
@killme2008 killme2008 added this pull request to the merge queue Oct 8, 2023
Merged via the queue into GreptimeTeam:develop with commit ff15bc4 Oct 8, 2023
19 checks passed
@killme2008 killme2008 deleted the feature/object-store-cache-improvements branch October 8, 2023 03:43
paomian pushed a commit to paomian/greptimedb that referenced this pull request Oct 19, 2023
* feat: refactor object storage cache with moka

* chore: minor fixes

* fix: concurrent issues and invalidate cache after write/delete

* chore: minor changes

* fix: cargo lock

* refactor: rename

* chore: change DEFAULT_OBJECT_STORE_CACHE_SIZE to 256Mib

* fix: typo

* chore: style

* fix: toml format

* chore: toml

* fix: toml format

* Update src/object-store/src/layers/lru_cache/read_cache.rs

Co-authored-by: Ruihang Xia <[email protected]>

* chore: update Cargo.toml

Co-authored-by: Yingwen <[email protected]>

* chore: update src/object-store/Cargo.toml

Co-authored-by: Yingwen <[email protected]>

* chore: refactor and apply suggestions

* fix: typo

* feat: adds back allow list for caching

* chore: cr suggestion

Co-authored-by: Yingwen <[email protected]>

* chore: cr suggestion

Co-authored-by: Yingwen <[email protected]>

* refactor: wrap inner Accessor with Arc

* chore: remove run_pending_task in read and write path

* chore: the arc is unnecessary

---------

Co-authored-by: Ruihang Xia <[email protected]>
Co-authored-by: Yingwen <[email protected]>
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.

4 participants