Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
RUST_TOOLCHAIN_NIGHTLY: nightly-2024-08-30
RUST_TOOLCHAIN_NIGHTLY: nightly-2025-05-09
CARGO_TERM_COLOR: always
CACHE_KEY_SUFFIX: 20250627
CARGO_UDEPS_KEY_SUFFIX: 20250627
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm]
rust_toolchain: [stable, 1.81.0]
rust_toolchain: [stable, 1.88.0]
serde: ["", "--features serde"]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -255,7 +255,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust_toolchain: [stable, 1.81.0]
rust_toolchain: [stable, 1.88.0]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand Down Expand Up @@ -455,7 +455,7 @@ jobs:
RUSTFLAGS: "-Zsanitizer=address --cfg tokio_unstable"
RUST_LOG: info
CI: true
RUST_TOOLCHAIN_NIGHTLY: nightly-2024-08-30
RUST_TOOLCHAIN_NIGHTLY: nightly-2025-05-09
run: |-
cargo +$RUST_TOOLCHAIN_NIGHTLY test --lib --bins --tests --target x86_64-unknown-linux-gnu -- --nocapture
- name: Run foyer-bench With Address Sanitizer
Expand All @@ -464,7 +464,7 @@ jobs:
RUSTFLAGS: "-Zsanitizer=address --cfg tokio_unstable"
RUST_LOG: info
CI: true
RUST_TOOLCHAIN_NIGHTLY: nightly-2024-08-30
RUST_TOOLCHAIN_NIGHTLY: nightly-2025-05-09
run: |-
cargo +$RUST_TOOLCHAIN_NIGHTLY build --all --target x86_64-unknown-linux-gnu
mkdir -p $GITHUB_WORKSPACE/foyer-data/foyer-bench/asan
Expand Down
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ members = [

[workspace.package]
version = "0.17.4"
edition = "2021"
rust-version = "1.81.0"
edition = "2024"
rust-version = "1.88.0"
repository = "https://github.com/foyer-rs/foyer"
homepage = "https://foyer.rs"
keywords = ["cache", "hybrid"]
Expand All @@ -22,8 +22,6 @@ license = "Apache-2.0"
readme = "README.md"

[workspace.dependencies]

# dependencies
twox-hash = "2"
anyhow = "1"
bincode = "1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ msrv:
RUST_BACKTRACE=1 cargo +1.81.0 nextest run --run-ignored ignored-only --no-capture --workspace

udeps:
RUSTFLAGS="--cfg tokio_unstable -Awarnings" cargo +nightly-2024-08-30 udeps --all-targets
RUSTFLAGS="--cfg tokio_unstable -Awarnings" cargo +nightly-2025-05-09 udeps --all-targets

machete:
cargo machete
Expand Down
2 changes: 1 addition & 1 deletion examples/export_metrics_prometheus_hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use anyhow::Ok;
use foyer::{Cache, CacheBuilder};
use http_body_util::Full;
use hyper::{
Request, Response,
body::{Bytes, Incoming},
header::CONTENT_TYPE,
server::conn::http1,
service::Service,
Request, Response,
};
use hyper_util::rt::TokioIo;
use mixtrics::registry::prometheus::PrometheusMetricsRegistry;
Expand Down
2 changes: 1 addition & 1 deletion foyer-bench/src/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

use std::{
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
},
time::{Duration, Instant},
};
Expand Down
2 changes: 1 addition & 1 deletion foyer-bench/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use std::{future::Future, net::SocketAddr, pin::Pin};
use anyhow::Ok;
use http_body_util::Full;
use hyper::{
Request, Response,
body::{Bytes, Incoming},
header::CONTENT_TYPE,
server::conn::http1,
service::Service,
Request, Response,
};
use hyper_util::rt::TokioIo;
use prometheus::{Encoder, Registry, TextEncoder};
Expand Down
54 changes: 28 additions & 26 deletions foyer-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ use std::{
net::SocketAddr,
ops::{Deref, Range},
sync::{
atomic::{AtomicU64, Ordering},
Arc,
atomic::{AtomicU64, Ordering},
},
time::{Duration, Instant},
};

use analyze::{analyze, monitor, Metrics};
use analyze::{Metrics, analyze, monitor};
use bytesize::ByteSize;
use clap::{builder::PossibleValuesParser, ArgGroup, Parser};
use clap::{ArgGroup, Parser, builder::PossibleValuesParser};
use exporter::PrometheusExporter;
use foyer::{
Code, CodeError, Compression, DirectFileDeviceOptions, DirectFsDeviceOptions, Engine, FifoConfig, FifoPicker,
Expand All @@ -46,7 +46,7 @@ use futures_util::future::join_all;
use itertools::Itertools;
use mixtrics::registry::prometheus::PrometheusMetricsRegistry;
use prometheus::Registry;
use rand::{distr::Distribution, rngs::StdRng, Rng, SeedableRng};
use rand::{Rng, SeedableRng, distr::Distribution, rngs::StdRng};
use rate::RateLimiter;
use text::text;
use tokio::sync::{broadcast, oneshot};
Expand Down Expand Up @@ -390,7 +390,7 @@ fn setup() {

#[cfg(not(any(feature = "tokio-console", feature = "tracing")))]
fn setup() {
use tracing_subscriber::{prelude::*, EnvFilter};
use tracing_subscriber::{EnvFilter, prelude::*};

tracing_subscriber::registry()
.with(
Expand Down Expand Up @@ -433,22 +433,24 @@ async fn benchmark(args: Args) {

#[cfg(feature = "deadlock")]
{
std::thread::spawn(move || loop {
std::thread::sleep(Duration::from_secs(1));
let deadlocks = parking_lot::deadlock::check_deadlock();
if deadlocks.is_empty() {
continue;
}
std::thread::spawn(move || {
loop {
std::thread::sleep(Duration::from_secs(1));
let deadlocks = parking_lot::deadlock::check_deadlock();
if deadlocks.is_empty() {
continue;
}

println!("{} deadlocks detected", deadlocks.len());
for (i, threads) in deadlocks.iter().enumerate() {
println!("Deadlock #{i}");
for t in threads {
println!("Thread Id {:#?}", t.thread_id());
println!("{:#?}", t.backtrace());
println!("{} deadlocks detected", deadlocks.len());
for (i, threads) in deadlocks.iter().enumerate() {
println!("Deadlock #{i}");
for t in threads {
println!("Thread Id {:#?}", t.thread_id());
println!("{:#?}", t.backtrace());
}
}
panic!()
}
panic!()
});
}

Expand Down Expand Up @@ -742,10 +744,10 @@ async fn write(id: u64, hybrid: HybridCache<u64, Value>, context: Arc<Context>,
};

// TODO(MrCroxx): Use `let_chains` here after it is stable.
if let Some(limiter) = &mut limiter {
if let Some(wait) = limiter.consume(entry_size as f64) {
tokio::time::sleep(wait).await;
}
if let Some(limiter) = &mut limiter
&& let Some(wait) = limiter.consume(entry_size as f64)
{
tokio::time::sleep(wait).await;
}

let time = Instant::now();
Expand Down Expand Up @@ -849,10 +851,10 @@ async fn read(hybrid: HybridCache<u64, Value>, context: Arc<Context>, mut stop:
assert_eq!(&text(idx as usize, entry_size), entry.value().inner.as_ref());

// TODO(MrCroxx): Use `let_chains` here after it is stable.
if let Some(limiter) = &mut limiter {
if let Some(wait) = limiter.consume(entry_size as f64) {
tokio::time::sleep(wait).await;
}
if let Some(limiter) = &mut limiter
&& let Some(wait) = limiter.consume(entry_size as f64)
{
tokio::time::sleep(wait).await;
}

if record {
Expand Down
24 changes: 12 additions & 12 deletions foyer-common/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ pub trait Unsigned:
}

impl<
U: Add<Output = Self>
+ Sub<Output = Self>
+ BitAnd<Output = Self>
+ Not<Output = Self>
+ Sized
+ From<u8>
+ Eq
+ Debug
+ Display
+ Clone
+ Copy,
> Unsigned for U
U: Add<Output = Self>
+ Sub<Output = Self>
+ BitAnd<Output = Self>
+ Not<Output = Self>
+ Sized
+ From<u8>
+ Eq
+ Debug
+ Display
+ Clone
+ Copy,
> Unsigned for U
{
}

Expand Down
2 changes: 1 addition & 1 deletion foyer-common/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
marker::PhantomData,
ops::Deref,
pin::Pin,
task::{ready, Context, Poll},
task::{Context, Poll, ready},
};

use pin_project::pin_project;
Expand Down
4 changes: 2 additions & 2 deletions foyer-common/src/rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ impl RateLimiter {
#[cfg(test)]
mod tests {
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
};

use rand::{rng, Rng};
use rand::{Rng, rng};

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions foyer-common/src/rated_ticket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ impl RatedTicket {
mod tests {
use std::{
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
},
time::Duration,
};

use itertools::Itertools;
use rand::{rng, Rng};
use rand::{Rng, rng};

use super::*;

Expand Down
6 changes: 3 additions & 3 deletions foyer-common/src/utils/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub trait RangeBoundsExt<
}

impl<
T: PartialOrd<T> + Add<Output = T> + Sub<Output = T> + Clone + Copy + Send + Sync + 'static + ZeroOne,
RB: RangeBounds<T>,
> RangeBoundsExt<T> for RB
T: PartialOrd<T> + Add<Output = T> + Sub<Output = T> + Clone + Copy + Send + Sync + 'static + ZeroOne,
RB: RangeBounds<T>,
> RangeBoundsExt<T> for RB
{
}
2 changes: 1 addition & 1 deletion foyer-memory/benches/bench_dynamic_dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::{
time::{Duration, Instant},
};

use rand::{distr::Alphanumeric, rng, Rng};
use rand::{Rng, distr::Alphanumeric, rng};

struct T<F>
where
Expand Down
4 changes: 2 additions & 2 deletions foyer-memory/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ use serde::{Deserialize, Serialize};
use tokio::sync::oneshot;

use crate::{
Piece, Pipe, Result,
eviction::{
fifo::{Fifo, FifoConfig},
lfu::{Lfu, LfuConfig},
lru::{Lru, LruConfig},
s3fifo::{S3Fifo, S3FifoConfig},
},
raw::{FetchContext, FetchState, RawCache, RawCacheConfig, RawCacheEntry, RawFetch, Weighter},
Piece, Pipe, Result,
};

/// Entry properties for in-memory only cache.
Expand Down Expand Up @@ -994,7 +994,7 @@ mod tests {

use futures_util::future::join_all;
use itertools::Itertools;
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
use rand::{Rng, SeedableRng, rngs::StdRng, seq::SliceRandom};

use super::*;
use crate::eviction::{fifo::FifoConfig, lfu::LfuConfig, lru::LruConfig, s3fifo::S3FifoConfig};
Expand Down
4 changes: 2 additions & 2 deletions foyer-memory/src/eviction/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use foyer_common::{
code::{Key, Value},
properties::Properties,
};
use intrusive_collections::{intrusive_adapter, LinkedList, LinkedListAtomicLink};
use intrusive_collections::{LinkedList, LinkedListAtomicLink, intrusive_adapter};
use serde::{Deserialize, Serialize};

use super::{Eviction, Op};
Expand Down Expand Up @@ -100,7 +100,7 @@ pub mod tests {

use super::*;
use crate::{
eviction::test_utils::{assert_ptr_eq, assert_ptr_vec_eq, Dump, TestProperties},
eviction::test_utils::{Dump, TestProperties, assert_ptr_eq, assert_ptr_vec_eq},
record::Data,
};

Expand Down
4 changes: 2 additions & 2 deletions foyer-memory/src/eviction/lfu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use foyer_common::{
properties::Properties,
strict_assert, strict_assert_eq, strict_assert_ne,
};
use intrusive_collections::{intrusive_adapter, LinkedList, LinkedListAtomicLink};
use intrusive_collections::{LinkedList, LinkedListAtomicLink, intrusive_adapter};
use serde::{Deserialize, Serialize};

use super::{Eviction, Op};
Expand Down Expand Up @@ -412,7 +412,7 @@ mod tests {

use super::*;
use crate::{
eviction::test_utils::{assert_ptr_eq, assert_ptr_vec_vec_eq, Dump, OpExt, TestProperties},
eviction::test_utils::{Dump, OpExt, TestProperties, assert_ptr_eq, assert_ptr_vec_vec_eq},
record::Data,
};

Expand Down
Loading
Loading