Phase5 ImportPerf — large STEP import benchmark
Reproducible kernel-side import benchmark for the question "is the UI slow to import because of the UI or the kernel?". The repository has no UI code; this tool measures the kernel-side UI-style pipeline:
STEP file -> import_step() -> per-body to_mesh(0.1) -> scene combine -> GLB write
Fixtures
gen_large_step.py copies the 9.45 MB / 5120-face template
(build-curves2/probe/fixtures/big.stp, 40 bodies) N times and re-numbers all
STEP entity ids, producing one multi-body file:
| name | size | bodies | faces |
|---|---|---|---|
| big_x1.stp | 9.45 MB | 40 | 5,120 |
| big_x5.stp | 49.4 MB | 200 | 25,600 |
| big_x20.stp | 201.9 MB | 800 | 102,400 |
gen_large_step.ps1 is a slower PowerShell fallback; the runner uses Python.
Run
powershell -ExecutionPolicy Bypass -File tools/import_bench/run_import_bench.ps1 `
-Tag baseline -Reps 3
The runner:
- generates/caches the fixtures under
build-curves3/import_bench/fixtures; - builds
import_bench.cppagainst the currentbuild-curves3/src/*.a; - runs
Repstiming runs withVDE_IMPORT_PROFILEunset (no profiling overhead) andRepsprofile runs withVDE_IMPORT_PROFILE=1 --import-onlyto collect[import-profile]stage ms; - writes
build-curves3/import_bench/results/import_bench_<tag>_<stamp>.{json,md}.
Stage meanings ([import-profile]): read file bytes, parse DATA entity
parse + complex resolve, meta PMI/colour/layer/family metadata scan,
convert entity map -> BrepModel bodies, post rectangularization/diagnostics,
total full import_step wall clock (includes entity-map teardown, see note).
Kernel optimizations (semantics unchanged)
evaluate_import_metadatano longer copies the whole entity map (wasO(entities)deep copies every import).StepToBrep::find_product_namecaches the file-level PRODUCT name through the entity type index; previously it scanned the full entity map once per body →O(bodies × entities), the dominant 20x cost.StepParserholds a reference to the input text (no whole-file copy), entity map reserve raised to 8M entries with a closer size estimate, type index bucket reserve reduced from all-entities to 512.- File read reserves the file size first; token
consume()moves instead of copying; profilingScopedStageis a stack object (no per-face heap allocs).
Measured results (median of 3, Windows, shared machine — rerun on idle host)
Import-only, profiling off (ms):
| case | import before | import after | read | parse | meta | convert |
|---|---|---|---|---|---|---|
| 1x (9.45 MB) | 631 | 556 | 10→5 | 136→171 | 170→67 | 230→207 |
| 5x (49.4 MB) | 2,950 | 2,616 | 48→28 | 773→866 | 835→357 | 1,155→1,283 |
| 20x (201.9 MB) | 35,742 | 11,992 | 342→157 | 3,438→3,264 | 3,913→1,648 | 29,460→4,781 |
20x is ~3.0x faster overall and ~6.2x faster in convert; 9/50 MB improve less
because the removed O(bodies×entities) scan only dominates at many bodies.
Residual total - sum(stages) (~2 s at 20x) is entity-map teardown.
Optimized UI-style pipeline (clean run, median): import / to_mesh / scene+GLB / total = 466/1130/1550/3146 ms (1x), 2680/7226/8253/18158 ms (5x),
14684/40804/66779/122267 ms (20x). Import share is ~12–15 %; tessellation +
scene combine + GLB write are ~85–88 %. The baseline full pipeline at 20x had
import 31 % (57,008 ms of 182,738 ms). Bodies/faces/triangles/GLB bytes are
identical before/after at all sizes (semantic equivalence check).
Conclusion: the kernel import scales linearly after the O(N²) fix and is a minor part of the UI-style pipeline; viewport tessellation and draw-scene build dominate. A front end reporting "import slow" must break its own read/tessellate/scene-upload phases; for multi-body files the old kernel product-name scan was the only super-linear hotspot.