starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[WIP] Support evicting old cache items with a given probability option to avoid frequent cache replacement.

Open GavinMar opened this issue 10 months ago • 2 comments

Why I'm doing:

Sometimes when the datacache quota is smaller than the query io bytes, evict the old cache item and populate a new one may cause too much CPU overhead and a lower cache hit rate.

For example, for a large query that read 500G data, while the cache quota is only 300G. If we always replace the cache data during the query, it may trigger the bad case of LRU policy, which result in a very low cache hit rate.

What I'm doing:

We support an evict probability option to control the probability to replace the old cache items when the cache space is full. In some cases, this can help avoid the hit rate problem caused by frequent cache replacement.

What type of PR is this:

  • [ ] BugFix
  • [x] Feature
  • [ ] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] 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.3
    • [ ] 3.2
    • [ ] 3.1
    • [ ] 3.0
    • [ ] 2.5

GavinMar avatar Apr 26 '24 03:04 GavinMar

[FE Incremental Coverage Report]

:white_check_mark: pass : 2 / 2 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: com/starrocks/qe/SessionVariable.java 2 2 100.00% []

github-actions[bot] avatar Apr 26 '24 03:04 github-actions[bot]

[BE Incremental Coverage Report]

:x: fail : 10 / 19 (52.63%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: src/io/cache_input_stream.cpp 0 6 00.00% [239, 256, 261, 262, 263, 264]
:large_blue_circle: src/block_cache/starcache_wrapper.cpp 0 1 00.00% [60]
:large_blue_circle: src/common/status.h 1 2 50.00% [160]
:large_blue_circle: src/formats/parquet/file_reader.cpp 2 3 66.67% [242]
:large_blue_circle: src/connector/hive_connector.cpp 4 4 100.00% []
:large_blue_circle: src/exec/hdfs_scanner_parquet.cpp 3 3 100.00% []

github-actions[bot] avatar Apr 26 '24 03:04 github-actions[bot]

[FE Incremental Coverage Report]

:white_check_mark: pass : 5 / 5 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: com/starrocks/qe/SessionVariable.java 4 4 100.00% []
:large_blue_circle: com/starrocks/datacache/DataCacheSelectExecutor.java 1 1 100.00% []

github-actions[bot] avatar Jun 13 '24 12:06 github-actions[bot]

[BE Incremental Coverage Report]

:white_check_mark: pass : 26 / 30 (86.67%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: be/src/io/cache_input_stream.cpp 7 9 77.78% [464, 466]
:large_blue_circle: be/src/formats/parquet/file_reader.cpp 9 11 81.82% [281, 282]
:large_blue_circle: be/src/connector/hive_connector.cpp 3 3 100.00% []
:large_blue_circle: be/src/exec/hdfs_scanner.cpp 1 1 100.00% []
:large_blue_circle: be/src/block_cache/starcache_wrapper.cpp 2 2 100.00% []
:large_blue_circle: be/src/exec/hdfs_scanner_parquet.cpp 4 4 100.00% []

github-actions[bot] avatar Jun 13 '24 12:06 github-actions[bot]

@mergify backport branch-3.3 branch-3.2

wanpengfei-git avatar Jun 14 '24 13:06 wanpengfei-git