perf(storage): optimize internode RPC transfer path (#2262)

Co-authored-by: momoda693 <momoda693@gmail.com>
This commit is contained in:
weisd
2026-03-23 17:09:49 +08:00
committed by GitHub
parent 236142a682
commit 05dc131a49
43 changed files with 1846 additions and 566 deletions
@@ -467,6 +467,10 @@ pub struct UpdateMetadataRequest {
pub file_info: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub opts: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "6")]
pub file_info_bin: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "7")]
pub opts_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct UpdateMetadataResponse {
@@ -486,6 +490,8 @@ pub struct WriteMetadataRequest {
pub path: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
pub file_info: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "5")]
pub file_info_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct WriteMetadataResponse {
@@ -506,6 +512,8 @@ pub struct ReadVersionRequest {
pub version_id: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
pub opts: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "6")]
pub opts_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ReadVersionResponse {
@@ -515,6 +523,8 @@ pub struct ReadVersionResponse {
pub file_info: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
#[prost(bytes = "vec", tag = "4")]
pub file_info_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ReadXlRequest {
@@ -535,6 +545,8 @@ pub struct ReadXlResponse {
pub raw_file_info: ::prost::alloc::string::String,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
#[prost(bytes = "vec", tag = "4")]
pub raw_file_info_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteVersionRequest {
@@ -586,6 +598,8 @@ pub struct ReadMultipleRequest {
pub disk: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub read_multiple_req: ::prost::alloc::string::String,
#[prost(bytes = "vec", tag = "3")]
pub read_multiple_req_bin: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ReadMultipleResponse {
@@ -595,6 +609,8 @@ pub struct ReadMultipleResponse {
pub read_multiple_resps: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, optional, tag = "3")]
pub error: ::core::option::Option<Error>,
#[prost(bytes = "vec", repeated, tag = "4")]
pub read_multiple_resps_bin: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct DeleteVolumeRequest {
+18 -3
View File
@@ -16,8 +16,13 @@
mod generated;
use proto_gen::node_service::node_service_client::NodeServiceClient;
use rustfs_common::{GLOBAL_CONN_MAP, GLOBAL_MTLS_IDENTITY, GLOBAL_ROOT_CERT, evict_connection};
use std::{error::Error, time::Duration};
use rustfs_common::{
GLOBAL_CONN_MAP, GLOBAL_MTLS_IDENTITY, GLOBAL_ROOT_CERT, evict_connection, internode_metrics::global_internode_metrics,
};
use std::{
error::Error,
time::{Duration, Instant},
};
use tonic::{
Request, Status,
service::interceptor::InterceptedService,
@@ -65,6 +70,7 @@ const RUSTFS_HTTPS_PREFIX: &str = "https://";
/// - Overall RPC timeout of 30s (reduced from 60s)
pub async fn create_new_channel(addr: &str) -> Result<Channel, Box<dyn Error>> {
debug!("Creating new gRPC channel to: {}", addr);
let dial_started_at = Instant::now();
let mut connector = Endpoint::from_shared(addr.to_string())?
// Fast connection timeout for dead peer detection
@@ -119,7 +125,16 @@ pub async fn create_new_channel(addr: &str) -> Result<Channel, Box<dyn Error>> {
}
}
let channel = connector.connect().await?;
let channel = match connector.connect().await {
Ok(channel) => {
global_internode_metrics().record_dial_result(dial_started_at.elapsed(), true);
channel
}
Err(err) => {
global_internode_metrics().record_dial_result(dial_started_at.elapsed(), false);
return Err(err.into());
}
};
// Cache the new connection
{
+8
View File
@@ -331,6 +331,8 @@ message UpdateMetadataRequest {
string path = 3;
string file_info = 4;
string opts = 5;
bytes file_info_bin = 6;
bytes opts_bin = 7;
}
message UpdateMetadataResponse {
@@ -343,6 +345,7 @@ message WriteMetadataRequest {
string volume = 2;
string path = 3;
string file_info = 4;
bytes file_info_bin = 5;
}
message WriteMetadataResponse {
@@ -356,12 +359,14 @@ message ReadVersionRequest {
string path = 3;
string version_id = 4;
string opts = 5;
bytes opts_bin = 6;
}
message ReadVersionResponse {
bool success = 1;
string file_info = 2;
optional Error error = 3;
bytes file_info_bin = 4;
}
message ReadXLRequest {
@@ -375,6 +380,7 @@ message ReadXLResponse {
bool success = 1;
string raw_file_info = 2;
optional Error error = 3;
bytes raw_file_info_bin = 4;
}
message DeleteVersionRequest {
@@ -408,12 +414,14 @@ message DeleteVersionsResponse {
message ReadMultipleRequest {
string disk = 1;
string read_multiple_req = 2;
bytes read_multiple_req_bin = 3;
}
message ReadMultipleResponse {
bool success = 1;
repeated string read_multiple_resps = 2;
optional Error error = 3;
repeated bytes read_multiple_resps_bin = 4;
}
message DeleteVolumeRequest {