Skip to content

⚡ Bolt: Replace Math.min/max spread with O(N) loops in bounds calculations - #5093

Open
dieterolson wants to merge 1 commit into
mainfrom
bolt-optimization-bounds-calculation-17914668131332905231
Open

⚡ Bolt: Replace Math.min/max spread with O(N) loops in bounds calculations#5093
dieterolson wants to merge 1 commit into
mainfrom
bolt-optimization-bounds-calculation-17914668131332905231

Conversation

@dieterolson

@dieterolson dieterolson commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Replaced array spreads in Math.max(...values) and chained flatMap arrays with single-pass for loops in ScalarEnsembleScatter and TorqueFitPreview.
🎯 Why: To prevent "Maximum call stack size exceeded" errors and avoid significant garbage collection pressure caused by spreading large arrays or creating intermediate mapped structures during frequent re-renders.
📊 Impact: Eliminates O(N) allocations for bounds calculations on these paths and ensures safety with larger datasets.
🔬 Measurement: Verified via unit test suite that calculations remain functionally identical while bypassing JS call stack limitations.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes


PR created automatically by Jules for task 17914668131332905231 started by @dieterolson

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T09:55:40.552705Z 3bf10ca PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bf10ca561

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +28 to +30
let minimum = Infinity;
let maximum = -Infinity;
for (let i = 0; i < samples.length; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Extract the bounds scan from the component

Extract this bounds aggregation into a focused helper: the added scan expands TorqueFitPreview from 45 lines in the parent revision to 56 lines (lines 14–69), exceeding the repository's mandatory 50-line maximum and making the calculation harder to test independently.

AGENTS.md reference: AGENTS.md:L190-L195

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ SPEC.md Update Required

Source files were modified in this PR but SPEC.md was not updated.

Per the Specification-Driven Development Policy:

  • Any PR that adds, removes, or changes functionality must update SPEC.md
  • Update the relevant sections (features, architecture, tests, dependencies, etc.)
  • Add ONE §12 Change Log row keyed by your pull request:
    | YYYY-MM-DD | #<pr> | one-line summary |. Do NOT bump the
    Spec Version field — it is release-derived
    (Repository_Management#1520)

To resolve:

  1. Update SPEC.md to reflect your changes, OR
  2. Add the spec-exempt label if this PR genuinely doesn't affect the spec (e.g., pure refactor with no behavior change)

This check is enforced by the spec-check CI workflow.

dieterolson added a commit that referenced this pull request Sep 9, 2026
… web components

Spec Check requires one §12 Change Log row keyed by the PR; Docs Governance requires the module-inventory shard refreshed for the two modified rate_of_closure web components. Handoff: no material handoff change — CI-green remediation for PR #5093 only.
@dieterolson
dieterolson enabled auto-merge (squash) September 9, 2026 01:50
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
…ulations (#5093)

Replaced array spreads in Math.max(...values) and chained flatMap arrays
with single-pass for loops in ScalarEnsembleScatter and TorqueFitPreview
to prevent stack overflow and avoid GC pressure.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 636cc7d to d5a85a2 Compare September 9, 2026 02:00
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
…ulations (#5093)

Replaced array spreads in Math.max(...values) and chained flatMap arrays
with single-pass for loops in ScalarEnsembleScatter and TorqueFitPreview
to prevent stack overflow and avoid GC pressure.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 4c2ced9 to 4d132ce Compare September 9, 2026 05:19
dieterolson added a commit that referenced this pull request Sep 9, 2026
Append release-bump closures (#5089-#5104), #5093/#5106 merges and #5103 auto-merge status to the PR Disposition table; re-pin handoff-manifest.json.

Co-authored-by: dieterolson <dieterolson@users.noreply.github.com>
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
…ulations (#5093)

Replaced array spreads in Math.max(...values) and chained flatMap arrays
with single-pass for loops in ScalarEnsembleScatter and TorqueFitPreview
to prevent stack overflow and avoid GC pressure.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 4d132ce to 76a9784 Compare September 9, 2026 14:54
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
…ulations (#5093)

Replaced array spreads in Math.max(...values) and chained flatMap arrays
with single-pass for loops in ScalarEnsembleScatter and TorqueFitPreview
to prevent stack overflow and avoid GC pressure.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 76a9784 to 65bc4d4 Compare September 9, 2026 16:45
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
…ulations (#5093)

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 65bc4d4 to dc61d4f Compare September 9, 2026 22:15
dieterolson pushed a commit that referenced this pull request Sep 10, 2026
…ulations (#5093)

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from dc61d4f to 6f3cd12 Compare September 10, 2026 01:23
@github-actions github-actions Bot added the do-not-merge Reviewer hold: automation must not arm auto-merge or merge this PR label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Auto-merge held

The Merge Hold Guard is holding this PR back. Reason(s):

  • diff deletes 222 tracked file(s) with no acknowledgement

This diff removes 222 file(s) that exist on the base branch:

docs/development/file-watcher-debounce-5095.md
docs/development/impact-acoustics/AFFINE_RESPONSE.md
docs/development/impact-acoustics/AFFINE_TRANSIENT.md
docs/development/impact-acoustics/AUTONOMOUS_DECAY.md
docs/development/impact-acoustics/BENDING_CONTINUUM.md
docs/development/impact-acoustics/CI_FINDINGS.md
docs/development/impact-acoustics/CI_REPAIR_RESULTS.json
docs/development/impact-acoustics/CONSTANT_GRIPPED_MODEL.md
docs/development/impact-acoustics/DATA_CANDIDATES.md
docs/development/impact-acoustics/DEFORMED_FRAME_INERTIA.md

If the deletions are intentional, add the deletions-acknowledged label (or a Deletions-Acknowledged: yes line to this description), then remove do-not-merge.

Auto-merge will be revoked again on every re-arm until the hold is cleared. The guard never merges and never pushes.

@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch 3 times, most recently from 78ed3c5 to 48d712c Compare September 10, 2026 11:01
Replaced Math.min(...spread) and Math.max(...spread) with O(N) single-pass loops in TorqueFitPreview.tsx.
Eliminates call stack pressure and garbage collection overhead on render paths.

rate-visual-exemption: algorithmic bounds calculation optimization without visual layout changes

Co-authored-by: dieterolson <198168927+dieterolson@users.noreply.github.com>
@dieterolson
dieterolson force-pushed the bolt-optimization-bounds-calculation-17914668131332905231 branch from 48d712c to c6859d2 Compare September 10, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge Reviewer hold: automation must not arm auto-merge or merge this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant