ref(opt): compile out Clay's unused debug-tools UI#89
Draft
natemoo-re wants to merge 1 commit into
Draft
Conversation
commit: |
Contributor
Merging this PR will degrade performance by 13.64%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
Clay's debug inspector (Clay__RenderDebugView, ~700 lines + ~150 UI strings) is reachable from the exported Clay_EndLayout behind a runtime debugModeEnabled branch, so --gc-sections can't drop it; at -O2 clang inlines it into the layout monolith. clayterm never enables debug mode, so it's dead weight. Adds an upstream-compatible CLAY_DISABLE_DEBUG_TOOLS guard (patches/clay-disable-debug-tools.patch) applied to the clay submodule at build time and opted in via -DCLAY_DISABLE_DEBUG_TOOLS. raw wasm 155,934 -> 111,234 (-28.7%); brotli 41,809 -> 30,417; npm esm/wasm.js 53,143 -> 38,903 (-13.9 KB unpacked). Cold path only (debugModeEnabled always false at runtime); deno task test passes.
81528b8 to
d08642c
Compare
This was referenced Jun 6, 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.
Clay's built-in debug inspector ships in our wasm but clayterm never uses it.
Clay__RenderDebugView(~700 lines + ~150 UI string literals) is reachable from the exportedClay_EndLayoutbehind a runtimeif (context->debugModeEnabled)branch, so--gc-sectionscan't strip it, and at-O2clang inlines it into the layout monolith (the "55 KB function" that dominated twiggy). clayterm never callsClay_SetDebugModeEnabled, so it's pure dead weight.patches/clay-disable-debug-tools.patch: upstream-compatible#ifndef CLAY_DISABLE_DEBUG_TOOLSguards around the#pragma region DebugToolsblock and its single call site inClay_EndLayout. The guards are harmless no-ops unless the flag is defined.claysubmodule at build time (idempotent — skips if already applied; reverted bymake clean) and opts in via-DCLAY_DISABLE_DEBUG_TOOLS.esm/wasm.js53,143 → 38,903 bytes (−14,240, ≈ −13.9 KB unpacked) — wasm.js is the only changed package filedebugModeEnabledis always false at runtime, so no executed layout code changes — none of the-Ozperf tradeoff.deno task testpasses (8 / 146 steps); watching CodSpeed to confirm neutrality.#pragma region DebugTools/#pragma endregion, so thisCLAY_DISABLE_DEBUG_TOOLSflag is a ~6-line PR to nicbarker/clay and would benefit every wasm Clay consumer. If accepted upstream, bump the submodule and drop the patch — only the-Dflag remains.