Skip to content

optimize asset checksum filtering with Set lookup#7105

Open
EvilGenius13 wants to merge 1 commit intomainfrom
perf/asset-checksum-set-lookup
Open

optimize asset checksum filtering with Set lookup#7105
EvilGenius13 wants to merge 1 commit intomainfrom
perf/asset-checksum-set-lookup

Conversation

@EvilGenius13
Copy link
Copy Markdown
Contributor

@EvilGenius13 EvilGenius13 commented Mar 25, 2026

WHY are these changes introduced?

We can improve performance around asset checksums.

WHAT is this pull request doing?

Optimizes rejectGeneratedStaticAssets in asset-checksum.ts from O(n²) to O(n) by pre-computing a Set of liquid asset keys.

Before: For each asset, hasLiquidSource() scans the entire array with some() — O(n) per asset, O(n²) total.

After: Pre-compute a Set of liquid asset keys once, then use O(1) has() lookups.

How to test your changes?

  • Pull down the branch
  • Build the branch
  • Run theme push, pull or dev and ensure everything is still working.

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@EvilGenius13 EvilGenius13 changed the title perf(theme): optimize asset checksum filtering with Set lookup optimize asset checksum filtering with Set lookup Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 82.22% 15042/18294
🟡 Branches 74.77% 7416/9918
🟢 Functions 81.3% 3791/4663
🟢 Lines 82.62% 14223/17216

Test suite run success

3970 tests passing in 1524 suites.

Report generated by 🧪jest coverage report action from bfca4c1

Replace O(n) Array.some() scan with O(1) Set lookup by pre-computing
liquid asset keys. Reduces complexity from O(n²) to O(n) for themes
with many assets.
@EvilGenius13 EvilGenius13 force-pushed the perf/asset-checksum-set-lookup branch from 268291c to bfca4c1 Compare March 26, 2026 19:57
@EvilGenius13 EvilGenius13 marked this pull request as ready for review March 30, 2026 15:08
@EvilGenius13 EvilGenius13 requested review from a team as code owners March 30, 2026 15:08
Copilot AI review requested due to automatic review settings March 30, 2026 15:08
@github-actions
Copy link
Copy Markdown
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves performance in the theme CLI’s checksum filtering by optimizing how generated static assets (e.g., assets/foo.css when assets/foo.css.liquid exists) are rejected during theme comparison/pull/upload flows.

Changes:

  • Precomputes a Set of Liquid asset keys under assets/ for O(1) membership checks.
  • Replaces per-asset some() scans with Set.has() lookups, reducing overall complexity from O(n²) to O(n).
  • Removes the now-unneeded hasLiquidSource helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants