feat(io): implement CacheIO read-cache layer for disk IO#2419
Conversation
|
/label S-waiting-on-review |
Merge Protections🟢 All 3 merge protections satisfied — ready to merge. Show 3 satisfied protections🟢 Require kind label
🟢 Require version label
🟢 Require linked issue for feature/bug PRs
|
There was a problem hiding this comment.
Code Review
This pull request introduces CacheIO, a page-based read-cache IO layer wrapping an underlying disk-backed IO implementation, along with its configuration parameters, an LRU eviction strategy, and unit tests. The review feedback highlights several critical issues that must be addressed: potential Use-After-Free (UAF) vulnerabilities in ReadImpl and DirectReadImpl due to race conditions and lack of page pinning, uninitialized and un-updated this->size_ values that will cause read operations to fail, a potential division-by-zero crash if page_size is configured as zero, and a redundant if-else block during eviction strategy initialization.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new CacheIO<InnerIO> CRTP IO wrapper that adds a page-based in-memory read cache in front of an underlying IO implementation, plus JSON-parseable parameters and unit tests.
Changes:
- Added
CacheIO<InnerIO>template with page caching, LRU eviction, and DirectRead/MultiRead support. - Added
CacheIOParameter(JSON serialization/parsing) andEvictionStrategy/LRUEviction. - Wired
cache_iointo IO parameter parsing and header aggregation; added unit tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/io/io_headers.h | Exposes cache_io.h through the IO header umbrella. |
| src/io/common/io_parameter.cpp | Adds JSON parsing support for type=cache_io parameters. |
| src/io/CMakeLists.txt | Builds cache_io_parameter.cpp as part of the IO object library. |
| src/io/cache_io/eviction_strategy.h | Introduces eviction strategy interface and LRU implementation. |
| src/io/cache_io/cache_io.h | Implements the CacheIO read-cache IO wrapper. |
| src/io/cache_io/cache_io_test.cpp | Adds unit tests for caching, eviction, direct read, multiread, and parameters. |
| src/io/cache_io/cache_io_parameter.h | Declares CacheIOParameter (page size, total cache size, eviction strategy). |
| src/io/cache_io/cache_io_parameter.cpp | Implements JSON (de)serialization for CacheIOParameter. |
| src/inner_string_params.h | Registers the cache_io IO type string. |
ec12104 to
d4e7d6b
Compare
d4e7d6b to
0b45a24
Compare
0b45a24 to
0c604cd
Compare
0c604cd to
33f1b3a
Compare
242da06 to
224fcb5
Compare
224fcb5 to
07cef6d
Compare
07cef6d to
242b2a8
Compare
242b2a8 to
c165f40
Compare
c165f40 to
e2cb7d3
Compare
fe96221 to
901c7aa
Compare
901c7aa to
d079368
Compare
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
d079368 to
03bb0cc
Compare
Summary
Add CacheIO template class that provides a page-based read cache in front of any disk-backed IO implementation. All reads go through the cache; writes passthrough directly to the inner IO with no cache involvement.
Closes #2420
Design
Components
Testing