René's URL Explorer Experiment


Title: Bonsai: reduce CPU cost of the proximity snap path by carlopav · Pull Request #9340 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: Bonsai: reduce CPU cost of the proximity snap path by carlopav · Pull Request #9340 · IfcOpenShell/IfcOpenShell

X Title: Bonsai: reduce CPU cost of the proximity snap path by carlopav · Pull Request #9340 · IfcOpenShell/IfcOpenShell

Description: Context The GPU snap detection that landed in 4cb6ce703..2b429dc60 replaces object discovery. Raycast.ray_cast_by_proximity survives it and is still the only CPU path that turns a detected object into Vertex / Edge Center / Edge snaps: detect_snapping_points calls it for the object under the cursor, and in plan/section views once per visible element carrying cut or fill decorator data. These three changes reduce the cost of that function and of Cad.intersect_edges_v2, which it calls once per edge. They are independent of how candidates are found, so they apply equally before and after the GPU work. Changes One commit each, each independently revertible: 1. Speed up Cad.intersect_edges_v2. Replace np.cross / np.linalg.norm / np.dot with explicit scalar arithmetic. On 3-element operands numpy spends far more time in its dispatch machinery (normalize_axis_tuple, moveaxis) than on the arithmetic itself. Float64 throughout, so results are unchanged. Also used by wall junctions in tool/model.py. 2. Hoist matrix_world out of the proximity loops. It was copied once per vertex and twice per edge, and cannot change while the loops run. Pure code motion: the copy is still taken, and the obj=None path used by the custom_bmesh callers is preserved. 3. Skip the line-line intersection for edges that cannot snap. Every point of an edge lies within half its length of its midpoint, whose distance to the ray the loop already computes for the Edge Center snap. By the triangle inequality no point can be nearer to the ray than midpoint_distance - edge_length / 2; once that lower bound reaches the snap threshold, intersect_edges_v2 cannot produce a hit. The predicate never rejects an edge that could snap, so snapping results are unchanged. Measurements Being explicit about what is and isn't measured: 3.8x on intersect_edges_v2 (68.95µs → 18.16µs) is a direct microbenchmark of the function and holds. End-to-end figures I collected earlier (per-event call count 52,113 → 1,869; ~370ms → ~70ms) were measured before the GPU rewrite, when ray_cast_by_proximity ran against every candidate object. They no longer describe the current architecture, so I am deliberately not claiming them here. What remains true regardless is that both changes strictly remove work while preserving behaviour. Where I would expect them to still matter most is plan and section views: the cut/fill block in detect_snapping_points came through the rewrite unchanged and still iterates every visible mesh element with cache data, rebuilding a bmesh per object per mouse move. Tests test/tool/test_cad.py — 6 characterization tests for intersect_edges_v2 (skew, crossing, parallel, collinear, 2D input, unnormalised directions), written against the previous implementation before the refactor, so it is verified behaviour-preserving rather than assumed to be. test/tool/test_raycast.py (new) — 5 tests for the early-out, including a randomised search over 3000 edges that samples 21 points along every rejected edge and asserts none lies within the threshold, with a guard so the test cannot pass vacuously. test/tool/test_cad.py test/tool/test_raycast.py — 23 passed. black --line-length 120 clean. Related Supersedes #9004, which fixed the object-origin sort in ray_cast_and_get_closest_to_camera_snaps. The GPU rewrite left that function in the file but nothing calls it any more, so the heuristic it corrected is no longer on a live path. I'll close #9004. 🤖 Generated with Claude Code Real work comparison Pre fix After fix

Open Graph Description: Context The GPU snap detection that landed in 4cb6ce703..2b429dc60 replaces object discovery. Raycast.ray_cast_by_proximity survives it and is still the only CPU path that turns a detected object i...

X Description: Context The GPU snap detection that landed in 4cb6ce703..2b429dc60 replaces object discovery. Raycast.ray_cast_by_proximity survives it and is still the only CPU path that turns a detected object i...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/9340

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:c26dbbbf-6441-e196-fe67-48601ff2495f
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB906:3FA1F8:91D4C0:C0B436:6B04D442
html-safe-noncebb4182f32c693b868c694f82548d796a65a76ac7d9201fa5c0df078f87e2cb54
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTA2OjNGQTFGODo5MUQ0QzA6QzBCNDM2OjZCMDRENDQyIiwidmlzaXRvcl9pZCI6IjQ1OTM1NDU2Mjg4NDc3NTYzNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5921bd9fde0cf3acc847baca44e5e85c3dd5211a8b98ae95d7f42b1c2b5b403f
hovercard-subject-tagpull_request:4326372979
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
twitter:imagehttps://avatars.githubusercontent.com/u/47068848?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/47068848?s=400&v=4
og:image:altContext The GPU snap detection that landed in 4cb6ce703..2b429dc60 replaces object discovery. Raycast.ray_cast_by_proximity survives it and is still the only CPU path that turns a detected object i...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None194dacb8acfd3e4d3ffb2704e0b1f10327f0dad690a7142acc7b0e0a2d073965
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git
octolytics-dimension-user_id13692563
octolytics-dimension-user_loginIfcOpenShell
octolytics-dimension-repository_id40473201
octolytics-dimension-repository_nwoIfcOpenShell/IfcOpenShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id40473201
octolytics-dimension-repository_network_root_nwoIfcOpenShell/IfcOpenShell
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release68cfb59cd750dff2f222256898e901425584e5e9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fpull%2F9340%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fpull%2F9340%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
IfcOpenShellhttps://github.com/IfcOpenShell
IfcOpenShellhttps://github.com/IfcOpenShell/IfcOpenShell
Codehttps://github.com/IfcOpenShell/IfcOpenShell
Issues1.2k (1.2k)https://github.com/IfcOpenShell/IfcOpenShell/issues
Pull requests936 (936)https://github.com/IfcOpenShell/IfcOpenShell/pulls
Discussionshttps://github.com/IfcOpenShell/IfcOpenShell/discussions
Actionshttps://github.com/IfcOpenShell/IfcOpenShell/actions
Projectshttps://github.com/IfcOpenShell/IfcOpenShell/projects
Wikihttps://github.com/IfcOpenShell/IfcOpenShell/wiki
Security and qualityhttps://github.com/IfcOpenShell/IfcOpenShell/security
Insightshttps://github.com/IfcOpenShell/IfcOpenShell/insights
Sign up for GitHub https://github.com/signup?return_to=%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2Fnew%2Fchoose
carlopavhttps://github.com/carlopav
IfcOpenShell:v0.8.0https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0
carlopav:bonsai-cad-intersect-perfhttps://github.com/carlopav/IfcOpenShell/tree/bonsai-cad-intersect-perf
Conversation 7 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340
Commits 3 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/commits
Checks 3 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/checks
Files changed https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Bonsai: reduce CPU cost of the proximity snap path https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#top
Show all changes 3 commits https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
71cfa36 Bonsai: speed up Cad.intersect_edges_v2 hot path carlopav Aug 20, 2026 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/commits/71cfa36827d97eae02012ca22bed15e001b6f043
13c7abb Bonsai: hoist matrix_world out of the proximity snap loops carlopav Aug 20, 2026 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/commits/13c7abb1a388bf9339999ea1f9235a62ed2a3ba2
219c4d1 Bonsai: skip the line-line intersection for edges that cannot snap carlopav Aug 20, 2026 https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/commits/219c4d106ca528986c626459aab75bb4d4d3fee0
Clear filters https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
cad.py https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
raycast.py https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
test_cad.py https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-dd3724fef4dbf7e7bfcbba3396e0076572274951810b3ce31107ecc8ffe91e40
test_raycast.py https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-95c672d4f7aea0e6cd3427d5d5238524ebb127e935be0acb13b4afec29689dcf
src/bonsai/bonsai/tool/cad.pyhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
View file https://github.com/IfcOpenShell/IfcOpenShell/blob/219c4d106ca528986c626459aab75bb4d4d3fee0/src/bonsai/bonsai/tool/cad.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/{{ revealButtonHref }}
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-93d4e19e1f5cc31b17ef50a269b89c2e3c2f6a025310b9ed46979d52aa5eead3
src/bonsai/bonsai/tool/raycast.pyhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
View file https://github.com/IfcOpenShell/IfcOpenShell/blob/219c4d106ca528986c626459aab75bb4d4d3fee0/src/bonsai/bonsai/tool/raycast.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/{{ revealButtonHref }}
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-ecd4c6a56e77cbb5f46b8f694ca76d2475d5e302ab1d06761fa405335e5cf6c9
src/bonsai/test/tool/test_cad.pyhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-dd3724fef4dbf7e7bfcbba3396e0076572274951810b3ce31107ecc8ffe91e40
View file https://github.com/IfcOpenShell/IfcOpenShell/blob/219c4d106ca528986c626459aab75bb4d4d3fee0/src/bonsai/test/tool/test_cad.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/{{ revealButtonHref }}
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-dd3724fef4dbf7e7bfcbba3396e0076572274951810b3ce31107ecc8ffe91e40
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-dd3724fef4dbf7e7bfcbba3396e0076572274951810b3ce31107ecc8ffe91e40
src/bonsai/test/tool/test_raycast.pyhttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files#diff-95c672d4f7aea0e6cd3427d5d5238524ebb127e935be0acb13b4afec29689dcf
View file https://github.com/IfcOpenShell/IfcOpenShell/blob/219c4d106ca528986c626459aab75bb4d4d3fee0/src/bonsai/test/tool/test_raycast.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/IfcOpenShell/IfcOpenShell/pull/9340/{{ revealButtonHref }}
Please reload this pagehttps://github.com/IfcOpenShell/IfcOpenShell/pull/9340/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.