perf(adminui): /hosts rebuilds driver rows on the tick, not per health publish (R04 P4)
OnSnapshotChanged used to re-project every cluster group and re-render the whole page for each driver publish, per open tab. It now only marks a CoalescingDirtyFlag; the 5 s tick rebuilds when the flag is set or the config load changed (or evicted) anything. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Hosts;
|
||||
|
||||
/// <summary>
|
||||
/// A thread-safe "something changed since you last looked" flag. A high-rate producer (the driver
|
||||
/// health store raises once per driver per publish, on the bridge actor's thread) calls
|
||||
/// <see cref="Mark"/>, which is cheap and never renders; the page's own periodic tick calls
|
||||
/// <see cref="TryConsume"/> and does the expensive re-projection + render at most once per tick,
|
||||
/// however many marks arrived in between.
|
||||
/// </summary>
|
||||
public sealed class CoalescingDirtyFlag
|
||||
{
|
||||
private int _dirty;
|
||||
|
||||
/// <summary>Records that the underlying data changed. Safe from any thread.</summary>
|
||||
public void Mark() => Volatile.Write(ref _dirty, 1);
|
||||
|
||||
/// <summary>Returns whether anything was marked since the last call, and clears the flag.</summary>
|
||||
/// <returns><see langword="true"/> when at least one <see cref="Mark"/> happened since the last consume.</returns>
|
||||
public bool TryConsume() => Interlocked.Exchange(ref _dirty, 0) == 1;
|
||||
}
|
||||
Reference in New Issue
Block a user