-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: wrapper cache type, reorg utils, add metrics framework (#15)
Signed-off-by: MrCroxx <[email protected]>
- Loading branch information
Showing
14 changed files
with
232 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[workspace] | ||
|
||
members = ["foyer", "foyer-bench"] | ||
members = ["foyer", "foyer-bench", "foyer-utils"] | ||
|
||
[patch.crates-io] | ||
# cmsketch = { path = "../cmsketch-rs" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[package] | ||
name = "foyer-utils" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["MrCroxx <[email protected]>"] | ||
description = "Hybrid cache for Rust" | ||
license = "Apache-2.0" | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
async-trait = "0.1" | ||
bytes = "1" | ||
cmsketch = "0.1" | ||
crossbeam = "0.8" | ||
futures = "0.3" | ||
itertools = "0.10.5" | ||
libc = "0.2" | ||
memoffset = "0.8" | ||
nix = { version = "0.26", features = ["fs", "mman"] } | ||
parking_lot = "0.12" | ||
paste = "1.0" | ||
prometheus = "0.13" | ||
thiserror = "1" | ||
tokio = { version = "1", features = [ | ||
"rt", | ||
"rt-multi-thread", | ||
"sync", | ||
"macros", | ||
"time", | ||
"signal", | ||
] } | ||
twox-hash = "1" | ||
|
||
[dev-dependencies] | ||
bytesize = "1" | ||
clap = { version = "4", features = ["derive"] } | ||
hdrhistogram = "7" | ||
rand = "0.8.5" | ||
rand_mt = "4.2.1" | ||
tempfile = "3" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2023 MrCroxx | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use prometheus::{ | ||
register_counter_vec_with_registry, register_histogram_vec_with_registry, | ||
register_int_counter_with_registry, CounterVec, HistogramVec, IntCounter, Registry, | ||
}; | ||
|
||
pub struct Metrics { | ||
pub miss: IntCounter, | ||
|
||
pub latency: HistogramVec, | ||
pub bytes: CounterVec, | ||
} | ||
|
||
impl Default for Metrics { | ||
fn default() -> Self { | ||
Self::new(Registry::new()) | ||
} | ||
} | ||
|
||
impl Metrics { | ||
pub fn new(registry: Registry) -> Self { | ||
let miss = | ||
register_int_counter_with_registry!("foyer_cache_miss", "file cache miss", registry) | ||
.unwrap(); | ||
|
||
let latency = register_histogram_vec_with_registry!( | ||
"foyer_latency", | ||
"foyer latency", | ||
&["op"], | ||
vec![ | ||
0.0001, 0.001, 0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, | ||
1.0 | ||
], | ||
registry | ||
) | ||
.unwrap(); | ||
|
||
let bytes = | ||
register_counter_vec_with_registry!("foyer_bytes", "foyer bytes", &["op"], registry) | ||
.unwrap(); | ||
|
||
Self { | ||
miss, | ||
latency, | ||
bytes, | ||
} | ||
} | ||
} |
Oops, something went wrong.