feat: add opt-in hotpath profiling (#5488)

* feat: add opt-in hotpath profiling

Co-Authored-By: heihutu <heihutu@gmail.com>

* test: fix vault kms client construction

Co-Authored-By: heihutu <heihutu@gmail.com>

---------

Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-07-31 01:49:19 +08:00
committed by GitHub
parent 1d3ba1eb8b
commit 7051a5ce41
18 changed files with 113 additions and 52 deletions
+13 -2
View File
@@ -53,18 +53,29 @@ pyroscope = ["rustfs-obs/pyroscope"]
# Tokio runtime telemetry. Requires `--cfg tokio_unstable`; use `make build-profiling`.
dial9 = ["rustfs-obs/dial9"]
hotpath = [
"dep:hotpath",
"hotpath/hotpath",
"hotpath/tokio",
"hotpath/futures",
"hotpath/async-channel",
"hotpath/crossbeam",
"hotpath/parking_lot",
"hotpath/reqwest-0-13",
"rustfs-ecstore/hotpath",
"rustfs-filemeta/hotpath",
"rustfs-rio/hotpath",
]
hotpath-alloc = [
"hotpath/hotpath-alloc",
"rustfs-ecstore/hotpath-alloc",
"rustfs-filemeta/hotpath-alloc",
"rustfs-rio/hotpath-alloc",
]
[lints]
workspace = true
[dependencies]
hotpath = { workspace = true, optional = true }
hotpath.workspace = true
# RustFS Internal Crates
rustfs-heal = { workspace = true }
rustfs-audit = { workspace = true }
+6 -13
View File
@@ -12,23 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#[cfg(all(feature = "hotpath", feature = "hotpath-alloc"))]
#[global_allocator]
static GLOBAL: hotpath::CountingAllocator = hotpath::CountingAllocator::new();
#[cfg(not(all(feature = "hotpath", feature = "hotpath-alloc")))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
fn main() {
// Wall-time profiling guard for `--features hotpath` builds. The guard
// lives for the whole process; dropping it on normal exit (SIGINT/SIGTERM
// unwind back through run_process) prints the timing report.
//
// hotpath's alloc mode is intentionally NOT wired up: hotpath 0.21.x
// panics when a MeasurementGuardSync drops on a different thread than it
// was created on (TLS index mismatch, alloc/core.rs:151), which tokio's
// work-stealing runtime does constantly. See rustfs/backlog#935.
#[cfg(feature = "hotpath")]
let _hotpath_guard = hotpath::HotpathGuardBuilder::new("main")
.percentiles(&[50.0, 95.0, 99.0])
.functions_limit(0)
.build();
let _hotpath_guard = hotpath::HotpathGuardBuilder::new("main").build();
rustfs::startup_entrypoint::run_process();
}
+2
View File
@@ -62,6 +62,8 @@ fn emit_fatal_stderr(context: &str, error: impl std::fmt::Display) {
}
async fn async_main() -> Result<()> {
hotpath::tokio_runtime!();
let env_compat_report = bootstrap_external_prefix_compat()?;
// Parse command line arguments