20260618 增加PP缓存命中路径性能埋点
This commit is contained in:
@@ -242,11 +242,15 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
{
|
||||
Ok(Some(projection)) => projection,
|
||||
Ok(None) => {
|
||||
self.record_publication_point_cache_miss("missing_projection");
|
||||
self.finish_publication_point_cache_miss(ca, "missing_projection", lookup_started);
|
||||
return None;
|
||||
}
|
||||
Err(e) => {
|
||||
self.record_publication_point_cache_miss("projection_load_error");
|
||||
self.finish_publication_point_cache_miss(
|
||||
ca,
|
||||
"projection_load_error",
|
||||
lookup_started,
|
||||
);
|
||||
crate::progress_log::emit(
|
||||
"publication_point_cache_lookup_error",
|
||||
serde_json::json!({
|
||||
@@ -261,37 +265,37 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
let current_identity = match self.current_publication_point_cache_identity(ca) {
|
||||
Ok(identity) => identity,
|
||||
Err(reason) => {
|
||||
self.record_publication_point_cache_miss(reason.as_str());
|
||||
self.finish_publication_point_cache_miss(ca, reason.as_str(), lookup_started);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
if projection.ca_cert_uri != ca.ca_certificate_rsync_uri {
|
||||
self.record_publication_point_cache_miss("ca_uri_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "ca_uri_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.ca_cert_sha256 != current_identity.ca_cert_sha256 {
|
||||
self.record_publication_point_cache_miss("ca_hash_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "ca_hash_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.manifest_sha256 != current_identity.manifest_sha256 {
|
||||
self.record_publication_point_cache_miss("manifest_hash_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "manifest_hash_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.tal_id != ca.tal_id {
|
||||
self.record_publication_point_cache_miss("tal_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "tal_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.ta_context_digest != current_identity.ta_context_digest {
|
||||
self.record_publication_point_cache_miss("ta_context_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "ta_context_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.parent_context_digest != current_identity.parent_context_digest {
|
||||
self.record_publication_point_cache_miss("parent_context_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "parent_context_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if projection.validation_policy_fingerprint != current_identity.policy_fingerprint {
|
||||
self.record_publication_point_cache_miss("policy_mismatch");
|
||||
self.finish_publication_point_cache_miss(ca, "policy_mismatch", lookup_started);
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -299,36 +303,47 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
match parse_snapshot_time_value(&projection.instance_effective_not_before) {
|
||||
Ok(value) => value,
|
||||
Err(_) => {
|
||||
self.record_publication_point_cache_miss("instance_not_before_invalid");
|
||||
self.finish_publication_point_cache_miss(
|
||||
ca,
|
||||
"instance_not_before_invalid",
|
||||
lookup_started,
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let instance_until = match parse_snapshot_time_value(&projection.instance_effective_until) {
|
||||
Ok(value) => value,
|
||||
Err(_) => {
|
||||
self.record_publication_point_cache_miss("instance_until_invalid");
|
||||
self.finish_publication_point_cache_miss(
|
||||
ca,
|
||||
"instance_until_invalid",
|
||||
lookup_started,
|
||||
);
|
||||
return None;
|
||||
}
|
||||
};
|
||||
if self.validation_time < instance_not_before || self.validation_time >= instance_until {
|
||||
self.record_publication_point_cache_miss("instance_time_gate_miss");
|
||||
self.finish_publication_point_cache_miss(ca, "instance_time_gate_miss", lookup_started);
|
||||
return None;
|
||||
}
|
||||
if let Err(reason) =
|
||||
publication_point_cache_projection_items_valid(&projection, self.validation_time)
|
||||
{
|
||||
self.record_publication_point_cache_miss(reason);
|
||||
self.finish_publication_point_cache_miss(ca, reason, lookup_started);
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
let lookup_nanos = lookup_started
|
||||
.elapsed()
|
||||
.as_nanos()
|
||||
.min(u128::from(u64::MAX)) as u64;
|
||||
timing.record_count("publication_point_cache_theoretical_hits", 1);
|
||||
timing.record_phase_nanos("publication_point_cache_lookup_total", lookup_nanos);
|
||||
timing.record_phase_nanos("publication_point_cache_lookup_hit_total", lookup_nanos);
|
||||
timing.record_phase_nanos(
|
||||
"publication_point_cache_lookup_total",
|
||||
lookup_started
|
||||
.elapsed()
|
||||
.as_nanos()
|
||||
.min(u128::from(u64::MAX)) as u64,
|
||||
"publication_point_cache_lookup_duration_total",
|
||||
lookup_nanos,
|
||||
);
|
||||
}
|
||||
if self.publication_point_cache_observe_only {
|
||||
@@ -364,6 +379,40 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn finish_publication_point_cache_miss(
|
||||
&self,
|
||||
ca: &CaInstanceHandle,
|
||||
reason: &str,
|
||||
lookup_started: std::time::Instant,
|
||||
) {
|
||||
self.record_publication_point_cache_miss(reason);
|
||||
let lookup_nanos = lookup_started
|
||||
.elapsed()
|
||||
.as_nanos()
|
||||
.min(u128::from(u64::MAX)) as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos("publication_point_cache_lookup_miss_total", lookup_nanos);
|
||||
timing.record_phase_nanos(
|
||||
"publication_point_cache_lookup_duration_total",
|
||||
lookup_nanos,
|
||||
);
|
||||
}
|
||||
let elapsed_ms = lookup_nanos / 1_000_000;
|
||||
if elapsed_ms >= crate::progress_log::pp_cache_slow_threshold_ms() {
|
||||
crate::progress_log::emit(
|
||||
"publication_point_cache_miss_slow",
|
||||
serde_json::json!({
|
||||
"manifest_rsync_uri": ca.manifest_rsync_uri.as_str(),
|
||||
"publication_point_rsync_uri": ca.publication_point_rsync_uri.as_str(),
|
||||
"ca_certificate_rsync_uri": ca.ca_certificate_rsync_uri.as_deref(),
|
||||
"reason": reason,
|
||||
"elapsed_ms": elapsed_ms,
|
||||
"slow_threshold_ms": crate::progress_log::pp_cache_slow_threshold_ms(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn record_publication_point_cache_miss(&self, reason: &str) {
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_count("publication_point_cache_miss_total", 1);
|
||||
@@ -371,21 +420,40 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
"missing_projection" => {
|
||||
timing.record_count("publication_point_cache_miss_missing_projection", 1)
|
||||
}
|
||||
"projection_load_error" => {
|
||||
timing.record_count("publication_point_cache_miss_projection_load_error", 1)
|
||||
}
|
||||
"current_manifest_missing" => {
|
||||
timing.record_count("publication_point_cache_miss_current_manifest_missing", 1)
|
||||
}
|
||||
"ca_uri_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_ca_uri_mismatch", 1)
|
||||
}
|
||||
"ca_hash_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_ca_hash_mismatch", 1)
|
||||
}
|
||||
"manifest_hash_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_manifest_hash_mismatch", 1)
|
||||
}
|
||||
"tal_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_tal_mismatch", 1)
|
||||
}
|
||||
"ta_context_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_ta_context_mismatch", 1)
|
||||
}
|
||||
"parent_context_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_parent_context_mismatch", 1)
|
||||
}
|
||||
"policy_mismatch" => {
|
||||
timing.record_count("publication_point_cache_miss_policy_mismatch", 1)
|
||||
}
|
||||
"instance_not_before_invalid" => timing.record_count(
|
||||
"publication_point_cache_miss_instance_not_before_invalid",
|
||||
1,
|
||||
),
|
||||
"instance_until_invalid" => {
|
||||
timing.record_count("publication_point_cache_miss_instance_until_invalid", 1)
|
||||
}
|
||||
"instance_time_gate_miss" => {
|
||||
timing.record_count("publication_point_cache_miss_instance_time_gate", 1)
|
||||
}
|
||||
@@ -395,6 +463,9 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
"child_time_gate_miss" => {
|
||||
timing.record_count("publication_point_cache_miss_child_time_gate", 1)
|
||||
}
|
||||
"reuse_build_error" => {
|
||||
timing.record_count("publication_point_cache_miss_reuse_build_error", 1)
|
||||
}
|
||||
_ => timing.record_count("publication_point_cache_miss_other", 1),
|
||||
}
|
||||
}
|
||||
@@ -447,13 +518,26 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
repo_sync_err: Option<&str>,
|
||||
warnings: &[Warning],
|
||||
) -> Result<PublicationPointRunResult, String> {
|
||||
let build_started = std::time::Instant::now();
|
||||
let mut warnings = warnings.to_vec();
|
||||
let output_reuse_count = projection.outputs.len() as u64;
|
||||
let child_reuse_count = projection.children.len() as u64;
|
||||
let related_object_reuse_count = projection.related_objects.len() as u64;
|
||||
let to_vcir_started = std::time::Instant::now();
|
||||
let mut vcir = projection.to_vcir_for_reuse(self.validation_time);
|
||||
let to_vcir_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_to_vcir_total",
|
||||
to_vcir_started,
|
||||
);
|
||||
vcir.parent_manifest_rsync_uri = ca.parent_manifest_rsync_uri.clone();
|
||||
let build_objects_started = std::time::Instant::now();
|
||||
let mut objects =
|
||||
build_objects_output_from_vcir(&vcir, self.validation_time, &mut warnings);
|
||||
let build_objects_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_build_objects_total",
|
||||
build_objects_started,
|
||||
);
|
||||
let restore_children_started = std::time::Instant::now();
|
||||
let (discovered_children, child_audits) = restore_children_from_publication_point_cache(
|
||||
self.store,
|
||||
ca,
|
||||
@@ -461,8 +545,18 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
self.validation_time,
|
||||
&mut warnings,
|
||||
);
|
||||
let restore_children_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_restore_children_total",
|
||||
restore_children_started,
|
||||
);
|
||||
let ccr_projection = projection.ccr_manifest_projection.clone();
|
||||
let ccr_append_started = std::time::Instant::now();
|
||||
self.append_ccr_manifest_projection(&ccr_projection)?;
|
||||
let ccr_append_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_ccr_append_total",
|
||||
ccr_append_started,
|
||||
);
|
||||
let audit_build_started = std::time::Instant::now();
|
||||
let audit = build_publication_point_audit_from_vcir(
|
||||
ca,
|
||||
PublicationPointSource::PublicationPointCache,
|
||||
@@ -477,11 +571,52 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
&child_audits,
|
||||
&[],
|
||||
);
|
||||
let audit_build_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_audit_build_total",
|
||||
audit_build_started,
|
||||
);
|
||||
let audit_object_count = audit.objects.len() as u64;
|
||||
let cir_cached_objects = audit.objects.clone();
|
||||
objects.local_outputs_cache.clear();
|
||||
let total_ms = self.record_publication_point_cache_phase_ms(
|
||||
"publication_point_cache_reuse_build_total",
|
||||
build_started,
|
||||
);
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_count("publication_point_cache_outputs_reused", output_reuse_count);
|
||||
timing.record_count("publication_point_cache_children_reused", child_reuse_count);
|
||||
timing.record_count(
|
||||
"publication_point_cache_related_objects_reused",
|
||||
related_object_reuse_count,
|
||||
);
|
||||
timing.record_count(
|
||||
"publication_point_cache_audit_objects_reused",
|
||||
audit_object_count,
|
||||
);
|
||||
}
|
||||
if total_ms >= crate::progress_log::pp_cache_slow_threshold_ms() {
|
||||
crate::progress_log::emit(
|
||||
"publication_point_cache_reuse_slow",
|
||||
serde_json::json!({
|
||||
"manifest_rsync_uri": ca.manifest_rsync_uri.as_str(),
|
||||
"publication_point_rsync_uri": ca.publication_point_rsync_uri.as_str(),
|
||||
"repo_sync_source": repo_sync_source,
|
||||
"repo_sync_phase": repo_sync_phase,
|
||||
"repo_sync_duration_ms": repo_sync_duration_ms,
|
||||
"repo_sync_err": repo_sync_err,
|
||||
"outputs_reused": output_reuse_count,
|
||||
"children_reused": child_reuse_count,
|
||||
"related_objects_reused": related_object_reuse_count,
|
||||
"audit_objects_reused": audit_object_count,
|
||||
"to_vcir_ms": to_vcir_ms,
|
||||
"build_objects_ms": build_objects_ms,
|
||||
"restore_children_ms": restore_children_ms,
|
||||
"ccr_append_ms": ccr_append_ms,
|
||||
"audit_build_ms": audit_build_ms,
|
||||
"total_ms": total_ms,
|
||||
"slow_threshold_ms": crate::progress_log::pp_cache_slow_threshold_ms(),
|
||||
}),
|
||||
);
|
||||
}
|
||||
Ok(PublicationPointRunResult {
|
||||
source: PublicationPointSource::PublicationPointCache,
|
||||
@@ -495,6 +630,18 @@ impl<'a> Rpkiv1PublicationPointRunner<'a> {
|
||||
})
|
||||
}
|
||||
|
||||
fn record_publication_point_cache_phase_ms(
|
||||
&self,
|
||||
phase: &'static str,
|
||||
started: std::time::Instant,
|
||||
) -> u64 {
|
||||
let nanos = started.elapsed().as_nanos().min(u128::from(u64::MAX)) as u64;
|
||||
if let Some(timing) = self.timing.as_ref() {
|
||||
timing.record_phase_nanos(phase, nanos);
|
||||
}
|
||||
nanos / 1_000_000
|
||||
}
|
||||
|
||||
pub(crate) fn ccr_accumulator_snapshot(&self) -> Option<CcrAccumulator> {
|
||||
self.ccr_accumulator
|
||||
.as_ref()
|
||||
|
||||
Reference in New Issue
Block a user