perf(runtime): O(1) attribute resolution, precomputed types, coalesced static writes, shared JSON options

This commit is contained in:
Joseph Doherty
2026-08-14 19:57:26 -04:00
parent ee193cd2bb
commit 125055d998
7 changed files with 350 additions and 83 deletions
@@ -17,6 +17,15 @@ public static class ManagementEndpoints
{
private static readonly TimeSpan DefaultAskTimeout = TimeSpan.FromSeconds(30);
/// <summary>
/// Shared options for the per-request command payload JSON parse in
/// <see cref="ParseCommand"/> (perf remediation, arch-review WP1.5) — avoids
/// allocating a new <see cref="JsonSerializerOptions"/> per inbound management
/// request. Settings preserved exactly.
/// </summary>
private static readonly JsonSerializerOptions CommandPayloadJsonOptions =
new() { PropertyNameCaseInsensitive = true };
/// <summary>
/// Resolves the ManagementActor Ask timeout from configuration.
/// Falls back to <see cref="DefaultAskTimeout"/>
@@ -197,7 +206,7 @@ public static class ManagementEndpoints
? p.GetRawText()
: "{}";
var command = JsonSerializer.Deserialize(payloadJson, commandType,
new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!;
CommandPayloadJsonOptions)!;
return CommandParseResult.Ok(command);
}
catch (Exception ex)