Skip to content

Commit 78fca8d

Browse files
authored
feat: use blob format in disk cache (#866)
* feat: use blob format in disk cache Signed-off-by: MrCroxx <mrcroxx@outlook.com> * chore: resolve changes after merge Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: add window splter for blob writer Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: keep entry info in blob builder Signed-off-by: MrCroxx <mrcroxx@outlook.com> * fix: fix split window calculation Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: add window split info into blob info Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: introduce new writer framework Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: add absolute range in window struct Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: use blob format to speed up lodc recovery Signed-off-by: MrCroxx <mrcroxx@outlook.com> * fix: fix batch first window range, enhance foyer-bench args Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: log recovery duration on startup Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: add blob efficiency histogram Signed-off-by: MrCroxx <mrcroxx@outlook.com> * fix: fix blob efficiency metrics Signed-off-by: MrCroxx <mrcroxx@outlook.com> * refactor: tiny refine Signed-off-by: MrCroxx <mrcroxx@outlook.com> * feat: REAL PIPELINE WRITE! Signed-off-by: MrCroxx <mrcroxx@outlook.com> * chore: remove unused comments Signed-off-by: MrCroxx <mrcroxx@outlook.com> * chore: use 1.81.0 compatible lifetime annotation Signed-off-by: MrCroxx <mrcroxx@outlook.com> * refactor: refine flusher code Signed-off-by: MrCroxx <mrcroxx@outlook.com> --------- Signed-off-by: MrCroxx <mrcroxx@outlook.com>
1 parent 344363a commit 78fca8d

30 files changed

+2308
-1489
lines changed

docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ services:
4444
- 3000:3000
4545
environment:
4646
- GF_AUTH_ANONYMOUS_ENABLED=true
47+
- NO_PROXY=prometheus
4748

4849
jaeger:
4950
image: jaegertracing/all-in-one:latest
@@ -56,4 +57,3 @@ services:
5657
- 6832:6832/udp
5758
- 16686:16686
5859
- 4317:4317
59-

etc/grafana/dashboards/foyer.json

+1-1
Large diffs are not rendered by default.

foyer-bench/src/main.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ struct Args {
245245
#[arg(long, value_parser = PossibleValuesParser::new(["lru", "lfu", "fifo", "s3fifo"]), default_value = "lru")]
246246
eviction: String,
247247

248+
#[arg(long, default_value_t = ByteSize::mib(16))]
249+
buffer_pool_size: ByteSize,
250+
248251
#[arg(long, default_value_t = ByteSize::kib(16))]
249252
set_size: ByteSize,
250253

@@ -513,7 +516,8 @@ async fn benchmark(args: Args) {
513516
.with_eviction_pickers(vec![
514517
Box::new(InvalidRatioPicker::new(args.invalid_ratio)),
515518
Box::<FifoPicker>::default(),
516-
]);
519+
])
520+
.with_buffer_pool_size(args.buffer_pool_size.as_u64() as _);
517521

518522
let small = SmallEngineOptions::new()
519523
.with_flushers(args.flushers)

foyer-common/src/metrics.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::borrow::Cow;
15+
use std::{borrow::Cow, fmt::Debug};
1616

1717
use mixtrics::metrics::{BoxedCounter, BoxedGauge, BoxedHistogram, BoxedRegistry};
1818

1919
#[expect(missing_docs)]
20-
#[derive(Debug)]
2120
pub struct Metrics {
2221
/* in-memory cache metrics */
2322
pub memory_insert: BoxedCounter,
@@ -68,6 +67,8 @@ pub struct Metrics {
6867
pub storage_entry_serialize_duration: BoxedHistogram,
6968
pub storage_entry_deserialize_duration: BoxedHistogram,
7069

70+
pub storage_blob_efficiency: BoxedHistogram,
71+
7172
/* hybrid cache metrics */
7273
pub hybrid_insert: BoxedCounter,
7374
pub hybrid_hit: BoxedCounter,
@@ -81,6 +82,12 @@ pub struct Metrics {
8182
pub hybrid_fetch_duration: BoxedHistogram,
8283
}
8384

85+
impl Debug for Metrics {
86+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87+
f.debug_struct("Metrics").finish()
88+
}
89+
}
90+
8491
impl Metrics {
8592
/// Create a new metric with the given name.
8693
pub fn new(name: impl Into<Cow<'static, str>>, registry: &BoxedRegistry) -> Self {
@@ -169,6 +176,12 @@ impl Metrics {
169176
&["name", "op"],
170177
);
171178

179+
let foyer_storage_blob_efficiency = registry.register_histogram_vec(
180+
"foyer_storage_blob_efficiency".into(),
181+
"foyer large object disk cache entry count in a blob".into(),
182+
&["name"],
183+
);
184+
172185
let storage_enqueue = foyer_storage_op_total.counter(&[name.clone(), "enqueue".into()]);
173186
let storage_hit = foyer_storage_op_total.counter(&[name.clone(), "hit".into()]);
174187
let storage_miss = foyer_storage_op_total.counter(&[name.clone(), "miss".into()]);
@@ -207,6 +220,8 @@ impl Metrics {
207220
let storage_entry_deserialize_duration =
208221
foyer_storage_entry_serde_duration.histogram(&[name.clone(), "deserialize".into()]);
209222

223+
let storage_blob_efficiency = foyer_storage_blob_efficiency.histogram(&[name.clone()]);
224+
210225
/* hybrid cache metrics */
211226

212227
let foyer_hybrid_op_total = registry.register_counter_vec(
@@ -269,6 +284,7 @@ impl Metrics {
269284
storage_region_size_bytes,
270285
storage_entry_serialize_duration,
271286
storage_entry_deserialize_duration,
287+
storage_blob_efficiency,
272288

273289
hybrid_insert,
274290
hybrid_hit,

0 commit comments

Comments
 (0)