Skip to content

[experiment] measure binding-symbol pruning (Tier-1 aliases vs Tier-2 containers)#6312

Closed
Fedr wants to merge 1 commit into
masterfrom
ci/experiment-prune-bindings
Closed

[experiment] measure binding-symbol pruning (Tier-1 aliases vs Tier-2 containers)#6312
Fedr wants to merge 1 commit into
masterfrom
ci/experiment-prune-bindings

Conversation

@Fedr

@Fedr Fedr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Experiment — not for merge

Measure the build-time and symbol-count impact of pruning Python-binding symbols via mrbind --ignore / --skip-mentions-of, to separate two hypotheses:

  1. Tier-1 (typedef aliases): Vector_*_value_type, *_const_reference, *_iterator, etc. Per mrbind docs these become Python aliases (≈free to compile) — expected to declutter the namespace but not move build time, and --ignore may not even suppress auto-aliases.
  2. Tier-2 (obscure/nested containers): std::vector<std::vector<…>>, std::vector<std::array<…>>, std::optional<std::variant<…>>, std::variant<…Polynomial…>, etc. — these are real py::bind_vector/container instantiations (the hot stl_bind.h cpp_functions in the -ftime-trace profile), so this is the actual build-time lever.

Method

A single same-runner step (vcpkg x64, Release, Clang 21) does 3 full bindings rebuilds with -B, appending flag lines to the shared scripts/mrbind/mrbind_flags.txt between stages:

  • BASELINE (unmodified flags)
  • +TIER1 (typedef-alias --ignore)
  • +TIER2 (additionally the obscure-container --skip-mentions-of)

Each stage reports wall time and len(dir(mrmeshpy)) (symbol count via import). Same runner → clean deltas. Flags are edited at runtime only (nothing committed) — this is a measurement, not a change.

Because the flags live in mrbind_flags.txt (loaded by generate.mk for every platform/config), whichever ignores prove worthwhile would apply everywhere with a one-line edit.

CI scoped to linux-vcpkg only (other platforms disabled via labels).

@Fedr

Fedr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing — experiment complete (not for merge).

Measured the build-time / symbol-count impact of mrbind --ignore pruning (vcpkg x64, Clang 21, same-runner 3-stage -B rebuild):

stage wall mrmeshpy symbols
baseline 665.4 s 2793
+Tier-1 (typedef-alias --ignore) 666.3 s 2628 (−165)
+Tier-2 (nested-container --skip-mentions-of) build failed

Findings:

  • Tier-1 (value_type/reference/iterator/… aliases): --ignore does remove them (−165 symbols) but build time is unchanged (+0.9 s, noise). They're Python aliases, not compile cost → namespace cleanup only, no build-time benefit.
  • Tier-2 (blanket --skip-mentions-of on nested containers) breaks the build: skipping a container type that's an aggregate-struct member leaves the struct's generated aggregate constructor referencing a now-unbound type (overload ambiguity std::vector(size_type) vs MR::Id's implicit →int). Carpet-pruning containers by regex cascades.

Conclusion: there's no free --ignore-regex win for the bindings build time. The cost is the bound container types + per-function cpp_functions; pruning them en masse breaks generated code. Real levers = surgical per-symbol API reduction (validate each, handle the aggregate cascade) or more vCPUs (the build is ~98% parallel → scales wall down with zero API loss).

@Fedr Fedr closed this Jun 23, 2026
@Fedr Fedr deleted the ci/experiment-prune-bindings branch June 23, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant