diff --git a/eden/mononoke/mononoke_types/Cargo.toml b/eden/mononoke/mononoke_types/Cargo.toml index 781f8f87064d5..41fba5a86a94c 100644 --- a/eden/mononoke/mononoke_types/Cargo.toml +++ b/eden/mononoke/mononoke_types/Cargo.toml @@ -48,6 +48,7 @@ sapling-xdiff = { version = "0.1.0", path = "../../scm/lib/xdiff" } serde = { version = "1.0.185", features = ["derive", "rc"] } serde_derive = "1.0.185" sha1 = "0.10.5" +slog = { version = "2.7", features = ["max_level_trace", "nested-values"] } smallvec = { version = "1.6.1", features = ["serde", "specialization", "union"] } sorted_vector_map = { version = "0.2.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" } sql = { version = "0.1.0", git = "https://github.com/facebookexperimental/rust-shed.git", branch = "main" } diff --git a/eden/mononoke/mononoke_types/src/typed_hash.rs b/eden/mononoke/mononoke_types/src/typed_hash.rs index 39067c6ed67b6..ae403dc9d566e 100644 --- a/eden/mononoke/mononoke_types/src/typed_hash.rs +++ b/eden/mononoke/mononoke_types/src/typed_hash.rs @@ -23,6 +23,7 @@ use edenapi_types::BonsaiChangesetId as EdenapiBonsaiChangesetId; use edenapi_types::CommitId as EdenapiCommitId; use edenapi_types::ContentId as EdenapiContentId; use edenapi_types::FsnodeId as EdenapiFsnodeId; +pub use slog; use sql::mysql; use crate::basename_suffix_skeleton_manifest_v3::BssmV3Directory; @@ -57,6 +58,8 @@ use crate::unode::FileUnode; use crate::unode::ManifestUnode; use crate::ThriftConvert; +pub const SLOW_DESERIAZLIZATION_THRESHOLD_MS: u128 = 100; + // There is no NULL_HASH for typed hashes. Any places that need a null hash should use an // Option type, or perhaps a list as desired. @@ -440,9 +443,17 @@ macro_rules! impl_typed_hash_loadable { let blobstore_key = id.blobstore_key(); let get = blobstore.get(ctx, &blobstore_key); - let bytes = get.await?.ok_or(LoadableError::Missing(blobstore_key))?; + let bytes = get.await?.ok_or(LoadableError::Missing(blobstore_key.clone()))?; + + let now = std::time::Instant::now(); let blob: Blob<$typed> = Blob::new(id, bytes.into_raw_bytes()); - ::from_blob(blob).map_err(LoadableError::Error) + let len = blob.len(); + let ret = ::from_blob(blob).map_err(LoadableError::Error); + let diff = now.elapsed().as_millis(); + if diff > $crate::typed_hash::SLOW_DESERIAZLIZATION_THRESHOLD_MS { + $crate::typed_hash::slog::warn!(ctx.logger(), "Slow load of {} ({} bytes) took {:?}", blobstore_key, len, now.elapsed()); + } + ret } }