Skip to content

[jules] Performance pass: resource optimization and latency benchmarks - #1

Open
teddashh wants to merge 1 commit into
mainfrom
jules/performance-optimization-32287853566871743
Open

teddashh wants to merge 1 commit into
mainfrom
jules/performance-optimization-32287853566871743

Conversation

@teddashh

Copy link
Copy Markdown
Contributor

This PR implements a performance pass across the repository focusing on memory allocation reduction, optimizing redundant operations, and identifying build process bottlenecks.

Changes include:

  • escapeHtml optimization: The HTML entities mapping object has been lifted out of the .replace callback in scripts/build.mjs, ensuring a new object isn't created for every matched character during sanitization.
  • site.js object check optimization: The postMessage event.data checking logic was refactored to replace an expensive sorting and string joining check (Object.keys().sort().join()) with a fast Object.keys().length and series of boolean in checks. This saves multiple array/string allocations on every user click action or window resize message.
  • Parallel File I/O: Refactored the internal build() generation pipeline in scripts/build.mjs to execute file reads and writes concurrently using Promise.all(), mitigating latency.
  • Benchmark Test Added: Added tests/benchmark.test.mjs to profile renderWorkspace operations in a tight loop to protect performance against future regressions.

Testing:

  • Benchmarked manually against existing implementations to ensure significant execution time improvements.
  • Handled tests through executing npm run build and resolving all npm test and Playwright tests (npm run test:browser) completely and cleanly with 0 failing suites.

PR created automatically by Jules for task 32287853566871743 started by @teddashh

…ecking, and parallelize build IO

- Move htmlEntities out of escapeHtml to prevent recreating object on every match
- Avoid Object.keys().sort().join() in postMessage handler to reduce intermediate string and array allocations
- Parallelize writing generated static site assets in build.mjs with Promise.all()
- Add rendering benchmark test file to prevent regressions

Co-authored-by: teddashh <233386770+teddashh@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

This branch has not been deployed

No deployments
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