Skip to content

perf(topology): share the edge arenas between a B-rep and its classification snapshot - #1037

Merged
github-merge-queue[bot] merged 1 commit into
tangency-labs:mainfrom
ablasik:perf/brep-snapshot-share-edges
Oct 26, 2026
Merged

github-merge-queue[bot] merged 1 commit into
tangency-labs:mainfrom
ablasik:perf/brep-snapshot-share-edges

Conversation

@ablasik

@ablasik ablasik commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

curve_on_classify clones the whole B-rep (clone_sharing_surface_caches) for every curve it classifies and drops the copy afterwards. On a 269-face boolean from a battery model this clone was about half of the cut's samples, and the edge and edgeuse arenas were 72% of each copy.

The classification snapshot now shares those two arenas with the source B-rep through an Arc and copies one only when something writes to it (Arc::make_mut in DerefMut). Every writer therefore sees exactly what the deep copy gave it. Plain Brep::clone stays deep. The diff is one file, crates/solidcore/src/topology.rs.

Measured on that model: eight sequential boolean_difference cuts of a 269-face body by 14-face tools (macOS arm64, release, main 329e22c, 3 interleaved runs each):

main this PR
first cut 1.75–1.96 s 1.03–1.04 s
all eight cuts 22.1–24.5 s 11.4–11.6 s
result vol 30007.566872, f/e/v 381/1211/818 identical

Validation, on Linux arm64 (ci.yml steps reproduced locally): fmt, both clippy runs (including --features difftest/cpp), workspace tests, runner tests with C++, wasm and publish dry-run. On the previous base, the --green sweep showed only failures that occur identically on clean main on arm64, and 42 units that go through curve_on_classify and the Booleans gave output identical to main.

x86_64 parity is left to this PR's CI. No tolerances or cases changed.

…ication snapshot

curve_on_classify clones the whole B-rep (clone_sharing_surface_caches) for
every curve it classifies and drops it afterwards; on a 269-face boolean this
was about half of the cut, and the edge and edgeuse arenas were 72% of each
copy. The snapshot now shares those two arenas through an Arc and copies one
only when something writes to it (Arc::make_mut in DerefMut), so every writer
sees exactly what the deep copy gave it. Plain Brep::clone stays deep.

@bherbruck bherbruck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved by the automated first-pass review: CI green, mergeable, no CI/build/dependency file changes, no red-flag patterns in added code (process/network/env/unsafe outside FFI/blobs/hidden unicode), 0 known-mismatch entries added. Logic is gated by CI and the difftest merge queue.

@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@bherbruck
bherbruck removed this pull request from the merge queue due to a manual request Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 25, 2026
@bherbruck

Copy link
Copy Markdown
Collaborator

The merge queue removed this twice (failed checks, run with jobs clippy/test). Against current main it no longer compiles: crates/solidcore/tests/curve_cache_memo.rs:173 assert_send::<Brep>() fails with RefCell<BreakCache> / Cell<bool> / Cell<f64> cannot be shared between threads safely. #992 (now on main) memoises curve caches in Cell/RefCell inside the curve value, so sharing the edge arenas between a B-rep and its snapshot (presumably through Arc) needs those curves to be Sync, and they aren't. Brep has to stay Send. Could you merge main and rework the sharing, for example Rc plus a per-snapshot copy, or keep the memo out of the shared part?

@github-merge-queue
github-merge-queue Bot merged commit e106115 into tangency-labs:main Oct 26, 2026
13 checks passed
saosebastiao pushed a commit to saosebastiao/solidcore that referenced this pull request Oct 26, 2026
…t-share-edges-on-main

stack: tangency-labs#1037 (share edge arenas with the classification snapshot) merged with main, Send-safe
@ablasik
ablasik deleted the perf/brep-snapshot-share-edges branch October 26, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants