Skip to content

ci(measure): mesh_bodies_vs_ifc scores its bodies on every CPU and skips the sliver pairs that cannot be nearest, with the same output (#1237) - #1320

Merged
DrunkOnJava merged 8 commits into
mainfrom
ci/mesh-bodies-speed
Nov 4, 2026
Merged

DrunkOnJava merged 8 commits into
mainfrom
ci/mesh-bodies-speed

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

tools/re/mesh_bodies_vs_ifc.py scores its bodies on every CPU, finds the vertices of a body with a lexsort instead of np.unique(axis=0), and skips the sliver triangles that cannot be a point's nearest. Every line it prints is the same on every model.

Motivation

The scorer took 75 to 85 s of each BIM4LCA office shard (run 41760244593's timings.log, EPYC 7763; the shard's saved_meshes_vs_ifc 215 s, schema-validate 168 s and wall_heights_vs_ifc 149 s are longer steps), all of it on one CPU. On the faster runners of run 41767184413 the old scorer took 14 to 16 s. Follows #1311, which shards each side.

Where its time goes, measured on the office permit pair (a warm mesh cache, as in Measure, where saved_meshes_vs_ifc meshes first in the same task):

  • Meshing is not the cost in Measure: mesh_parts reads both files' bodies from the cache in 0.0 s (run 41762111248). Alone and cold it is 13 s for rvt-rs's IFC and 56 s for Revit's (run 41762114063), which the cache already removes.
  • The scoring loop is 41.2 s of 46.0 s (a fast runner), 1,068 surface_distance calls: 622 exhaustive ones 4.3 s, 446 pruned ones 32.6 s. cProfile: distances 27.1 s, sample (np.unique(axis=0)) 3.9 s, ifcopenshell.open 3.4 s for both files.
  • Inside the pruned path (run 41763294622, instrumented distances): the sliver pass, 25,117 calls of 8 triangles against every point, is 16.6 s of the 34.9 s serial loop.

Changes

  • tools/re/mesh_bodies_vs_ifc.py:
    • score_pair / score_all: each body (its volume ratio and both surface_distance calls) is one task of a fork process pool over the CPUs (RVT_MESH_WORKERS sets the count, as for mesh_parts), heaviest first, collected in tags order, so the printed rows and rankings are built from the same values in the same order. Fewer than 16 bodies, or one CPU, score in this process; a dead worker falls back to scoring in this process.
    • the sliver pass measures a point against a sliver only when the point is within the nearest distance found plus the slack of the sliver's box or of its plane. A sliver's inside cannot be trusted, so its plane distance (|height|, which distances gives for a point it takes as inside) is part of the bound, and the distance to any of its three edges is no less than the distance to its box. A pair that is measured goes through the same distances arithmetic as before.
    • sample sorts the vertices with np.lexsort and drops repeats, which is np.unique(axis=0) without its structured-array comparison.
    • a worker stops at its next body when its parent has died (the getppid check ifc_common.mesh_parts uses), and an RVT_MESH_WORKERS that is not a number means the CPU count.
  • No change to ifc_common.py, the cache paths, measure.yml or measure-reference-models.sh.

Testing

Unit tests are banned in this repository: none added. Checked end to end on the BIM4LCA office files (CC BY-SA 4.0, research/bim4lca-measure.tsv) in Measure:

  • Same-process A/B on one runner (EPYC 7763, run 41764599268, the office permit pair, 534 bodies): the main-branch scorer 40.7 s serial; this scorer 21.9 s serial and 8.9 s with 4 processes; all 534 x 3 results (volume ratio and both distances) equal as floats, 0 mismatches (res_new == res_old). The stages of the 21.9 s: setup 0.9, block bounds and seeds 5.0, pair pass 4.4, sliver pass 6.1 (6.9 M of 78 M sliver pairs measured), exhaustive about 3.5, sample 0.7.

  • Threads instead of processes: 16.0 s against 13.1 s on 4 CPUs (run 41763294622), so processes.

  • sample: byte-identical to np.unique(axis=0) on all 1,068 samples of the office pair.

  • Filtered Measure with base=main (run 41765844976, models: both office files, core-interior, re1-architecture, three r2025 models, scorers saved_meshes_vs_ifc mesh_bodies_vs_ifc): mesh_bodies_vs_ifc.txt byte-identical (cmp) head against base on all 7 models, empty compare-scorer-diff.

  • Unfiltered Measure, base=main nordic r2025 samples holdout (run 41767184413, head 6cc6702): the scorer diff has no mesh_bodies_vs_ifc line (its one entry is the base side's missing terrain models, a BIM4LCA host failure handled in ci(measure): the BIM4LCA office and R2025 models are restored from the Actions cache and saved from main (#1237) #1322), and cmp finds the office permit and as-built mesh_bodies_vs_ifc.txt byte-identical head against base.

  • What that run's step times do not show: mesh_bodies_vs_ifc took 19.5 s (permit, EPYC 9V74) and 16.5 s (as-built, EPYC 9V45) on the head side, 14.5 s (EPYC 9V45) and 15.6 s (Xeon 6975P-C) on the base side. Head and base ran on different CPUs, and saved_meshes_vs_ifc in the same runs took 164 s and 134 s against 119 s and 142 s, so those times compare machines, not code. The same-process A/B above is the evidence of the gain; a same-runner measurement of the whole shard has not been made.

  • Verified end to end on real Revit files: the command, the files and the result are above; the reproduce command is gh workflow run measure.yml --ref <ref> -f ref=<sha> -f base=main -f nordic=true -f models="nordic-office-*" -f scorers="saved_meshes_vs_ifc mesh_bodies_vs_ifc"

  • If this is a performance change: the before / after is above (Measure, not tools/bench.sh, which times the exporter)

  • tools/check-local.sh: not run (no Rust, workflow or documented-behaviour change; a Python scorer under tools/re/ only)

Audit-honesty checklist

  • README / docs: no claim changes
  • No user-visible change, so no changelog.d/ fragment
  • No new limitation. The pool is a fork pool, so the scorer needs a platform with fork (Linux, macOS), as mesh_parts does
  • No emojis, no private paths or addresses

Legal and contribution hygiene

  • Apache-2.0
  • No Autodesk proprietary source or SDK content
  • No new fixtures

Breaking changes

None. The scorer's output is byte-identical.

Output samples

Run 41765844976, cmp of mesh_bodies_vs_ifc.txt, head against base:

nordic-office-permit identical
nordic-office-as-built identical
core-interior identical
re1-architecture identical
r2025-12_Rooms_Door_Windows identical
r2025-13_Rooms_Stairs identical
r2025-17_Rooms_Stairs_Spiral identical

Related issues

Refs #1237, as #1311 and #1318 (the shards) do.

@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 04:23
@DrunkOnJava DrunkOnJava changed the title ci(measure): mesh_bodies_vs_ifc scores its bodies on every CPU and skips the sliver pairs that cannot be nearest, with the same output ci(measure): mesh_bodies_vs_ifc scores its bodies on every CPU and skips the sliver pairs that cannot be nearest, with the same output (#1237) Nov 4, 2026
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 4, 2026 04:23
@DrunkOnJava
DrunkOnJava merged commit 3b40e5e into main Nov 4, 2026
27 checks passed
@DrunkOnJava
DrunkOnJava deleted the ci/mesh-bodies-speed branch November 4, 2026 04:31
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.

1 participant