A block measured every child's bounding box twice - #1232
Open
redbluevn wants to merge 2 commits into
Open
Conversation
BlockRecord.GetBoundingBox called item.GetBoundingBox() once to test whether the extent was infinite and again to merge it. That is twice per entity at one level - and blocks nest, so a block whose children are inserts of blocks whose children are inserts costs 2^depth evaluations of the same boxes. Measured on an architectural drawing of 188,000 entities, warm cache, three runs each: 8s before, then 5s/5s/4s. That is whole-run wall clock including parsing a 19 MB file, so the share actually spent measuring boxes fell by considerably more than the 40% the total shows. No behaviour change: the same box is computed, once. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
DomCR
reviewed
Aug 31, 2026
| if (item.GetBoundingBox().Extent == BoundingBoxExtent.Infinite | ||
| && ignoreInfinite) | ||
| //Once per entity. Asking twice - once to test the extent, once to merge - doubles the | ||
| //work at every level of nesting, so a block three deep was measured eight times over. |
DomCR
approved these changes
Aug 31, 2026
Asked for in review of DomCR#1232. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ceo4HJNunc2XfA9PnLCpQK
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.
item.GetBoundingBox()is called once to test the extent and again to merge it.That is twice per entity at one level — but blocks nest.
Insert.GetBoundingBox()callsBlock.GetBoundingBox(), so a block whose children are inserts of blocks whose children are inserts costs2^depthevaluations of the same boxes. Some of those evaluations are not cheap:ArcandCirclesample 256 points,Ellipse100,Splineup to 256.Measurement
An architectural drawing of 188,000 entities, warm file cache, three runs each, reading the file and computing every model-space entity's box:
That is whole-run wall clock including parsing a 19 MB DWG, so the share actually spent measuring boxes fell by considerably more than the 40% the total shows.
Behaviour
Unchanged. The same box is computed, once, and used for both the test and the merge.
dotnet test: 2313 passed / 17 failed — identical tomasterat 592d70a on this machine, as expected for a change that adds no tests and alters no results.