perf(removeHiddenElems): cache computed styles - #2280
Open
TrySound wants to merge 1 commit into
Open
Conversation
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.
Summary
removeHiddenElemsmakes its two traversal passescomputeStyle, avoiding repeated ancestor traversal and selector matchingremoveHiddenElemsonly needs to distinguish empty, single-point, and renderable pathsBenchmark
Benchmarked against the regression fixture suite at
77ba065b4e4b4902c8795921287f9cf7, using all Charm and Oxygen icon fixtures:floatPrecision: 4removeHiddenElemsremoveHiddenElemsshareremoveHiddenElemsrankThe full after profile was:
convertPathDataremoveHiddenElemsminifyStylesmergePathsremoveUselessStrokeAndFillconvertTransformcleanupEnableBackgroundremoveUnknownsAndDefaultscleanupIdsBecause parallel phase timings include GC and worker contention, unrelated phases vary between runs. The
removeHiddenElemsresult was also checked separately on a deterministic every-tenth-file Oxygen sample (433 files): 6.52s before vs 2.96s after (-54.6%).Optimized output was compared against the baseline for a deterministic 460-file Charm/Oxygen sample with no differences.
Tests
pnpm typecheckpnpm exec vitest run lib/path.test.js lib/style.test.js test/plugins/_index.test.js --exclude '.worktrees/**'(407 tests)