Skip to content

Commit

Permalink
build: reduce futures dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Jan 31, 2025
1 parent 92522d3 commit 61c2917
Show file tree
Hide file tree
Showing 27 changed files with 64 additions and 220 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.toml]
indent_size = tab
tab_width = 2
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ readme = "README.md"
ahash = "0.8"
bytesize = { package = "foyer-bytesize", version = "2" }
clap = { version = "4", features = ["derive"] }
crossbeam = "0.8"
equivalent = "1"
fastrace = "0.7"
futures-core = { version = "0.3" }
futures-util = { version = "0.3", default-features = false, features = ["std"] }
hashbrown = "0.15"
itertools = "0.14"
parking_lot = { version = "0.12" }
Expand Down
2 changes: 1 addition & 1 deletion foyer-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ console-subscriber = { version = "0.4", optional = true }
fastrace = { workspace = true, optional = true }
fastrace-jaeger = { version = "0.7", optional = true }
foyer = { workspace = true }
futures = "0.3"
futures-util = { workspace = true }
hdrhistogram = "7"
http-body-util = "0.1"
humantime = "2"
Expand Down
2 changes: 1 addition & 1 deletion foyer-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use foyer::{
HybridCacheBuilder, InvalidRatioPicker, LargeEngineOptions, LfuConfig, LruConfig, RateLimitPicker, RecoverMode,
RuntimeOptions, S3FifoConfig, SmallEngineOptions, TokioRuntimeOptions, TracingOptions,
};
use futures::future::join_all;
use futures_util::future::join_all;
use itertools::Itertools;
use mixtrics::registry::prometheus::PrometheusMetricsRegistry;
use prometheus::Registry;
Expand Down
3 changes: 1 addition & 2 deletions foyer-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ahash = { workspace = true }
bytes = "1"
cfg-if = "1"
fastrace = { workspace = true }
futures = "0.3"
itertools = { workspace = true }
mixtrics = { workspace = true }
parking_lot = { workspace = true }
Expand All @@ -26,7 +25,7 @@ serde = { workspace = true }
tokio = { workspace = true }

[dev-dependencies]
futures = "0.3"
futures-util = { workspace = true }
mixtrics = { workspace = true, features = ["test-utils"] }
rand = "0.8.5"

Expand Down
4 changes: 2 additions & 2 deletions foyer-common/src/countdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Countdown {
mod tests {
use std::time::Duration;

use futures::future::join_all;
use futures_util::future::join_all;

use super::*;

Expand All @@ -66,7 +66,7 @@ mod tests {
tokio::time::sleep(Duration::from_millis(10)).await;
cd.countdown()
}))
.await;
.await;
assert_eq!(counter, res.into_iter().filter(|b| !b).count());
}

Expand Down
3 changes: 1 addition & 2 deletions foyer-common/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ where

#[cfg(test)]
mod tests {
use std::future::poll_fn;
use std::pin::pin;

use futures::future::poll_fn;

use super::*;

#[tokio::test]
Expand Down
4 changes: 1 addition & 3 deletions foyer-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

//! Shared components and utils for foyer.
/// Allow enable debug assertions in release profile with feature "strict_assertion".
/// Allow to enable debug assertions in release profile with feature "strict_assertion".
pub mod assert;
/// The util that convert the blocking call to async call.
pub mod asyncify;
Expand Down Expand Up @@ -48,5 +48,3 @@ pub mod runtime;
pub mod scope;
/// Tracing related components.
pub mod tracing;
/// An async wait group implementation.
pub mod wait_group;
14 changes: 8 additions & 6 deletions foyer-common/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use fastrace::prelude::*;
use pin_project::pin_project;
use serde::{Deserialize, Serialize};
use std::future::Future;
use std::{
ops::Deref,
pin::Pin,
Expand All @@ -20,11 +24,6 @@ use std::{
time::Duration,
};

use fastrace::prelude::*;
use futures::{ready, Future};
use pin_project::pin_project;
use serde::{Deserialize, Serialize};

/// Configurations for tracing.
#[derive(Debug, Default)]
pub struct TracingConfig {
Expand Down Expand Up @@ -201,7 +200,10 @@ where
let this = self.project();

let _guard = this.root.as_ref().map(|s| s.set_local_parent());
let res = ready!(this.inner.poll(cx));
let res = match this.inner.poll(cx) {
Poll::Ready(res) => res,
Poll::Pending => return Poll::Pending,
};

let mut root = this.root.take().unwrap();

Expand Down
158 changes: 0 additions & 158 deletions foyer-common/src/wait_group.rs

This file was deleted.

2 changes: 1 addition & 1 deletion foyer-memory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ cmsketch = "0.2.1"
equivalent = { workspace = true }
fastrace = { workspace = true }
foyer-common = { workspace = true }
futures = "0.3"
hashbrown = { workspace = true }
intrusive-collections = { package = "foyer-intrusive-collections", version = "0.10.0-dev" }
itertools = { workspace = true }
Expand All @@ -34,6 +33,7 @@ tracing = { workspace = true }

[dev-dependencies]
csv = "1.3.0"
futures-util = { workspace = true }
moka = { version = "0.12", features = ["sync"] }
rand = { version = "0.8", features = ["small_rng"] }
test-log = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion foyer-memory/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ where
mod tests {
use std::{ops::Range, time::Duration};

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

Expand Down
4 changes: 2 additions & 2 deletions foyer-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ auto_enums = { version = "0.8", features = ["futures03"] }
bincode = "1"
bytes = "1"
clap = { workspace = true }
either = "1"
equivalent = { workspace = true }
fastrace = { workspace = true }
flume = "0.11"
foyer-common = { workspace = true }
foyer-memory = { workspace = true }
fs4 = { version = "0.12", default-features = false }
futures = "0.3"
futures-core = { workspace = true }
futures-util = { workspace = true }
itertools = { workspace = true }
libc = "0.2"
lz4 = "1.24"
Expand Down
2 changes: 1 addition & 1 deletion foyer-storage/src/device/direct_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{

use foyer_common::{asyncify::asyncify_with_runtime, bits};
use fs4::free_space;
use futures::future::try_join_all;
use futures_util::future::try_join_all;
use itertools::Itertools;
use serde::{Deserialize, Serialize};

Expand Down
5 changes: 2 additions & 3 deletions foyer-storage/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{fmt::Debug, marker::PhantomData, sync::Arc};

use auto_enums::auto_enum;
use foyer_common::code::{StorageKey, StorageValue};
use foyer_memory::Piece;
use futures::Future;
use std::future::Future;
use std::{fmt::Debug, marker::PhantomData, sync::Arc};

use crate::{
error::Result,
Expand Down
2 changes: 1 addition & 1 deletion foyer-storage/src/large/flusher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use foyer_common::{
metrics::Metrics,
};
use foyer_memory::Piece;
use futures::future::{try_join, try_join_all};
use futures_util::future::{try_join, try_join_all};
use tokio::sync::{oneshot, OwnedSemaphorePermit, Semaphore};

use super::{
Expand Down
2 changes: 1 addition & 1 deletion foyer-storage/src/large/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use foyer_common::{
metrics::Metrics,
};
use foyer_memory::Piece;
use futures::future::{join_all, try_join_all};
use futures_util::future::{join_all, try_join_all};
use tokio::sync::Semaphore;

use super::{
Expand Down
2 changes: 1 addition & 1 deletion foyer-storage/src/large/reclaimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use foyer_common::{
code::{StorageKey, StorageValue},
metrics::Metrics,
};
use futures::future::join_all;
use futures_util::future::join_all;
use itertools::Itertools;
use tokio::sync::{mpsc, oneshot, Semaphore, SemaphorePermit};

Expand Down
2 changes: 1 addition & 1 deletion foyer-storage/src/large/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use foyer_common::{
code::{StorageKey, StorageValue},
metrics::Metrics,
};
use futures::future::try_join_all;
use futures_util::future::try_join_all;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use tokio::sync::Semaphore;
Expand Down
Loading

0 comments on commit 61c2917

Please sign in to comment.