docs(design): VirtualTag/script memory scalability (A0+A+guardrail; C2 deferred) + measurement harness
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<!-- Throwaway memory probe: keep build noise low. -->
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Closure of THIS assembly = {LeanContext, Core.Abstractions}. No Roslyn. -->
|
||||
<ProjectReference Include="..\..\..\src\Core\ZB.MOM.WW.OtOpcUa.Core.Abstractions\ZB.MOM.WW.OtOpcUa.Core.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
|
||||
namespace LeanContext;
|
||||
|
||||
/// <summary>
|
||||
/// LEAN globals type for the memory probe. Its transitive reference closure is only
|
||||
/// {LeanContext, Core.Abstractions} — deliberately NO Roslyn — so the per-script cost
|
||||
/// of the Roslyn reference-manager loading the globalsType's closure (dotnet/roslyn#22219)
|
||||
/// can be measured against the heavy <c>VirtualTagContext</c>, whose closure pulls in
|
||||
/// Microsoft.CodeAnalysis.CSharp.Scripting.
|
||||
/// <para>
|
||||
/// <see cref="GetTag"/> returns the same <see cref="DataValueSnapshot"/> type that
|
||||
/// <c>VirtualTagContext.GetTag</c> returns, so the probe's script source
|
||||
/// (<c>ctx.GetTag("x").Value</c>) is byte-identical for both modes — the ONLY
|
||||
/// difference is which assembly closure the globalsType lives in.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class LeanCtx
|
||||
{
|
||||
private readonly System.Collections.Generic.Dictionary<string, DataValueSnapshot> _d = new();
|
||||
|
||||
public DataValueSnapshot GetTag(string p) =>
|
||||
_d.TryGetValue(p, out var v) ? v : new DataValueSnapshot(null, 0u, null, default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LEAN analogue of the prod <c>ScriptGlobals<TContext></c> wrapper: exposes a
|
||||
/// named <c>ctx</c> property so the script source can be byte-identical to the heavy
|
||||
/// path (<c>ctx.GetTag(...).Value</c>). Lives in the LeanContext assembly, so its
|
||||
/// reference closure is {LeanContext, Core.Abstractions} — NO Roslyn. This is the A0
|
||||
/// "globals type in a lean assembly" treatment.
|
||||
/// </summary>
|
||||
public sealed class LeanGlobals
|
||||
{
|
||||
public LeanCtx ctx { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user