From e06c9c02c63186acf1a5bb2283eb2ab7bd905169 Mon Sep 17 00:00:00 2001 From: houseme Date: Fri, 31 Jul 2026 09:59:13 +0800 Subject: [PATCH] feat: add hotpath primitive profiling coverage (#5492) * chore(deps): refresh google cloud dependencies Co-Authored-By: heihutu * feat: add hotpath primitive coverage Co-Authored-By: heihutu * feat: extend hotpath profiling features Co-Authored-By: heihutu * fix: gate OPA hotpath client wrapping Co-Authored-By: heihutu * fix: avoid request-scoped hotpath primitive wrappers Preserve the original bounded channel and stream semantics in EC and RIO request paths while keeping hotpath CPU profiling as a separate opt-in feature that implies base hotpath instrumentation. Co-Authored-By: heihutu --------- Co-authored-by: heihutu --- Cargo.lock | 77 +++++++++++++++++++-------------- Cargo.toml | 4 +- crates/ecstore/Cargo.toml | 6 +++ crates/filemeta/Cargo.toml | 1 + crates/policy/Cargo.toml | 7 +++ crates/policy/src/policy/opa.rs | 10 ++++- crates/rio/Cargo.toml | 1 + rustfs/Cargo.toml | 10 +++++ 8 files changed, 81 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5bd0f4e1..97584df3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1528,7 +1528,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.9", + "generic-array 0.14.7", ] [[package]] @@ -1547,7 +1547,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93" dependencies = [ - "generic-array 0.14.9", + "generic-array 0.14.7", ] [[package]] @@ -1598,7 +1598,7 @@ version = "3.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dee98b0db6a962de883bf5d20362dee4d7ca0d12fe39a7c6c73c844e1cd7c1f" dependencies = [ - "darling 0.23.0", + "darling 0.20.11", "ident_case", "prettyplease", "proc-macro2", @@ -1870,7 +1870,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "crypto-common 0.1.6", + "crypto-common 0.1.7", "inout 0.1.4", ] @@ -2328,7 +2328,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "generic-array 0.14.9", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -2353,11 +2353,11 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ - "generic-array 0.14.9", + "generic-array 0.14.7", "typenum", ] @@ -3554,7 +3554,7 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "const-oid 0.9.6", - "crypto-common 0.1.6", + "crypto-common 0.1.7", "subtle", ] @@ -3813,7 +3813,7 @@ dependencies = [ "crypto-bigint 0.5.5", "digest 0.10.7", "ff 0.13.1", - "generic-array 0.14.9", + "generic-array 0.14.7", "group 0.13.0", "hkdf 0.12.4", "pem-rfc7468 0.7.0", @@ -4258,9 +4258,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.9" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -4273,7 +4273,7 @@ version = "1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab4e5aa225bc56696909483320f0ff9b600f1a971b52e07a17d70f3d9b43254b" dependencies = [ - "generic-array 0.14.9", + "generic-array 0.14.7", "rustversion", "typenum", ] @@ -4372,9 +4372,9 @@ dependencies = [ [[package]] name = "google-cloud-auth" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3494870d06f3cbbb3561ada6f234982549e3a2fb31e719ef258e6eadb9ae09a" +checksum = "f54aab44c16b8463ae11b165a87c3d484780231f157bb1ed65843d591beb5abd" dependencies = [ "async-trait", "aws-lc-rs", @@ -4401,9 +4401,9 @@ dependencies = [ [[package]] name = "google-cloud-gax" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3103a4a9013f1aed573ca56e19a9680b0211643a99ea85caf524b397d6be8be3" +checksum = "b9a46dd0fd026bbc4a5d84e6ab0c941cee6e3b057976a0bb107fdb5238ce598f" dependencies = [ "bytes", "futures", @@ -4420,9 +4420,9 @@ dependencies = [ [[package]] name = "google-cloud-gax-internal" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0df265fba091ed7e00ecd0755009423310163f8b52820f007b6b4d97f4c6617" +checksum = "fb04c54317ace06d489213f761797240b3046142a9b7ce6b9a82a9d134e193d1" dependencies = [ "bytes", "futures", @@ -4524,9 +4524,9 @@ dependencies = [ [[package]] name = "google-cloud-storage" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b1d78c88db5c2530b12461e373a7d0d3a6caa3f6c1fc14e5d824cf2aeb307" +checksum = "9227f65175fa91a6e41f246797917697efdadfe09dd8ea84ad8b737a71efbd28" dependencies = [ "async-trait", "base64 0.22.1", @@ -4577,9 +4577,9 @@ dependencies = [ [[package]] name = "google-cloud-wkt" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46df1fcc3ab69164af3f4199ed21f45b5dbc56d9f03211eb4fa20116d442364b" +checksum = "7fccf98cfd5481a5f5a285181ab0c62123d7d47cd2bb7299448440649349e4e7" dependencies = [ "base64 0.22.1", "bytes", @@ -4920,6 +4920,7 @@ dependencies = [ "async-trait", "cfg-if", "crossbeam-channel", + "flate2", "futures-channel", "futures-util", "hdrhistogram", @@ -4927,6 +4928,7 @@ dependencies = [ "hotpath-meta", "http 1.5.0", "libc", + "object 0.36.7", "parking_lot", "pin-project-lite", "prettytable-rs", @@ -4934,6 +4936,7 @@ dependencies = [ "regex", "reqwest", "reqwest-middleware", + "rustc-demangle", "serde", "serde_json", "tiny_http", @@ -5047,9 +5050,9 @@ checksum = "15cdd26707701c53297e2fa6afb323d55fbc1d0810c3aec078ae3ef0424c3c15" [[package]] name = "hybrid-array" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818356c5132c1fede50f837ca96afbe78ff42413047f4abb886217845e1b6c8c" +checksum = "707114b52a152fa7bdb290cd7cd5912d9467273b6d74e21b8d81aca1f8533f6b" dependencies = [ "ctutils", "subtle", @@ -5297,7 +5300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ "block-padding 0.3.3", - "generic-array 0.14.9", + "generic-array 0.14.7", ] [[package]] @@ -6807,6 +6810,15 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + [[package]] name = "object" version = "0.37.3" @@ -7844,7 +7856,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" dependencies = [ "heck", - "itertools 0.10.5", + "itertools 0.13.0", "log", "multimap", "once_cell", @@ -7864,7 +7876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042" dependencies = [ "heck", - "itertools 0.10.5", + "itertools 0.13.0", "log", "multimap", "petgraph 0.8.3", @@ -7885,7 +7897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.119", @@ -7898,7 +7910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.119", @@ -9716,6 +9728,7 @@ dependencies = [ "base64-simd", "chrono", "futures", + "hotpath", "ipnetwork", "jsonwebtoken 11.0.0", "moka", @@ -10550,7 +10563,7 @@ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", "der 0.7.10", - "generic-array 0.14.9", + "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", "zeroize", @@ -11540,7 +11553,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.3", "once_cell", "rustix", "windows-sys 0.61.2", diff --git a/Cargo.toml b/Cargo.toml index 1b5bbe8b9..112df1c40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -250,8 +250,8 @@ enumset = "1.1.14" faster-hex = "0.10.0" flate2 = "1.1.9" glob = "0.3.4" -google-cloud-storage = "1.16.0" -google-cloud-auth = "1.14.0" +google-cloud-storage = "1.17.0" +google-cloud-auth = "1.15.0" hashbrown = { version = "0.17.1" } hex = "0.4.3" hex-simd = "0.8.0" diff --git a/crates/ecstore/Cargo.toml b/crates/ecstore/Cargo.toml index 3b6ce2ce8..726c5f2a2 100644 --- a/crates/ecstore/Cargo.toml +++ b/crates/ecstore/Cargo.toml @@ -48,6 +48,12 @@ hotpath-alloc = [ "rustfs-filemeta/hotpath-alloc", "rustfs-rio/hotpath-alloc", ] +hotpath-cpu = [ + "hotpath", + "hotpath/hotpath-cpu", + "rustfs-filemeta/hotpath-cpu", + "rustfs-rio/hotpath-cpu", +] # Exposes shared lifecycle/tier test utilities (MockWarmBackend, fault # injection, xl.meta transition assertions) via `api::tier::test_util`. # Enable only from `[dev-dependencies]` (rustfs/backlog#1148 ilm-6). diff --git a/crates/filemeta/Cargo.toml b/crates/filemeta/Cargo.toml index 3fdea23e0..f1d2bbad2 100644 --- a/crates/filemeta/Cargo.toml +++ b/crates/filemeta/Cargo.toml @@ -29,6 +29,7 @@ documentation = "https://docs.rs/rustfs-filemeta/latest/rustfs_filemeta/" default = [] hotpath = ["hotpath/hotpath", "hotpath/tokio"] hotpath-alloc = ["hotpath/hotpath-alloc"] +hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"] [dependencies] hotpath.workspace = true diff --git a/crates/policy/Cargo.toml b/crates/policy/Cargo.toml index 6d10ac82d..b85ded8b5 100644 --- a/crates/policy/Cargo.toml +++ b/crates/policy/Cargo.toml @@ -28,6 +28,12 @@ documentation = "https://docs.rs/rustfs-policy/latest/rustfs_policy/" [lints] workspace = true +[features] +default = [] +hotpath = ["hotpath/hotpath", "hotpath/reqwest-0-13"] +hotpath-alloc = ["hotpath/hotpath-alloc"] +hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"] + [dependencies] rustfs-credentials = { workspace = true } rustfs-config = { workspace = true, features = ["opa"] } @@ -49,6 +55,7 @@ moka = { workspace = true, features = ["future"] } async-trait.workspace = true futures.workspace = true pollster.workspace = true +hotpath.workspace = true [dev-dependencies] pollster.workspace = true diff --git a/crates/policy/src/policy/opa.rs b/crates/policy/src/policy/opa.rs index be2e033a8..5ff6e3ea0 100644 --- a/crates/policy/src/policy/opa.rs +++ b/crates/policy/src/policy/opa.rs @@ -32,10 +32,15 @@ impl Args { #[derive(Debug, Clone)] pub struct AuthZPlugin { - client: reqwest::Client, + client: OpaHttpClient, args: Args, } +#[cfg(feature = "hotpath")] +type OpaHttpClient = hotpath::wrap::reqwest::Client; +#[cfg(not(feature = "hotpath"))] +type OpaHttpClient = reqwest::Client; + #[derive(Debug, thiserror::Error)] pub enum OpaConfigError { #[error("Missing required env var: {0}")] @@ -141,6 +146,9 @@ impl AuthZPlugin { reqwest::Client::new() }); + #[cfg(feature = "hotpath")] + let client = hotpath::http!(client, label = "Policy::OPA"); + Self { client, args: config } } diff --git a/crates/rio/Cargo.toml b/crates/rio/Cargo.toml index c0b7b52d6..4d0f3916e 100644 --- a/crates/rio/Cargo.toml +++ b/crates/rio/Cargo.toml @@ -32,6 +32,7 @@ workspace = true default = [] hotpath = ["hotpath/hotpath", "hotpath/tokio", "hotpath/futures", "hotpath/reqwest-0-13"] hotpath-alloc = ["hotpath/hotpath-alloc"] +hotpath-cpu = ["hotpath", "hotpath/hotpath-cpu"] [dependencies] hotpath.workspace = true diff --git a/rustfs/Cargo.toml b/rustfs/Cargo.toml index cbef7e4f0..53db5ca19 100644 --- a/rustfs/Cargo.toml +++ b/rustfs/Cargo.toml @@ -62,14 +62,24 @@ hotpath = [ "hotpath/reqwest-0-13", "rustfs-ecstore/hotpath", "rustfs-filemeta/hotpath", + "rustfs-policy/hotpath", "rustfs-rio/hotpath", ] hotpath-alloc = [ "hotpath/hotpath-alloc", "rustfs-ecstore/hotpath-alloc", "rustfs-filemeta/hotpath-alloc", + "rustfs-policy/hotpath-alloc", "rustfs-rio/hotpath-alloc", ] +hotpath-cpu = [ + "hotpath", + "hotpath/hotpath-cpu", + "rustfs-ecstore/hotpath-cpu", + "rustfs-filemeta/hotpath-cpu", + "rustfs-policy/hotpath-cpu", + "rustfs-rio/hotpath-cpu", +] [lints] workspace = true