Repository navigation
Faster curved subtracts and a call to release idle display geometry - #46
Merged
Merged
Conversation
…t the first branch Small curved subtracts, such as a WC pan cut from its shelled body, spent almost all their time rebuilding the same trim polygons on every membership probe, revalidating both bodies for every face pair, and finishing the whole body intersection graph in the non-intersecting handler after the first branch had already decided it. A face trim now holds the sampled loops and band limits of one face and answers the same tests in the same order, rebuilding a loop only where the old code would have failed; the clip builds the two trims once per branch, the body graph validates both bodies once, and the non-intersecting handler stops at the first coincident or branching pair. Results, handlers and attempted lists are unchanged; the WC pan and seat subtracts and the face trim answers are pinned to values recorded before the change.
The record pool keeps up to two unreferenced display records per shape so a level-of-detail switch back is instant. A renderer that drew those records leaves its dispose listener on each one, so after an app disposes a renderer, its buffer state stays reachable through the idle records until they are evicted. The new call disposes every idle record and reports how many records and bytes it released, so an app that replaces its renderer can drop that state at once. Records in use by displayed bodies are kept.
After the face trims were cached, the WC pan subtract still spent about half its time in the point-in-trim loop, measuring every probe's exact distance to every trim segment through the software fused multiply-add and hypot of the wasm build. A segment whose bounding box, widened by twice the tolerance plus a rounding margin, does not reach the probe cannot be within tolerance of it, so its exact distance is skipped; the crossing count still visits every segment and non-finite values take the exact path. Every answer is unchanged, and a test pins the boundary band on both sides of a trim edge and corner.
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.
Summary
Three changes on top of the display bounds cache that is already on
main(#45):OpenGeometry.releaseIdleGeometry(). A new call that disposes every idle display record (records kept for a quick level-of-detail switch back) and returns{ records, bytes }. A three.js renderer leaves adisposelistener on every geometry it draws. After an app disposes a renderer, that renderer's buffer state stays reachable through the idle records until they are evicted. This call frees it at once. Records used by displayed bodies are kept.Results
Exact B-rep results do not change: no golden key moved, and the kernel snapshot is identical to
main.Subtract times, in ms, median of 5, through the SDK in node (inline kernel):
Orbit with the display bounds cache from #45 together with this branch: a four-storey architectural model in a three.js app, hardware WebGL (Apple M2 Max), median of 3 orbits of 3 s. Frame time goes from 116.7 ms (p90 125) to 16.6 ms (p90 17.2, at the refresh limit). The level-of-detail pass goes from 78 % to 1.2 % of CPU time.
Behaviour notes
handlersandattemptedare unchanged.static releaseIdleGeometry(): { records: number; bytes: number; }. The README "Display" row lists it.Tests
releaseIdleGeometry: Node tests show that idle records are disposed and counted, installed records survive, a released bucket is requested again, and the call returns zero afterreset(). A browser spec shows that every idle record keeps a disposed renderer's listener, and that after the call none is left.Checks
npm run check: 18 of 18 steps passed.mainis empty.