Speed up publicization by patching metadata in place - #232
Merged
Conversation
Publicization only flips visibility bits in the fixed-width Flags columns of the TypeDef, Field and Method tables, so the output can be produced by patching a copy of the input instead of having dnlib rebuild the whole metadata. Measured on a 7 MB assembly the write phase drops from ~1600ms to ~5ms, taking the cache-miss task from ~1.9s to ~0.36s. Unpatchable layouts (ENC/uncompressed metadata, unexpected column shape) fall back to the dnlib writer.
krafs
marked this pull request as ready for review
July 26, 2026 13:01
This was referenced Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Publicization only flips visibility bits in the fixed-width Flags columns of the TypeDef, Field and Method tables, so the output can be produced by patching a copy of the input rather than having dnlib rebuild the entire metadata.
Measured on a 7.1 MB assembly, the write phase drops from ~1580 ms to ~5 ms, taking the whole cache-miss task from ~1.9 s to ~0.36 s. Cache hits are unaffected — they already skip the write.
Unpatchable layouts fall back to the existing dnlib writer: uncompressed/ENC metadata (
#-heap, where deleted rows make row offsets unsafe to compute from rid), an unexpected Flags column name or width, or table extents past the end of the file. Each logs its reason.Verified beyond the existing suites by diffing against dnlib's own output across three assemblies (7.1 MB / 5.1 MB / 1.1 MB): every member's flags match exactly, and Roslyn loads each patched image as a metadata reference with no diagnostics.
Two known gaps, tracked on the board rather than fixed here: