Skip to content

perf: optimize library selection, filtering, and virtual scrolling - #535

Merged
ghiscoding merged 2 commits into
mainfrom
feat/audit-astra
Oct 5, 2026
Merged

ghiscoding merged 2 commits into
mainfrom
feat/audit-astra

Conversation

@ghiscoding

Copy link
Copy Markdown
Owner

Summary

Reduce repeated selection, filtering, rendering, and event-binding work in multiple-select-vanilla. Fix listener cleanup and virtual-scroller lifecycle issues identified during the library LOC/performance audit.

Why

Large option lists repeatedly scanned selection values, rebuilt unchanged row descriptions, decoded labels, and rebound stable controls.

Recorded local diagnostic results:

Operation Before After Improvement
Select one of 10,000 virtual text options 96.0 ms 8.8 ms 10.9× faster
Temporary textareas during that selection 10,001 0 Eliminated
Filter 10,000 text options 109.9 ms 24.0 ms 4.6× faster
Search-term normalizations per filter 10,000 1 99.99% fewer
Check all 10,000 native options 2,047.6 ms 28.4 ms 72.1× faster
Highlight calls when skipping eight disabled rows 9 1 88.9% fewer

Timing results are single instrumented local probes using unminified bundles, not repeated production benchmarks.

Changes

  • Replace repeated selection membership searches with Sets while preserving value coercion.
  • Cache unchanged text row descriptions and decoded labels, with invalidation for mutable rendering inputs.
  • Normalize built-in filter queries once while preserving custom parser calls and grouped filtering.
  • Index listener checks and correctly remove captured listeners, collections, and omitted-callback bindings.
  • Rebind recreated row controls while retaining stable control and navigation handlers.
  • Fix virtual-scroller ownership, reset behavior, mounted selection bounds, and spacer updates.
  • Cancel delayed opening during destruction and settle canceled opening Promises.
  • Share selection finalization, remove unreachable branches, and consolidate repeated binding guards.
  • Add eight browser regression cases and retain the audit and measurements in .agents/audits.

The final guard simplification reduces rebindControls checks from 12 to 2 and avoids creating an unused handler during virtual-scroll updates.

Validation

  • Package-wide Biome lint and formatting: passed.
  • Library TypeScript check: passed.
  • Library and demo builds: passed.
  • Security tests: 11 passed.
  • Full Playwright suite: 100 passed, including eight new regression cases.
  • Targeted Biome check for the regression spec: passed.
  • git diff --check: passed.
  • Package validation: ESM-only profile passed; the strict profile reports the existing CommonJS-to-ESM resolution restriction.

The latest browser run used a separate artifact directory after the initial run encountered missing trace files while a Playwright UI session used the default directory.

Comments

Performance and lifecycle fixes add some implementation state:

Library metric Before Final Change
Core TypeScript physical LOC 3,048 3,128 +80 lines
Minified ESM, excluding source-map trailer 46,661 bytes 48,264 bytes +1,603 bytes
Gzip size 13,092 bytes 13,722 bytes +630 bytes

The final simplification alone removes 29 minified bytes and 10 gzip bytes; physical LOC is unchanged.

Public exports remain unchanged. Existing custom styling, sanitization, mutable-data handling, selection coercion, and callback ordering are preserved. No migration is required.

Changes are scoped to the library, its regression coverage, and audit documentation. Timing probes were not repeated after the final guard simplification; bundle measurements and browser validation were repeated.

AI / LLM assistance

  • AI / LLM assistance used:
    • No
    • Yes
  • If Yes:
    • which tool/model: OpenAI Codex; GPT-6 Astra
    • how was it used: Audit library LOC and performance, implement optimizations and lifecycle fixes, add regression coverage, run validation, record measurements, and draft the PR description.

Checklist

  • The changes are limited to only one scope (if not please explain why in the comments above).
  • Tests were added or updated where appropriate.
  • Documentation was updated where appropriate.

@ghiscoding ghiscoding changed the title perf: optimize library selection, filtering, and virtual scrolling feat: optimize library selection, filtering, and virtual scrolling Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Playwright E2E Test Results

100 tests  +8   100 ✅ +8   2m 20s ⏱️ +11s
 76 suites +1     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 17b2064. ± Comparison against base commit 8536d74.

♻️ This comment has been updated with latest results.

@ghiscoding ghiscoding changed the title feat: optimize library selection, filtering, and virtual scrolling perf: optimize library selection, filtering, and virtual scrolling Oct 5, 2026
@ghiscoding
ghiscoding merged commit 8d7cf44 into main Oct 5, 2026
5 checks passed
@ghiscoding
ghiscoding deleted the feat/audit-astra branch October 5, 2026 13:30
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

🎉 This pull request is included in version 5.2.3 📦
🔗 The release notes are available at: GitHub Release 🚀

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.

1 participant