Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Remove stream_throttle (#1079)

Aleksandr Golokozefa1d7d22672
diff --git a/Cargo.lock b/Cargo.lock
index d7d0296a4..e0231b5c8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4795,7 +4795,6 @@ dependencies = [
"httparse",
"serde_json",
"shoji",
- "stream_throttle",
"thiserror 2.0.21",
"tokio",
"tracing",
@@ -6061,12 +6060,6 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
-[[package]]
-name = "pin-utils"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "13bee6c73da26345c729282832b60b0363cf3dd9f4bfd81d8551b7a1c889a113"
-
[[package]]
name = "piper"
version = "0.2.5"
@@ -8242,18 +8235,6 @@ version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff7589a1859b09232522bb9edf076ca7fcf14ded96685d3fa629db73023ffbb7"
-[[package]]
-name = "stream_throttle"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e5c28c494ad34b726248a73abd7184468b351ff6218c8524f0f8a426664dcbd7"
-dependencies = [
- "futures",
- "log",
- "pin-utils",
- "tokio",
-]
-
[[package]]
name = "string_cache"
version = "0.9.0"
diff --git a/Cargo.toml b/Cargo.toml
index dd3cdb6be..9bffa5306 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -146,7 +146,6 @@ futures-util = "0.3.34"
async-fs = "2.2.0"
http = "1.5.0"
httparse = "1.10.1"
-stream_throttle = "0.5.1"
reqwest = { version = "0.13.5", features = [
"json",
"stream",
diff --git a/crates/legacy/mock-registry/Cargo.toml b/crates/legacy/mock-registry/Cargo.toml
index f2df078a8..fc5f5b0e8 100644
--- a/crates/legacy/mock-registry/Cargo.toml
+++ b/crates/legacy/mock-registry/Cargo.toml
@@ -17,7 +17,6 @@ http.workspace = true
httparse.workspace = true
serde_json.workspace = true
shoji.workspace = true
-stream_throttle.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["full"] }
tracing.workspace = true
diff --git a/crates/legacy/mock-registry/src/file_server.rs b/crates/legacy/mock-registry/src/file_server.rs
index bdaf43ac8..52b7ad7d0 100644
--- a/crates/legacy/mock-registry/src/file_server.rs
+++ b/crates/legacy/mock-registry/src/file_server.rs
@@ -1,11 +1,11 @@
use std::{net::SocketAddr, sync::Arc, time::Duration};
use http::{Method, StatusCode, header::RANGE};
-use stream_throttle::{ThrottlePool, ThrottleRate};
use tokio::{
io::AsyncWriteExt,
net::{TcpListener, TcpStream},
task::JoinHandle as TokioJoinHandle,
+ time::{MissedTickBehavior, interval},
};
use crate::{
@@ -122,9 +122,10 @@ async fn write_file_body(
return Ok(());
}
- let throttle = ThrottlePool::new(ThrottleRate::new(1, THROTTLED_CHUNK_INTERVAL));
+ let mut throttle = interval(THROTTLED_CHUNK_INTERVAL);
+ throttle.set_missed_tick_behavior(MissedTickBehavior::Delay);
for chunk in body.chunks(THROTTLED_CHUNK_SIZE) {
- throttle.queue().await;
+ throttle.tick().await;
stream.write_all(chunk).await?;
stream.flush().await?;
}