Skip to content

Optimize generated binding layout - #95

Closed
leileizhang (lei9444) wants to merge 3 commits into
mainfrom
perf/binding-layout-optimizations
Closed

Optimize generated binding layout#95
leileizhang (lei9444) wants to merge 3 commits into
mainfrom
perf/binding-layout-optimizations

Conversation

@lei9444

Copy link
Copy Markdown
Contributor

Summary

  • Add opt-in shared required-interface prototype descriptors with --shared-interface-members.
  • Add a bundle subcommand for canonical CommonJS dependency bundles.
  • Preserve existing declarations, raw interface wrappers, overload dispatch, deep imports, and module identity.
  • Keep both optimizations disabled by default.

Shared interface members

Generated concrete classes currently duplicate inherited interface getter, setter, and method implementations.

With --shared-interface-members, compatible members reuse descriptors from canonical interface prototypes:

  • conflicting and overloaded members remain class-local;
  • raw interface wrappers remain available;
  • generated .d.ts files remain unchanged;
  • default generation behavior is unaffected.

Binding bundles

The new command bundles configured roots and their generated relative dependency closure:

dynwinrt-codegen bundle --output .winapp\bindings --bundle first-screen=Application,Window,Button,lifetime

It:

  • preserves external runtime imports and CommonJS cycle semantics;
  • replaces bundled per-type files with canonical redirect shims;
  • preserves root/deep CommonJS and ESM constructor identity;
  • keeps existing  .d.ts  import paths;
  • supports multiple non-overlapping bundles.

For safety, bundling requires a fresh, unbundled output directory. Existing bundle artifacts, missing roots, unsafe inventory paths, and conflicting ownership fail explicitly.

Compatibility

Both features are opt-in:

  • generation without  --shared-interface-members  is unchanged;
  • bindings are not bundled unless the  bundle  command is executed;
  • Python generation is unaffected.

Gallery measurements

Combined shared-interface and first-screen bundle layout:

  • per-type generated JS: 46.8 MB → 24.6 MB;
  • first-screen implementation files: 882 → 1 bundle plus redirect shims;
  • existing declaration files remained byte-identical.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84688dea-d965-4933-a2d9-41f8f6ad2f2e
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 80.7% 77.11% 80.6% regions
Generated Python projections 58.64% n/a 2.53% branches
JavaScript aggregate 18.19% 19.58% 50.75% branches
JavaScript runtime 19.36% 14.28% 7.14% branches
Generated WinRT projections 22.27% 20.02% 52.85% branches
Generated Classic COM projections 11.25% 18.08% 45.94% branches

View workflow run and download full HTML/LCOV/XML reports

leileizhang (lei9444) and others added 2 commits August 11, 2026 16:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84688dea-d965-4933-a2d9-41f8f6ad2f2e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 84688dea-d965-4933-a2d9-41f8f6ad2f2e
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