ref(opt): compile out Clay's unused debug-tools UI - #89
Open
natemoo-re wants to merge 1 commit into
Open
Conversation
commit: |
natemoo-re
marked this pull request as draft
June 6, 2026 16:46
Contributor
natemoo-re
force-pushed
the
ref/clay-debug-tools
branch
from
June 6, 2026 17:12
81528b8 to
d08642c
Compare
This was referenced Jun 6, 2026
natemoo-re
force-pushed
the
ref/clay-debug-tools
branch
2 times, most recently
from
August 27, 2026 09:14
fe8bf96 to
fe0f62d
Compare
|
Size Reduced — -18.8 KB 100.0 KB unpacked |
Clay's debug inspector (Clay__RenderDebugView, ~700 lines + ~150 UI strings) is reachable from the exported Clay_EndLayout behind runtime debugModeEnabled branches, 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_DEBUG_MODE_ENABLED value macro (default 1; patches/clay-debug-mode-enabled.patch), named to match the runtime context->debugModeEnabled selector. Generated against the submodule's recorded commit (938967a) and covering all four debugModeEnabled sites; opted out via -DCLAY_DEBUG_MODE_ENABLED=0. The Makefile now applies Clay patches generically: every patches/*.patch is applied (in sorted order) after resetting clay/clay.h to pristine, so the applied set always matches the directory exactly and future patches (e.g. #115's grow-minDimensions fix) need no per-patch Makefile wiring. Reverted by make clean. Drop individual patches as they ship upstream. raw wasm 155,877 -> 101,208 (-35.1%); brotli 44,141 -> 29,133. Cold path only (debugModeEnabled always false at runtime); deno task test test/ passes (19 files, 227 steps).
natemoo-re
force-pushed
the
ref/clay-debug-tools
branch
from
August 27, 2026 10:08
fe0f62d to
0a1e0a8
Compare
natemoo-re
marked this pull request as ready for review
August 27, 2026 10:17
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 is gated behind
if (context->debugModeEnabled), but tty doesn't benefit from this code path at all.This PR patches Clay to add a
CLAY_DEBUG_MODE_ENABLEDmacro (defaults to1), which allows us to strip out the unused code. Good candidate for an upstream PR!Makefile has also been updated with a generic patch mechanism, with
patches/*.patchapplied in order against the latest upstream base.Net result size is reduced by 18.8 KB (down to 100.0 KB unpacked)