Skip to content

Improve Brotli compression of Wasm ReadyToRun runtime-function tables without eager startup reconstruction #135796

Open

Description

@davidwrighton

Description

WebAssembly ReadyToRun runtime-function tables have an opportunity to improve Brotli-compressed download size without changing the logical eight-byte records. A prototype transposed the resolved records into eight byte planes, grouping corresponding bytes across entries rather than storing each record contiguously.

This produced a measurable whole-file Brotli improvement. However, the prototype eagerly reconstructed a conventional runtime-function array at image load, adding startup work and a table-sized allocation. That implementation was abandoned because the startup tradeoff was unacceptable. This issue tracks retaining the compression benefit without that eager reconstruction/allocation, not merging the abandoned implementation.

Prototype: commit 5ab649f69a902ea8e60904e9a12ab5502a55e443 in #135553. Its revert is currently local and has not been pushed to that PR.

Configuration

  • Experimental .NET 11 CoreCLR WebAssembly ReadyToRun, built on Linux/x64 for browser-wasm.
  • Optimized CoreLib + CallPerformance composite.
  • Historical prototype measurements used randomized method layout; these are not fresh default-order measurements. Future validation should use default function order and also measure retail System.Private.CoreLib.wasm.
  • Brotli quality 11, window 22, generic mode. Compressed streams were decompressed and compared with the original inputs.

Regression?

This is a size-improvement opportunity, not a reported regression in a released runtime.

Data

Matched measurements immediately before and after the byte-plane stage:

Artifact Before After Savings
Whole managed composite, raw bytes 12,757,774 12,757,774 0
Whole managed composite, Brotli bytes 2,798,225 2,756,068 42,157 (1.51%)
Runtime-function table, raw bytes, excluding trailer 288,088 288,088 0
Runtime-function table, independently compressed Brotli bytes 91,378 51,519 39,859 (43.62%)

The independently compressed table row is not an additional whole-file saving. Both table encodings represent the same 36,011 records; all records and the sentinel/minimum-function-index trailer round-tripped exactly.

The eager-decoding prototype added a 288,096-byte loader allocation, excluding allocator overhead. Native runtime Wasm grew by 709 raw bytes while its Brotli size decreased by 266 bytes. Startup latency was not quantitatively benchmarked; the objection was the eager full-table reconstruction and allocation.

No retail CoreLib byte-plane comparison was recorded for this prototype.

Analysis

Each runtime-function record contains a 32-bit BeginAddress and 32-bit UnwindData. Corresponding-byte planes expose repeated high bytes and related values to Brotli. Encoding after relocation resolution preserves the original RVAs. The trailing sentinel and minimum function-table index can remain linear.

A follow-up should investigate direct indexed reads from planar storage, or an alternative compression-friendly representation that requires no image-sized reconstruction at startup. Runtime lookup and stack-walking consumers currently rely on ordinary record pointers, including pointer subtraction for ordinal identity, so simply returning pointers into the byte planes is not safe.

Acceptance should include correctness of method lookup, funclet/unwind/GC handling, composite/component sharing, and managed inspection tools, together with default-order raw/Brotli comparisons for both retail CoreLib and a composite, startup/allocation measurements, and hot-path lookup/stack-walk performance.

Note

This issue was prepared with GitHub Copilot.

Activity

  1. added
    tenet-performance
    on Oct 14, 2026
  2. added
    untriaged
    on Oct 14, 2026
  3. dotnet-policy-service commented on Oct 14, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/crossgen-contrib
    See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ReadyToRuntenet-performanceuntriaged

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions