Skip to content

⚡ Bolt: Replace Math.max(...map) with single-pass loops - #5123

Merged
dieterolson merged 1 commit into
mainfrom
bolt-optimization-math-max-map-114777708485744154
Sep 10, 2026
Merged

⚡ Bolt: Replace Math.max(...map) with single-pass loops#5123
dieterolson merged 1 commit into
mainfrom
bolt-optimization-math-max-map-114777708485744154

Conversation

@dieterolson

Copy link
Copy Markdown
Collaborator

💡 What: Replaced inline Math.max(...array.map()) and Math.min(...array.map()) chains with standard single-pass for loops in forceSourceArtifact.ts, auditForceSourceFairness.ts and forceSourceStudy.test.ts.

🎯 Why: Using Math.max(...spread) combined with .map() is an anti-pattern that creates intermediate arrays, generating GC pressure and risking "Maximum call stack size exceeded" errors with large data sets. Single-pass loops run significantly faster with O(1) memory overhead.

📊 Impact: Eliminates unbounded intermediate array allocations and call-stack expansions during data processing and objective scoring loops.

🔬 Measurement: Observe lower GC pressure in traces and confirm that the test suite still passes successfully with identical output.


PR created automatically by Jules for task 114777708485744154 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 9, 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-09T10:09:20.356342Z e30e48d 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.

@github-actions

github-actions Bot commented Sep 9, 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
dieterolson enabled auto-merge (squash) September 9, 2026 14:58
@dieterolson
dieterolson force-pushed the bolt-optimization-math-max-map-114777708485744154 branch from f857bca to bbf7f9e Compare September 9, 2026 16:48
dieterolson pushed a commit that referenced this pull request Sep 9, 2026
@dieterolson
dieterolson force-pushed the bolt-optimization-math-max-map-114777708485744154 branch 2 times, most recently from 250fb9d to 41ecb63 Compare September 10, 2026 01:20
@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 161 tracked file(s) with no acknowledgement

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

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
docs/development/impact-acoustics/DISTRIBUTED_MODEL_INPUTS.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-math-max-map-114777708485744154 branch from a262a84 to e82aa8f Compare September 10, 2026 10:28
Using Math.max(...array.map()) allocates intermediate arrays and uses the spread operator, which can cause stack overflows and high garbage collection pressure for large arrays. This commit replaces those chains with memory-efficient single-pass or loops in �uditForceSourceFairness.ts, orceSourceArtifact.ts and orceSourceStudy.test.ts.

Co-authored-by: dieterolson <198168927+dieterolson@users.noreply.github.com>
@dieterolson
dieterolson force-pushed the bolt-optimization-math-max-map-114777708485744154 branch from e82aa8f to 37d9b39 Compare September 10, 2026 10:55
@dieterolson
dieterolson merged commit 2c3ab05 into main Sep 10, 2026
27 of 29 checks passed
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