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

[Refactor] Remove charge_mode from LRUCache #55911

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

trueeyu
Copy link
Contributor

@trueeyu trueeyu commented Feb 14, 2025

Why I'm doing:

charge_size is the actual memory size occupied by an element, while value_size is the size of the element. For the underlying cache, it only needs to know charge_size for memory accounting purposes. As for the passed-in Item, if it needs to rely on the value_size for decoding, then ensuring that the data structure is self-descriptive.

The interface of DataCache only have one param charge_size, so In order to unify PageCache and DataCache, the charge mode of LRUCache will be removed.

What I'm doing:

Remove charge_mode from LRUCache

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@trueeyu trueeyu requested review from a team as code owners February 14, 2025 07:13
void (*deleter)(const CacheKey& key, void* value), CachePriority priority,
size_t value_size) {
Cache::Handle* LRUCache::insert(const CacheKey& key, uint32_t hash, void* value, size_t value_size, size_t charge,
void (*deleter)(const CacheKey& key, void* value), CachePriority priority) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the value is self-descriptive, how about removing the value_size in the lru_cache because it is really unnecessary for a underly cache? It can reduce memory if value_size=charge in many cases. If value_size!=size, the caller can get the value size from the pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Removing it can save metadata memory. However, we won't change it in this PR. The purpose of this PR is to enable PageCache to use the StarCache interface.

@trueeyu
Copy link
Contributor Author

trueeyu commented Feb 14, 2025

@Mergifyio rebase main

Signed-off-by: trueeyu <[email protected]>
Signed-off-by: trueeyu <[email protected]>
Signed-off-by: trueeyu <[email protected]>
Copy link
Contributor

mergify bot commented Feb 14, 2025

rebase main

✅ Branch has been successfully rebased

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[FE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

pass : 25 / 25 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/util/lru_cache.cpp 7 7 100.00% []
🔵 be/src/storage/page_cache.cpp 3 3 100.00% []
🔵 be/src/storage/lake/metacache.cpp 1 1 100.00% []
🔵 be/src/service/staros_worker.cpp 1 1 100.00% []
🔵 be/src/storage/page_cache.h 1 1 100.00% []
🔵 be/src/exprs/jit/jit_engine.cpp 6 6 100.00% []
🔵 be/src/exec/query_cache/cache_manager.cpp 2 2 100.00% []
🔵 be/src/fs/fd_cache.cpp 1 1 100.00% []
🔵 be/src/storage/sstable/table.cpp 2 2 100.00% []
🔵 be/src/storage/rowset/metadata_cache.cpp 1 1 100.00% []

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.

3 participants