Files
ScadaBridge/src/ZB.MOM.WW.ScadaBridge.Host/ZB.MOM.WW.ScadaBridge.Host.csproj
T
Joseph Doherty b47002b45e perf(host): cap thread-pool spin (UnfairSemaphoreSpinLimit=10) (#146)
Mirror of mxaccessgw#237 (659bb831). DEV vd03 showed 229k context switches
in ZB.MOM.WW.ScadaBridge.Host at ~240 MxGateway events/s. Akka's default
dispatcher, gRPC/Kestrel and async continuations all run on the .NET thread
pool, so a trickle of small work items makes idle pool workers spin with
Sleep(0) (default limit 70) before parking.

- Host csproj: RuntimeHostConfigurationOption
  System.Threading.ThreadPool.UnfairSemaphoreSpinLimit=10, written into
  ZB.MOM.WW.ScadaBridge.Host.runtimeconfig.json (verified in the publish
  output, which docker/Dockerfile copies into the image).
- RuntimeConfigTests pins the value in the built runtimeconfig.
- Component-Host.md: new "Runtime thread-pool settings" section (what, why,
  override/revert via DOTNET_ThreadPool_UnfairSemaphoreSpinLimit).

Local synthetic trickle bench (macOS, ~185 chains/s): involuntary context
switches 17-28k -> 6-13k, CPU 430-560 -> 200-295 ms per 20 s. The vd03
before/after WPR measurement is pending the next vd03 deploy.
2026-11-28 09:15:20 -05:00

93 lines
6.3 KiB
XML

<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="ZB.MOM.WW.ScadaBridge.Host.Tests" />
</ItemGroup>
<ItemGroup>
<!--
Cap the thread pool's idle spin (#146, mirror of mxaccessgw#237). The default (70 steps,
Sleep(0) on every other step past the tenth) makes a pool worker that finds no work yield
~30 times before parking. Akka dispatchers, gRPC/Kestrel and every async continuation run on
the pool, so a steady trickle of small work items (MxGateway events) turns those yields into
context switches. 10 keeps a short busy-spin and then parks. Lands in the published
*.runtimeconfig.json (Windows service and Docker image alike); override per host with
DOTNET_ThreadPool_UnfairSemaphoreSpinLimit. See Component-Host.md -> Runtime thread-pool settings.
-->
<RuntimeHostConfigurationOption Include="System.Threading.ThreadPool.UnfairSemaphoreSpinLimit" Value="10" />
</ItemGroup>
<ItemGroup>
<!-- Bootstrap is a hand-assembled, injection-safe HOCON document
(AkkaHostedService.BuildHocon) + ActorSystem.Create, NOT Akka.Hosting's
AkkaConfigurationBuilder (REQ-HOST-6). The three Akka.*.Hosting packages
were referenced but unused; dropped in arch-review 01 Task 22. Akka.Cluster.Tools
supplies ClusterSingleton/ClusterClient and (transitively) Akka.Cluster,
which carries the SBR provider named in HOCON. -->
<PackageReference Include="Akka.Cluster.Tools" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Grpc.AspNetCore" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="ZB.MOM.WW.Configuration" />
<PackageReference Include="ZB.MOM.WW.Health" />
<PackageReference Include="ZB.MOM.WW.Health.Akka" />
<PackageReference Include="ZB.MOM.WW.Health.EntityFrameworkCore" />
<PackageReference Include="ZB.MOM.WW.Auth.ApiKeys.SqlServer" />
<PackageReference Include="ZB.MOM.WW.Telemetry" />
<PackageReference Include="ZB.MOM.WW.Telemetry.Serilog" />
<!-- Host/App.razor uses the kit's <ThemeHead/>/<ThemeScripts/> directly; declare the
dependency here rather than leaning on CentralUI re-exporting it transitively. -->
<PackageReference Include="ZB.MOM.WW.Theme" />
<PackageReference Include="ZB.MOM.WW.Secrets" />
<PackageReference Include="ZB.MOM.WW.Secrets.Abstractions" />
<PackageReference Include="ZB.MOM.WW.Secrets.Ui" />
<!-- Secrets:Store:Provider=SqlServer only (Task 5): points a clustered central pair at one
shared SQL-Server secret store directly, no hub. The gRPC secrets hub package this project
used to also reference (ZB.MOM.WW.Secrets.Replicator.Grpc) was retired in Task 11 — see
SecretsRegistration. -->
<PackageReference Include="ZB.MOM.WW.Secrets.Replicator.SqlServer" />
<PackageReference Include="ZB.MOM.WW.LocalDb" />
<PackageReference Include="ZB.MOM.WW.LocalDb.Replication" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.Commons/ZB.MOM.WW.ScadaBridge.Commons.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.TemplateEngine/ZB.MOM.WW.ScadaBridge.TemplateEngine.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.DeploymentManager/ZB.MOM.WW.ScadaBridge.DeploymentManager.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.SiteRuntime/ZB.MOM.WW.ScadaBridge.SiteRuntime.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.DataConnectionLayer/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.Communication/ZB.MOM.WW.ScadaBridge.Communication.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.StoreAndForward/ZB.MOM.WW.ScadaBridge.StoreAndForward.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.ExternalSystemGateway/ZB.MOM.WW.ScadaBridge.ExternalSystemGateway.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.NotificationService/ZB.MOM.WW.ScadaBridge.NotificationService.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.NotificationOutbox/ZB.MOM.WW.ScadaBridge.NotificationOutbox.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.Transport/ZB.MOM.WW.ScadaBridge.Transport.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.AuditLog/ZB.MOM.WW.ScadaBridge.AuditLog.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.SiteCallAudit/ZB.MOM.WW.ScadaBridge.SiteCallAudit.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.KpiHistory/ZB.MOM.WW.ScadaBridge.KpiHistory.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.CentralUI/ZB.MOM.WW.ScadaBridge.CentralUI.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.Security/ZB.MOM.WW.ScadaBridge.Security.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.HealthMonitoring/ZB.MOM.WW.ScadaBridge.HealthMonitoring.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.SiteEventLogging/ZB.MOM.WW.ScadaBridge.SiteEventLogging.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.ClusterInfrastructure/ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.InboundAPI/ZB.MOM.WW.ScadaBridge.InboundAPI.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.csproj" />
<ProjectReference Include="../ZB.MOM.WW.ScadaBridge.ManagementService/ZB.MOM.WW.ScadaBridge.ManagementService.csproj" />
</ItemGroup>
<ItemGroup><ProjectReference Include="../ZB.MOM.WW.ScadaBridge.CentralUI.SandboxWorker/ZB.MOM.WW.ScadaBridge.CentralUI.SandboxWorker.csproj" /></ItemGroup>
</Project>