Skip to content

Commit

Permalink
build: reduce futures dependencies (#851)
Browse files Browse the repository at this point in the history
* build: reduce futures dependencies

Signed-off-by: tison <[email protected]>

* address comments

Signed-off-by: tison <[email protected]>

---------

Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Jan 31, 2025
1 parent 92522d3 commit bc61fbd
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 212 deletions.
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
2 changes: 1 addition & 1 deletion 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 Down
4 changes: 1 addition & 3 deletions foyer-common/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ where

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

use futures::future::poll_fn;
use std::{future::poll_fn, pin::pin};

use super::*;

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;
7 changes: 5 additions & 2 deletions foyer-common/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use std::{
future::Future,
ops::Deref,
pin::Pin,
sync::atomic::{AtomicU64, Ordering},
Expand All @@ -21,7 +22,6 @@ use std::{
};

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

Expand Down Expand Up @@ -201,7 +201,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
3 changes: 1 addition & 2 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 std::{fmt::Debug, future::Future, marker::PhantomData, sync::Arc};

use auto_enums::auto_enum;
use foyer_common::code::{StorageKey, StorageValue};
use foyer_memory::Piece;
use futures::Future;

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
2 changes: 1 addition & 1 deletion foyer-storage/src/large/tombstone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{
use array_util::SliceExt;
use bytes::{Buf, BufMut};
use foyer_common::{bits, metrics::Metrics, strict_assert_eq};
use futures::future::try_join_all;
use futures_util::future::try_join_all;
use tokio::sync::Mutex;

use crate::{
Expand Down
6 changes: 2 additions & 4 deletions foyer-storage/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ use std::{

use async_channel::{Receiver, Sender};
use foyer_common::{countdown::Countdown, metrics::Metrics};
use futures::{
future::{BoxFuture, Shared},
FutureExt,
};
use futures_core::future::BoxFuture;
use futures_util::{future::Shared, FutureExt};
use itertools::Itertools;
use parking_lot::Mutex;
use pin_project::pin_project;
Expand Down
Loading

0 comments on commit bc61fbd

Please sign in to comment.