measurement: record the start of adaptive probing as a rate change

This commit is contained in:
justme committed 2026-10-22 10:57:53 +08:00
1 parent af385cf688
commit 20b0f7fbd8
2 files changed
+18

No files matched your search

@@ -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
});
}
/// <summary>
/// 自适应开始:记一条「start → watch」(从最高频率起步)。审计据此知道这个任务从什么时候起在自适应,
/// 没有这条之前的时段是「没有记录」,不是某个状态。
/// </summary>
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
@@ -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,