Files
HealthAppRepositoryB/ImplementationPlan/idle-architecture-analysis.md
T

111 lines
9.0 KiB
Markdown

# Architecture A versus current B: idle implementation audit
Date: 2026-10-22. Scope: pinned A source at
2117236366130775214d9fd2611984d4348f2b79 and corrected B, deployed application hash
1f476847095b1b6b20a436a7f3c6848910f3d500af2c8b660f1f95255ae2c0ae.
This audit inspected local source, retained releases and recorded results only.
It did not send diagnostic traffic to the NUC or change the ongoing USB-off test.
## Conclusion
There are real implementation differences, particularly A's disabled database
pooling versus B's shared enabled pool. They must be distinguished from process
consolidation when interpreting the measurements. However, source inspection
has not identified a mechanism that establishes the residual idle-power offset
as an architectural consequence or an implementation defect. The reference
source contains no architectural requirement for B to consume more power idle.
It also does not guarantee exactly equal idle watts: framework/provider/process
maintenance and wakeup scheduling are implementation-dependent.
The measured whole-outlet difference is a real observation in these runs, not
an attribution. The completed A idle average was 4.4502 W. B with USB attached
was 5.1762 W; the most recently checked USB-off B interval was approximately
4.7884 W (first 20.6 measured minutes, not a completed four-hour mean). The
residual A-versus-B difference at that point was approximately 0.338 W. These
runs are not paired repetitions under identical captured host conditions.
## Findings
| Item | A source/default deployment | Corrected B source/default deployment | Meaning for idle |
|---|---|---|---|
| Application processes | Five web services/runtimes/listeners | One web host with typed in-process modules | Genuine architectural difference. Removes duplicated hosts; does not introduce a new application task. Fewer processes alone is not a wattage model. |
| Application background work | No application hosted background worker, polling loop or scheduled assessment found | None found | No evidence of an added B background workload explaining the offset. Framework background activity is separate. |
| Persistence | Separate profile and observation databases, same PostgreSQL installation model | One database with separate owned schemas | Genuine architecture difference. Both still have PostgreSQL background maintenance; no additional B custom periodic DB job was found. |
| Database connections | Installer sets Pooling=false | Shared NpgsqlDataSource with Pooling=true | Concrete, important implementation difference, explicitly selected by B specification section 7. Pool maintenance and temporarily retained backend connections can differ after activity. It is not an unnoticed stock default. |
| Pool steady state | No pool | Default minimum 0, idle lifetime 300 s, pruning interval 10 s, keepalive disabled | With no new requests, the provider can shrink to zero and disables pruning when the minimum is reached. This makes an indefinitely active pruning loop a weak explanation after a 30-minute warmup; actual historical session counts were not recorded. |
| Local DB transport | Installer sets SslMode=Prefer, Timeout=10 | Installer sets SslMode=Disable for loopback; remote VerifyFull | Concrete configuration difference. Prefer negotiates TLS when supported; it does not prove TLS was used in A's recorded deployment. Handshake/encryption differences matter under traffic. No periodic TLS traffic is configured to explain steady idle. |
| Transactions | Per-service EF query/write lifetimes | Explicit shared snapshot or write transaction per protected request | Necessary B snapshot implementation. Begins only on requests, closes/disposes in request cleanup. No scheduled transaction or calculation was found. Historical server transaction state was not captured. |
| Authentication/token keys | Bearer tokens and file-backed Data Protection in gateway | Same mechanism in consolidated host | No new token-refresh worker found. Token renewal is client activity; idle JMeter sends no login/API requests. |
| Logging | Information default; ASP.NET Warning | ASP.NET Warning and EF logging disabled | Real implementation difference; primarily changes request-time logs. No B periodic logging loop was found. Does not explain more sustained idle I/O by itself. |
| Runtime/provider versions in source | .NET 10, EF Core 10.0.12, Npgsql EF provider 10.0.3 | Same target/core provider versions | No explicit B-only GC mode/timer tuning found. Source equality does not prove the exact installed runtime patch/environment was identical during A's older measurement. |
| Installer lifetime | Administrative provisioner/migration/verification commands exit | Same administrative lifetime | B provisioner is not a continuously running extra service during experiments. |
| Measurement instrumentation | PerfMon and Shelly at 1 s; direct remote PerfMon access | Same nine metrics and meter interval, PerfMon through SSH | Transport differs outside the application architecture. Its contribution has not been isolated. |
## Pooling: what was verified and what was not
A: Reference/ArchitectureA/deploy/HealthApp.Provisioning/Deployment.cs:149-153
explicitly constructs the generated application connection strings with
Pooling=false. ConfigurationWriter carries those values into installed service
configuration. B: src/HealthApp/Program.cs:29-38 constructs the shared pooled
source, and deploy/HealthApp.Provisioning/Installation.cs:67 emits the local
pooled connection string. ArchitectureProposal/software-architecture.md:105
explicitly selects shared bounded pooling for B. This differs from A's reference
installer; my earlier description of normal pooling as a shared A/B behavior
was incomplete. The historical A installed protected config was not retained
with the result, so this is a source/default-deployment finding, not a fresh
read of that deleted installation.
Npgsql 10.0.3's PoolingDataSource starts a disabled pruning timer when the count
exceeds the configured minimum and disables it when that count returns to the
minimum. Creating a maximum-size-100 pool does not open 100 connections. The
provider has no configured nonzero minimum or query keepalive in B's generated
local settings. Do not claim that an idle pool necessarily keeps PostgreSQL
connections or pruning callbacks active throughout the measured four hours.
Primary provider references:
- https://raw.githubusercontent.com/npgsql/npgsql/v10.0.3/src/Npgsql/PoolingDataSource.cs
(constructor and UpdatePruningTimer/CloseConnector)
- https://www.npgsql.org/doc/connection-string-parameters.html
(pooling/timeouts/keepalive defaults)
- https://raw.githubusercontent.com/npgsql/npgsql/v10.0.3/src/Npgsql/NpgsqlDataSource.cs
(password refresh is conditional, not configured by B)
## The correction did not introduce a new architecture
Retained old-B and corrected-B release comparison found 24 app files identical;
only HealthApp.dll and its debug symbols differ. Feature-module DLLs, EF/Npgsql
binaries, runtimeconfig and deps are identical. Installer dependency adapter,
install script and systemd unit are identical. Provisioner DLL changed to stop
emitting the removed resource defaults. The application change removes request
admission gates/deadline and restores adopted error mapping; these paths are
invoked by requests, not by a zero-request idle workload. The maximum pool
setting changed from 32 to provider default 100; minimum/keepalive/pruning were
not changed. Both B versions already used pooling.
Old B's completed idle average was 4.5259 W, close to A's 4.4502 W. The same
consolidated architecture existed then. This is evidence against asserting that
B's architecture inherently requires the entire current positive idle offset.
It does not prove the cause of the remaining difference after USB removal.
## What can be concluded now
1. A and B are not internally identical and are not required to have identical
idle runtime behavior. The concrete differences above must be reported.
2. No added application background computation, polling, broker, projection
worker, permanent transaction or mandatory keepalive was found in current B.
3. Pooling is the strongest specific implementation candidate identified for
post-activity state, but the provider's zero-minimum/pruning behavior weakens
it as an explanation of a four-hour steady offset after 30 minutes warmup.
4. Neither a source audit nor aggregate CPU/power identifies which process or
wakeup pattern causes approximately 0.34 W. Low CPU alone cannot settle it.
5. No basis was found to declare a new unauthorized idle implementation feature
the demonstrated cause. Equally, there is no basis to declare the remaining
difference harmless variance or an unavoidable architecture cost.
After the already running USB-off idle/load pair finishes, causal attribution
needs matched A/B observations of per-process CPU/wakeups, database session and
transaction lifetimes, and package idle-state residency. No power settings,
services, source or software should be changed during the current pair. Any
future controlled isolation experiment must be separately identified and must
not overwrite or relabel the completed runs.