Repository navigation
Speed up exact integral grid row measurements - #2893
Merged
Merged
Conversation
alixander
marked this pull request as ready for review
September 10, 2026 15:42
pancsta
pushed a commit
to pancsta/d2
that referenced
this pull request
Nov 7, 2026
…ements Speed up exact integral grid row measurements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human
AI
Large dynamic grids repeatedly rescan row sizes when the bounded measurement cache misses. A native Studio compile profile for 3,001 grid objects spent 87% of sampled CPU time in those row sums.
Use lazy prefix sums when all sizes and the gap are nonnegative integers and their complete total, including the trailing gap used by the existing calculation, fits within float64's exact integer range of 2^53. Every intermediate remains exact, so interval subtraction and gap addition preserve the existing results. Fractional, negative, nonfinite, or oversized inputs retain the existing bounded cache and addition order. Empty and singleton intervals still avoid allocating a cache. Division traversal, search limits, and tie-breaking are unchanged.
Validation:
go test ./d2layouts/d2grid -count=1go test ./d2layouts ./d2lib -count=1