Repository navigation
Use faster Brotli compression for StaticHost publishing - #1879
Conversation
Preserve Brotli negotiation and immutable asset caching, cover isolated publishes, and add opt-in full-site CI diagnostics. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
Exercise the full-site verifier against incorrect compressed content without mutating shared publish fixtures. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
Frontend HTML artifact readyThe latest frontend build uploaded the This comment updates automatically when a new frontend build artifact is uploaded. |
There was a problem hiding this comment.
None of these changes to this file are needed/useful to anyone actually contributing to this project. Please undo these changes.
Update the stale mount and data-directory expectations to match the corrected non-root dashboard example in both shell variants. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
There was a problem hiding this comment.
🟡 Changes recommended
The profiling job remains unreachable for frontend-only pull requests despite the documented label opt-in.
1 open finding
What changed in this PR
This PR reduces StaticHost publish time by changing the default Brotli compression level and adds publishing diagnostics and regression coverage.
Changes:
- Defaults Brotli publishing to
Optimalwhile preserving overrides. - Adds publish, HTTP negotiation, integrity, and cache-header tests.
- Adds opt-in full-site CI profiling and contributor guidance.
| File | Description |
|---|---|
tests/StaticHost.Tests/StaticHost.Tests.csproj |
Copies publishing fixtures into test output. |
tests/StaticHost.Tests/PublishingTargetsTests.cs |
Tests compression, delivery, and diagnostics. |
tests/scripts/Measure-StaticHostPublish.ps1 |
Verifies output and records metrics. |
src/statichost/StaticHost/StaticHost.csproj |
Imports publishing targets. |
src/statichost/StaticHost/Publishing.targets |
Configures Brotli and timing logs. |
src/frontend/tests/unit/dashboard-image-references.vitest.test.ts |
Corrects persistence expectations. |
CONTRIBUTING.md |
Documents publishing behavior and profiling. |
.github/workflows/ci.yml |
Passes the profiling opt-in. |
.github/workflows/apphost-build.yml |
Adds the diagnostic publish job. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if: ${{ needs.changes.outputs.apphost == 'true' }} | ||
| uses: ./.github/workflows/apphost-build.yml | ||
| with: | ||
| profile_publish: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'build-profile') }} |
Add opt-in controlled SmallestSize versus Optimal publishing, image, CPU, memory, native decode, and cold/warm Chromium measurements without rendering the frontend twice. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
Keep ordinary publish diagnostics capped at 45 minutes; use the maintainer-approved three-hour limit only for the full compression comparison. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
Controlled compression resultsCI run 38449500455 passed on commit The frontend was rendered once. Each variant then used a clean compression/publish directory and
Directory totals, exact task timings, CPU/RSS measurements, and raw data are in Representative document bytes and decoding
Those HTML-body deltas alone model approximately 11-16 ms of additional transfer at 5 Mbps, or 55-82 ms at 1 Mbps. They exclude CSS/JS/resources, RTT, protocol behavior, and CDN caching; they are not observed page-load penalties. Isolated native Browser measurement correctionI found a validation flaw in the first browser profile: Playwright request routing disables HTTP caching. Consequently, its samples labelled "warm" did not exercise a warm HTTP cache, and the interceptor also makes the throttled-network observations unsuitable for conclusions. I am not using those browser samples to recommend a setting. The profiler now uses Chromium-native URL blocking without a request interceptor and explicitly requires warm navigations to show actual cache hits. All 48 tiny-fixture observations passed that corrected check. A browser-only follow-up using the same generated pages/assets is being prepared so the expensive full-corpus baseline need not be repeated. Other measured bottlenecks and coverage
Validation
|
Replace cache-disabling request interception with Chromium URL blocking. Reuse a completed paired corpus for SHA-verified representative browser-only profiling, requiring identical Brotli bytes and genuine cache hits. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
Corrected browser/cache resultsThe browser-only job in CI run 38598948534 passed on commit This follow-up reused the completed full-corpus run's generated frontend. Each representative page's SHA-256 and Brotli byte count had to match the original These results supersede the earlier interceptor-based browser samples. Chromium-native URL blocking keeps HTTP caching enabled, and warm navigations must produce real cached-resource hits. All 96 observations, 48 per setting, passed the content and cache checks. Warm navigations reused at least 37 cached resources. Environment: Chromium 149.0.7827.55, Node 24.21.0, Ubuntu x64. Each setting used three cold/warm pairs per page/scenario. Mobile-like means a 390x844 viewport, 5 Mbps downstream, 40 ms simulated latency, and 4x CPU throttling. Cold mobile-like visitsPage transfer includes the main document and same-origin resources, not just HTML.
These descriptive medians show 42-62 ms more document download time and 40-56 ms higher FCP with LCP medians were mixed, not a consistent regression: home 648→596 ms, guide 756→672 ms, C# 632→616 ms, and TypeScript 600→628 ms. Ranges overlap for most comparisons. Three pairs are insufficient to establish statistical significance or a field-performance guarantee. Warm visitsIn the mobile-like warm-cache profile, transfer was 600 B for both settings on all four pages, with 37-64 cached resources. Document response/download spans were approximately 44-46 ms for both variants. The larger compressed payload therefore did not add body-transfer bytes in these cached revisits. Desktop cold LCP medians differed by -40 to +12 ms across these pages. Warm desktop transfer was 600-900 B for both settings. The dominant measurable penalty is the cold, bandwidth-constrained transfer, not server TTFB or native decompression. Scope and interpretation
Validation
|
Final validation statusCI run 38598948534 completed successfully on The full-corpus build/size figures and corrected browser-cache figures are preserved in the two detailed comments above and in the PR body. The expensive full compression comparison was not repeated for the cache correction. The PR remains draft for the cold-visit/size tradeoff decision. No merge or deployment was performed. |
|
|
||
| switch (args[0]) | ||
| { | ||
| case "snapshot": |
There was a problem hiding this comment.
How useful is this stuff going to be over time? Is this something that needs to be checked in? Or was it just used as a one-off?
| <_BlazorBrotliCompressionLevel Condition="'$(_BlazorBrotliCompressionLevel)' == ''">$(BrotliCompressionLevel)</_BlazorBrotliCompressionLevel> | ||
| </PropertyGroup> | ||
|
|
||
| <Target Name="LogStaticHostCompressionStart" BeforeTargets="GeneratePublishCompressedStaticWebAssets"> |
There was a problem hiding this comment.
Do we even need this if we had a binlog?
There was a problem hiding this comment.
Do we need this thing at all? Should it be removed?
Remove investigative profiling tools, added tests, workflow changes, documentation, unrelated dashboard assertions, and redundant timing messages. Keep the Optimal default in StaticHost.csproj and only the .NET 10 publish-property compatibility mapping in Publishing.targets. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 3761b826-bc44-40e0-99dd-a3162446f1a6
|
Scope cleanup is complete in Validation: the existing StaticHost unit/HTTP suite passed locally (308 tests), production property evaluation passed for the default and both override paths, and fresh CI 38927931737 passed, including AppHost/StaticHost/Redis coverage and the CI gate. Frontend CI correctly skipped because the final diff has no frontend changes. |
Set _BlazorBrotliCompressionLevel directly in the csproj and drop Publishing.targets. Publish ignores BrotliCompressionLevel: dotnet/sdk#56679 Co-authored-by: Copilot App <[email protected]> Copilot-Session: c8e20bb7-5776-4e97-ab7f-ea75bf4ae889
|
Simplified the Brotli configuration in d5e8f82:
Local check: a |
Eric Erhardt (eerhardt)
left a comment
There was a problem hiding this comment.
Approving after simplifying the Brotli configuration (see comment).

Summary
This PR changes only two production files, eight added lines:
StaticHost.csprojdefaultsBrotliCompressionLeveltoOptimalwhile respecting explicit public or compatibility-property overrides.Publishing.targetsmaps that setting to_BlazorBrotliCompressionLevel, which .NET 10's publish compression target consumes.All investigative performance programs/scripts, added tests, frontend scripts, workflow changes, documentation additions, unrelated dashboard-test edits, and custom timing messages have been removed. MSBuild binary logs already contain the task timings.
The completed research remains in the controlled timing/size results and corrected browser results, not in shipped profiling infrastructure. On the measured identical corpus, Brotli compression dropped from 4,172.315s to 38.766s; compressed payload increased 19.5% and the container archive increased 7.3%. Sampled cold mobile-like visits had 40–56ms higher median FCP; these lab samples are not statistical or field-performance guarantees.
Third-party links and affiliations
None.
Validation
dotnet test tests\StaticHost.Tests\StaticHost.Tests.csproj --configuration Release --filter "Category!=RedisIntegration" --verbosity minimal— passed, 308 existing tests. Restore reported an existing MessagePack NU1902 advisory; no dependency changes are included.dotnet msbuild src\statichost\StaticHost\StaticHost.csproj -nologo -getProperty:BrotliCompressionLevel,_BlazorBrotliCompressionLevel,PublishCompressionFormats— passed: both level properties evaluate toOptimal, format remainsbrotli.-p:BrotliCompressionLevel=SmallestSize— passed: both level properties evaluate toSmallestSize.-p:_BlazorBrotliCompressionLevel=Fastest— passed: both level properties evaluate toFastest.git diff --check— passed.8b7c52318cb1da38af1f329e591c4df8ea3d4cc7— passed, including the AppHost/StaticHost build and tests, Redis integration tests, release-sync tests, and CI gate. Frontend CI was correctly skipped because no frontend changes remain.