Skip to content

perf(web-ui): optimize search query tokenization, datetime parsing cache, and identity document memoization - #3817

Open
Raing5Days wants to merge 1 commit into
openBitFun:mainfrom
Raing5Days:perf/flywheel-scanned-optimizations
Open

Raing5Days wants to merge 1 commit into
openBitFun:mainfrom
Raing5Days:perf/flywheel-scanned-optimizations

Conversation

@Raing5Days

Copy link
Copy Markdown
Contributor

Summary

Performance optimizations discovered and verified via autonomous flywheel scanning, targeting high-frequency string splitting, regex parsing, and YAML document caching in Web UI.

Key improvements:

  1. Global Search Matching Query Tokenization (searchMatching.ts):

    • Hoisted queryTokens invocation outside the candidate fields iteration loop (previously splitting the query up to 5 times per item across hundreds of items).
    • Added bounded LRU cache for queryTokens and fieldWordsCache for term/acronym word splits, eliminating repeated regex splitting and array allocations during live search keystrokes.
  2. Scheduled Jobs DateTime Parsing & Formatting (localizedDateTime.ts):

    • Reused hoisted static regex patterns FORMAT_PATTERN and DIGIT_PATTERN instead of re-instantiating regexes on every call.
    • Added bounded format and parse memoization cache, enabling instant rendering for scheduled jobs tables and timeline rows with zero regex recalculations.
  3. My Agent Identity Document Memoization (identityDocument.ts):

    • Added parsedDocCache memoizing parseIdentityDocument by content string, returning identical object references (===) across repeat renders and property accesses without repeated markdown/YAML parsing.

Type and Areas

Performance / refactoring. Web UI (src/web-ui).

Verification

  • node scripts/run-vitest.mjs run src/app/global-search/searchMatching.test.ts -- 6 passed (100%).
  • node scripts/run-vitest.mjs run src/app/components/scheduled-jobs/localizedDateTime.test.ts -- 12 passed (100%).
  • node scripts/run-vitest.mjs run src/app/scenes/my-agent/identityDocument.test.ts src/app/scenes/my-agent/useAgentIdentityDocument.test.tsx -- 6 passed (100%).
  • node scripts/check-repo-hygiene.mjs -- passed (clean repository hygiene and formatting).

Checklist

  • Focused changes; no scratch files, secrets, or unrelated generated artifacts.
  • Preserves pure functional contracts and existing testing guarantees.

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