From 20b0f7fbd8f6454f637cfc9d4561ba62d7d3c44c Mon Sep 17 00:00:00 2001 From: justme Date: Thu, 22 Oct 2026 10:57:53 +0800 Subject: [PATCH] measurement: record the start of adaptive probing as a rate change --- .../MoShiro.Measurement/Blocks/BlockBase.cs | 17 +++++++++++++++++ .../shared/MoShiro.Measurement/Blocks/Http.cs | 1 + 2 files changed, 18 insertions(+) diff --git a/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs b/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs index 4c5ebd5..abe8035 100644 --- a/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs +++ b/backend/shared/MoShiro.Measurement/Blocks/BlockBase.cs @@ -85,6 +85,7 @@ public abstract class BlockBase : IBlock } double max = Math.Max(Spec.Int("rate_max_hz"), Spec.Int("rate_min_hz")); + ReportStart(max); return new AdaptiveRate(new AdaptiveRateOptions { MinHz = Spec.Int("rate_min_hz"), @@ -95,6 +96,22 @@ public abstract class BlockBase : IBlock }); } + /// + /// 自适应开始:记一条「start → watch」(从最高频率起步)。审计据此知道这个任务从什么时候起在自适应, + /// 没有这条之前的时段是「没有记录」,不是某个状态。 + /// + protected void ReportStart(double hz) => + Env.OnRateChange?.Invoke(new RateChange + { + AtMs = Env.Time.GetUtcNow().ToUnixTimeMilliseconds(), + Task = Spec.Scope.Task?.Value, + Kind = Spec.KindId, + From = "start", + To = "watch", + Hz = Math.Round(hz, 3), + Reason = "start", + }); + private void LogTransition(ProbeTransition change) { Env.OnRateChange?.Invoke(new RateChange diff --git a/backend/shared/MoShiro.Measurement/Blocks/Http.cs b/backend/shared/MoShiro.Measurement/Blocks/Http.cs index 1a2c630..29c7e54 100644 --- a/backend/shared/MoShiro.Measurement/Blocks/Http.cs +++ b/backend/shared/MoShiro.Measurement/Blocks/Http.cs @@ -143,6 +143,7 @@ public sealed class HttpDialer : BlockBase } double max = Math.Max(Spec.Int("rate_max_per_min"), Spec.Int("rate_min_per_min")) / 60.0; + ReportStart(max); return new AdaptiveRate(new AdaptiveRateOptions { MinHz = Spec.Int("rate_min_per_min") / 60.0,