René's URL Explorer Experiment


Title: Proposal: batch relationship handling for ExtractElements / append_asset (measured ~200x on a real model) · Issue #8952 · IfcOpenShell/IfcOpenShell · GitHub

Open Graph Title: Proposal: batch relationship handling for ExtractElements / append_asset (measured ~200x on a real model) · Issue #8952 · IfcOpenShell/IfcOpenShell

X Title: Proposal: batch relationship handling for ExtractElements / append_asset (measured ~200x on a real model) · Issue #8952 · IfcOpenShell/IfcOpenShell

Description: Raising this as a design question rather than a patch, because the interesting parts are decisions that belong to you rather than to us. Found while investigating #8945, where extracting 2,004 walls from a 495 MB IFC2X3 model takes 12.8 ...

Open Graph Description: Raising this as a design question rather than a patch, because the interesting parts are decisions that belong to you rather than to us. Found while investigating #8945, where extracting 2,004 wall...

X Description: Raising this as a design question rather than a patch, because the interesting parts are decisions that belong to you rather than to us. Found while investigating #8945, where extracting 2,004 wall...

Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/issues/8952

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: batch relationship handling for ExtractElements / append_asset (measured ~200x on a real model)","articleBody":"Raising this as a design question rather than a patch, because the interesting parts are decisions that belong to you rather than to us.\n\nFound while investigating #8945, where extracting 2,004 walls from a 495 MB IFC2X3 model takes 12.8 minutes.\n\n## The measured problem\n\n`ExtractElements` extracts a subset by calling `ifcopenshell.api.project.append_asset()` once per selected element. That function is correct for appending one asset, but it re-walks the inverse relationship graph on every invocation, including relationships shared by many elements.\n\nOn the real model, 2,004 walls take 769.9s, about 369 ms per wall, and the cost is flat from N=25 to N=2004. So it is linear with a very large constant, not a scaling problem.\n\ncProfile at N=250 shows where the constant goes:\n\n- **57.1%** in `is_another_asset` and the `by_guid` calls it triggers, walking the full `RelatedObjects` tuple of every shared relationship once per participating element. In this file one wall type's defining relationship has about 1,300 members, and each of the 2,004 selected walls re-walks it in full.\n- **18.8%** in `SafeRemovalContext.__exit__`, caused by a separate issue: the internal recursive type-append in `append_product` omits `assume_asset_uniqueness_by_name`, so it silently falls back to the default `True` even though the recipe explicitly sets `False`. We have a separate fix in flight for that one.\n- The remaining ~24% is Python/C++ boundary overhead proportional to the same re-walk.\n\nRoughly 76% of the time is work that only needs doing once per shared relationship rather than once per element.\n\n## Proposed mechanism\n\nGroup by relationship id up front instead of by element:\n\n1. For each selected element, read its own inverse relationships (`HasAssociations`, `IsDefinedBy`, type assignment). These are small, cheap, per-element lookups that never touch the large member side.\n2. Accumulate a map from relationship id to the set of selected elements referencing it.\n3. Build each filtered relationship once, at the end, from that map.\n4. Let `file.add()` handle bulk copying. It already deduplicates shared forward-reachable entities at the C++ level, so no engine work is needed. It deliberately does not touch the relationship side, which is correct, since doing so would drag in every other member.\n\n## Evidence\n\nAll on the real 495 MB file, running unmodified `append_asset.py` and `ExtractElements.py` (diffed byte-identical against source to rule out a stale sandbox).\n\nFull N=2004: closure 0.86s (339,006 entities, 15,567 relationship groups), copy and relate 1.60s, write 1.16s. **Total 3.62s against roughly 755s of algorithmic work today**, excluding the ~15s parse that is unavoidable either way.\n\nSame process, N=100, both paths back to back: **47.16s versus 0.76s**.\n\nCorrectness at N=100: 100/100 walls present in both. GlobalId sets 1,756 versus 1,716, 95.8% match. Of 67 classes, 32 differ in count, and **every difference is smaller in the batch output, never larger**. No fan-out to sibling walls of a shared type, no duplication of shared types or materials.\n\nThe 4.2% gap is fully accounted for, not unexplained: the prototype does not yet implement `StyledByItem`, `LayerAssignment(s)`, material `HasRepresentation`, or `HasShapeAspects`, which explains the missing styling and shape-aspect entities and the geometry that cascades from them. Those are mechanical additions to a pattern already working for materials, property sets and types.\n\n## The questions that are actually yours\n\n**1. `IfcOwnerHistory` semantics.** The current path mints a fresh `IfcOwnerHistory` on each type assignment via `assign_type`. The prototype reuses the original. Reusing arguably reflects reality better for an extraction, since nothing was edited and a synthetic edit trail is misleading, but that is a decision about what an extracted file's provenance should say. We did not want it decided implicitly inside a performance change.\n\n**2. Where should this live?** Inside `append_asset.py` as a batch entry point, or in `ExtractElements.py` calling a lower-level primitive? `append_asset` is used well beyond ifcpatch, including Bonsai's own append flows, so this needs your steer. Note there is also a separate constant-factor optimisation pass in flight on that same file; this is a different lever and the two are not mutually exclusive, but they need sequencing.\n\n**3. Which relationship classes are in scope?** The prototype handles only those present in this one file. A real version needs the full whitelist from `append_asset.py` and confirmation that each batches the same way without behaviour change.\n\n## Honesty check\n\nThis is a prototype built to answer \"is this worth proposing\", not production code. It has been run against exactly one model, never against Bonsai's append flows, and four whitelist branches are knowingly missing rather than merely untested. The speed numbers are real, measured and reproducible. The correctness claim is \"structurally right, demonstrably incomplete in specific enumerated ways\", not \"done\".\n\nIf the mechanism looks sound we are happy to build it properly. We would rather have your answer on the owner-history question and the placement question before writing anything real.\n\ncc @aothms @Moult\n\nThis proposal was prepared with the assistance of an AI tool.\n","author":{"url":"https://github.com/petruconduraru","@type":"Person","name":"petruconduraru"},"datePublished":"2026-07-25T07:07:47Z","url":"https://github.com/IfcOpenShell/IfcOpenShell/issues/8952"}

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/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c5a97d4c-0407-ad63-ad10-21c823e48f89
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE6AA:2D6F70:4E6773:6E2CC8:6B0472B1
html-safe-nonceb9b140e4c80f3a2cdfe76f273ef8b82c32d99a2a7c260fb01bebb8dce0e4f370
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkFBOjJENkY3MDo0RTY3NzM6NkUyQ0M4OjZCMDQ3MkIxIiwidmlzaXRvcl9pZCI6IjY4NzUwMzEzODg4OTk1Mzc1ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacfec506008b7a1eeb7a28afbda8eefb7c42edf56507b6556e16d3c9c640dc05fc
hovercard-subject-tagissue:4974694820
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/IfcOpenShell/IfcOpenShell/8952/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d61c52e171815a8868f135ac7043751cc3623ad79788ff317b709981525c6d33/IfcOpenShell/IfcOpenShell/issues/8952
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d61c52e171815a8868f135ac7043751cc3623ad79788ff317b709981525c6d33/IfcOpenShell/IfcOpenShell/issues/8952
og:image:altRaising this as a design question rather than a patch, because the interesting parts are decisions that belong to you rather than to us. Found while investigating #8945, where extracting 2,004 wall...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepetruconduraru
hostnamegithub.com
expected-hostnamegithub.com
Noneae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f
turbo-cache-controlno-preview
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
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecfb5f24c6e01d85f70804652a5107e5cac03a161
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/IfcOpenShell/IfcOpenShell/issues/8952#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FIfcOpenShell%2FIfcOpenShell%2Fissues%2F8952
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%2Fissues%2F8952
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=IfcOpenShell%2FIfcOpenShell
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8952
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8952
Reloadhttps://github.com/IfcOpenShell/IfcOpenShell/issues/8952
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 requests937 (937)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
https://github.com/IfcOpenShell/IfcOpenShell
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8952
New issuehttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8952
Proposal: batch relationship handling for ExtractElements / append_asset (measured ~200x on a real model)https://github.com/IfcOpenShell/IfcOpenShell/issues/8952#top
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
https://github.com/petruconduraru
petruconduraruhttps://github.com/petruconduraru
on Jul 25, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8952#issue-4974694820
#8945https://github.com/IfcOpenShell/IfcOpenShell/issues/8945
@aothmshttps://github.com/aothms
@Moulthttps://github.com/Moult
petruconduraruhttps://github.com/petruconduraru
on Jul 25, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8952#event-28483704112
Bonsai: report real progress while a patch recipe runs, instead of fr…https://github.com/BIMvoice/IfcOpenShell/commit/88702923ac18a1f2f7c748b1c52042ea0889ed57
8870292https://github.com/BIMvoice/IfcOpenShell/commit/88702923ac18a1f2f7c748b1c52042ea0889ed57
https://github.com/petruconduraru
petruconduraruhttps://github.com/petruconduraru
on Sep 7, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8952#issuecomment-5571026977
ifcpatch(ExtractElements): keep every element on its presentation layer (#9008) #9050https://github.com/IfcOpenShell/IfcOpenShell/pull/9050
Consolidated ExtractElements fixes based on BIMvoice proposals #9422https://github.com/IfcOpenShell/IfcOpenShell/pull/9422
@PahlawanJoeyhttps://github.com/PahlawanJoey
#9422https://github.com/IfcOpenShell/IfcOpenShell/pull/9422
#9422https://github.com/IfcOpenShell/IfcOpenShell/pull/9422
#9422https://github.com/IfcOpenShell/IfcOpenShell/pull/9422
#8870https://github.com/IfcOpenShell/IfcOpenShell/issues/8870
#9050https://github.com/IfcOpenShell/IfcOpenShell/pull/9050
#9241https://github.com/IfcOpenShell/IfcOpenShell/pull/9241
#9050https://github.com/IfcOpenShell/IfcOpenShell/pull/9050
@Andrej730https://github.com/Andrej730
petruconduraruhttps://github.com/petruconduraru
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
on Sep 7, 2026https://github.com/IfcOpenShell/IfcOpenShell/issues/8952#event-30692768713
Sign up for freehttps://github.com/signup?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8952
Sign in to commenthttps://github.com/login?return_to=https://github.com/IfcOpenShell/IfcOpenShell/issues/8952
PR ProposedA PR has been proposed for this bug/feature.https://github.com/IfcOpenShell/IfcOpenShell/issues?q=state%3Aopen%20label%3A%22PR%20Proposed%22
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-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.