From b6c629d28664e77461cb6ef79b862bdd57f37b28 Mon Sep 17 00:00:00 2001 From: Solar Mithril Date: Mon, 13 Oct 2025 13:03:21 +0400 Subject: [PATCH 1/5] nits --- crates/rproxy/Cargo.toml | 2 +- crates/rproxy/src/metrics/metrics.rs | 4 ++-- crates/rproxy/src/proxy_http/proxy_http.rs | 10 ++++++---- crates/rproxy/src/proxy_ws/proxy_ws.rs | 4 ++-- crates/rproxy/src/server/server.rs | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/rproxy/Cargo.toml b/crates/rproxy/Cargo.toml index a6aa97d..c553a49 100644 --- a/crates/rproxy/Cargo.toml +++ b/crates/rproxy/Cargo.toml @@ -49,6 +49,6 @@ tracing-subscriber = { version = "0.3.20", features = ["env-filter", "json", "va tungstenite = { version = "0.27.0", features = ["handshake"] } url = "2.5.7" uuid = { version = "1.18.1", features = ["v7" ]} -valuable = { version = "0.1.1", features = ["derive"] } +valuable = { version = "0.1.0", features = ["derive"] } x509-parser = "0.18.0" zstd = "0.13.3" diff --git a/crates/rproxy/src/metrics/metrics.rs b/crates/rproxy/src/metrics/metrics.rs index 223f28b..0b7320c 100644 --- a/crates/rproxy/src/metrics/metrics.rs +++ b/crates/rproxy/src/metrics/metrics.rs @@ -5,7 +5,7 @@ use actix_web::{ HttpRequest, HttpResponse, HttpServer, - middleware::{NormalizePath, TrailingSlash}, + middleware::NormalizePath, web, }; use awc::http::Method; @@ -287,7 +287,7 @@ impl Metrics { let server = match HttpServer::new(move || { App::new() .app_data(web::Data::new(self.clone())) - .wrap(NormalizePath::new(TrailingSlash::Trim)) + .wrap(NormalizePath::trim()) .default_service(web::route().to(Self::receive)) }) .workers(1) diff --git a/crates/rproxy/src/proxy_http/proxy_http.rs b/crates/rproxy/src/proxy_http/proxy_http.rs index 87871b0..63ccf52 100644 --- a/crates/rproxy/src/proxy_http/proxy_http.rs +++ b/crates/rproxy/src/proxy_http/proxy_http.rs @@ -22,7 +22,7 @@ use actix_web::{ HttpServer, body::BodySize, http::{StatusCode, header}, - middleware::{NormalizePath, TrailingSlash}, + middleware::NormalizePath, web, }; use awc::{ @@ -179,7 +179,7 @@ where App::new() .app_data(this) - .wrap(NormalizePath::new(TrailingSlash::Trim)) + .wrap(NormalizePath::trim()) .default_service(web::route().to(Self::receive)) }) .on_connect(Self::on_connect(metrics, client_connections_count)) @@ -250,10 +250,10 @@ where socket.set_tcp_keepalive( &socket2::TcpKeepalive::new() .with_time( - config.idle_connection_timeout().div_f64(f64::from(TCP_KEEPALIVE_ATTEMPTS)), + config.idle_connection_timeout().checked_div(TCP_KEEPALIVE_ATTEMPTS).expect("duration is not zero"), ) .with_interval( - config.idle_connection_timeout().div_f64(f64::from(TCP_KEEPALIVE_ATTEMPTS)), + config.idle_connection_timeout().checked_div(TCP_KEEPALIVE_ATTEMPTS).expect("duration is not zero"), ) .with_retries(TCP_KEEPALIVE_ATTEMPTS - 1), )?; @@ -457,11 +457,13 @@ where ) { if cli_req.decompressed_size < cli_req.size { (cli_req.decompressed_body, cli_req.decompressed_size) = + // TODO: remove this clone decompress(cli_req.body.clone(), cli_req.size, cli_req.info.content_encoding()); } if mrr_res.decompressed_size < mrr_res.size { (mrr_res.decompressed_body, mrr_res.decompressed_size) = + // TODO: remove this clone decompress(mrr_res.body.clone(), mrr_res.size, mrr_res.info.content_encoding()); } diff --git a/crates/rproxy/src/proxy_ws/proxy_ws.rs b/crates/rproxy/src/proxy_ws/proxy_ws.rs index 72fdfb8..4630a6c 100644 --- a/crates/rproxy/src/proxy_ws/proxy_ws.rs +++ b/crates/rproxy/src/proxy_ws/proxy_ws.rs @@ -15,7 +15,7 @@ use actix_web::{ HttpRequest, HttpResponse, HttpServer, - middleware::{NormalizePath, TrailingSlash}, + middleware::NormalizePath, web, }; use actix_ws::{MessageStream, Session}; @@ -158,7 +158,7 @@ where App::new() .app_data(this) - .wrap(NormalizePath::new(TrailingSlash::Trim)) + .wrap(NormalizePath::trim()) .default_service(web::route().to(Self::receive)) }) .on_connect(Self::on_connect(metrics, client_connections_count)) diff --git a/crates/rproxy/src/server/server.rs b/crates/rproxy/src/server/server.rs index 12bf1a9..de0b030 100644 --- a/crates/rproxy/src/server/server.rs +++ b/crates/rproxy/src/server/server.rs @@ -28,7 +28,7 @@ impl Server { let resetter = Server::wait_for_reset_signal(canceller.clone()); // spawn metrics service - let metrics = Arc::new(Metrics::new(config.metrics.clone())); + let metrics = Arc::new(Metrics::new(config.metrics)); { let canceller = canceller.clone(); let metrics = metrics.clone(); From 5c4415fe99e208e70c706cd24cce40051c1235ec Mon Sep 17 00:00:00 2001 From: Solar Mithril Date: Mon, 13 Oct 2025 20:49:31 +0400 Subject: [PATCH 2/5] profile for flamegraph --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d825a03..08fb8d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,7 @@ default-members = ["crates/rproxy"] members = [ "crates/rproxy", ] + +[profile.flamegraph] +inherits = "release" +debug = true \ No newline at end of file From 6bc167c2150419a39747eacd02a752e3b564decb Mon Sep 17 00:00:00 2001 From: Solar Mithril Date: Mon, 13 Oct 2025 21:44:44 +0400 Subject: [PATCH 3/5] profile for flamegraph --- crates/rproxy/src/metrics/metrics.rs | 9 +-------- crates/rproxy/src/proxy_http/proxy_http.rs | 10 ++++++++-- crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs | 2 +- crates/rproxy/src/proxy_ws/proxy_ws.rs | 9 +-------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/crates/rproxy/src/metrics/metrics.rs b/crates/rproxy/src/metrics/metrics.rs index 0b7320c..3561f15 100644 --- a/crates/rproxy/src/metrics/metrics.rs +++ b/crates/rproxy/src/metrics/metrics.rs @@ -1,13 +1,6 @@ use std::{net::TcpListener, sync::Arc, time::Duration}; -use actix_web::{ - App, - HttpRequest, - HttpResponse, - HttpServer, - middleware::NormalizePath, - web, -}; +use actix_web::{App, HttpRequest, HttpResponse, HttpServer, middleware::NormalizePath, web}; use awc::http::Method; use prometheus_client::{ metrics::{counter::Counter, family::Family, gauge::Gauge}, diff --git a/crates/rproxy/src/proxy_http/proxy_http.rs b/crates/rproxy/src/proxy_http/proxy_http.rs index 63ccf52..160a82b 100644 --- a/crates/rproxy/src/proxy_http/proxy_http.rs +++ b/crates/rproxy/src/proxy_http/proxy_http.rs @@ -250,10 +250,16 @@ where socket.set_tcp_keepalive( &socket2::TcpKeepalive::new() .with_time( - config.idle_connection_timeout().checked_div(TCP_KEEPALIVE_ATTEMPTS).expect("duration is not zero"), + config + .idle_connection_timeout() + .checked_div(TCP_KEEPALIVE_ATTEMPTS) + .expect("duration is not zero"), ) .with_interval( - config.idle_connection_timeout().checked_div(TCP_KEEPALIVE_ATTEMPTS).expect("duration is not zero"), + config + .idle_connection_timeout() + .checked_div(TCP_KEEPALIVE_ATTEMPTS) + .expect("duration is not zero"), ) .with_retries(TCP_KEEPALIVE_ATTEMPTS - 1), )?; diff --git a/crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs b/crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs index f5da0c8..46af948 100644 --- a/crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs +++ b/crates/rproxy/src/proxy_http/proxy_http_inner_rpc.rs @@ -47,7 +47,7 @@ impl ProxyHttpInner for ProxyHttpInnerRpc { return false; } - return mirror_errored_requests || jrpc_res.error.is_none() + return mirror_errored_requests || jrpc_res.error.is_none(); } match jrpc_req { diff --git a/crates/rproxy/src/proxy_ws/proxy_ws.rs b/crates/rproxy/src/proxy_ws/proxy_ws.rs index 4630a6c..8b48731 100644 --- a/crates/rproxy/src/proxy_ws/proxy_ws.rs +++ b/crates/rproxy/src/proxy_ws/proxy_ws.rs @@ -10,14 +10,7 @@ use std::{ }; use actix::{Actor, AsyncContext, WrapFuture}; -use actix_web::{ - App, - HttpRequest, - HttpResponse, - HttpServer, - middleware::NormalizePath, - web, -}; +use actix_web::{App, HttpRequest, HttpResponse, HttpServer, middleware::NormalizePath, web}; use actix_ws::{MessageStream, Session}; use bytes::{Buf, BufMut, Bytes, BytesMut}; use futures::{ From 87c3df3111a35c5af6cd4aaf8df044e58dd2f393 Mon Sep 17 00:00:00 2001 From: Solar Mithril Date: Mon, 13 Oct 2025 21:48:24 +0400 Subject: [PATCH 4/5] return valuable version --- crates/rproxy/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rproxy/Cargo.toml b/crates/rproxy/Cargo.toml index c553a49..a6aa97d 100644 --- a/crates/rproxy/Cargo.toml +++ b/crates/rproxy/Cargo.toml @@ -49,6 +49,6 @@ tracing-subscriber = { version = "0.3.20", features = ["env-filter", "json", "va tungstenite = { version = "0.27.0", features = ["handshake"] } url = "2.5.7" uuid = { version = "1.18.1", features = ["v7" ]} -valuable = { version = "0.1.0", features = ["derive"] } +valuable = { version = "0.1.1", features = ["derive"] } x509-parser = "0.18.0" zstd = "0.13.3" From 92ac22de79646bdcfa5c290cbaf498386584f800 Mon Sep 17 00:00:00 2001 From: Solar Mithril Date: Mon, 13 Oct 2025 21:48:50 +0400 Subject: [PATCH 5/5] EOL --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 08fb8d2..8abf898 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ members = [ [profile.flamegraph] inherits = "release" -debug = true \ No newline at end of file +debug = true