Skip to content

perf: optimize metadata generator - #52

Open
DjDeveloperr wants to merge 3 commits into
refactorfrom
optimize-metadata-generator
Open

perf: optimize metadata generator#52
DjDeveloperr wants to merge 3 commits into
refactorfrom
optimize-metadata-generator

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • speed up the Objective-C metadata generator while preserving generated output
  • add an opt-in Rust/Oxc analyzer that scans emitted JavaScript or TypeScript bundles and generates a symbol-based NativeScript metadata whitelist
  • retain the existing whitelist.mdg and blacklist.mdg filtering behavior
  • harden build integration so the analyzer is packaged for the host architecture without causing redundant metadata-generator rebuilds

How automatic filtering works

The new ns-metadata-symbols tool parses bundle files with Oxc, resolves unbound native symbols, and analyzes multiple files/chunks in parallel with Rayon. It emits deterministic NativeScript .mdg rules that the existing metadata-generator build step consumes.

This feature is opt-in:

NS_METADATA_AUTO_FILTER=1
NS_METADATA_BUNDLE_PATHS="$CONFIGURATION_BUILD_DIR/app/bundle.js"

The packaged analyzer is used automatically. NS_METADATA_SYMBOL_ANALYZER can override its path for development.

Safety and compatibility behavior:

  • existing manual whitelist entries are merged into the generated whitelist
  • blacklist.mdg is still applied after the whitelist
  • Foundation and Runtime metadata are retained by default
  • parse/semantic failures, dynamic global access, and dynamic code execution fail open by retaining all metadata
  • symbol matching intentionally prefers false positives over removing required metadata

Performance

On the full macOS SDK workload, median warm-cache results improved while all 207 generated artifacts remained byte-for-byte identical:

Measurement Baseline Optimized Change
Wall time 6.98 s 4.94 s -29.2%
User CPU 5.62 s 4.35 s -22.6%
System CPU 0.80 s 0.55 s -31.2%
Maximum RSS 1.21 GB 1.18 GB -2.6%

For a representative AppKit bundle using NSView, automatic filtering reduced binary metadata by 92.4%, signature bindings by 84.3%, and TypeScript output by 93.1%. These figures are workload-specific rather than size guarantees.

The analyzer averaged 6.5 ms across the 184-file TestRunner corpus with 18 workers, versus 9.9 ms with one worker, while producing identical output.

Validation

  • Rust analyzer unit and CLI tests: 8 passed
  • C++ metadata-filter regression test: passed
  • source, minified, and code-split bundle analysis produced byte-identical whitelists
  • malformed/dynamic TestRunner inputs verified conservative fail-open behavior
  • macOS CI: 714 tests, 0 failures
  • iOS CI: 714 specs, 0 failures
  • full CI: passed

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 240b3475-a81f-4cd0-832e-487e42a814c5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DjDeveloperr
DjDeveloperr force-pushed the optimize-metadata-generator branch from 37b4d54 to 3d8b6c2 Compare August 12, 2026 00:17
@DjDeveloperr
DjDeveloperr force-pushed the refactor branch 2 times, most recently from 3519a29 to 2125175 Compare August 20, 2026 03:55
@DjDeveloperr
DjDeveloperr force-pushed the optimize-metadata-generator branch from 3d8b6c2 to b35181f Compare August 20, 2026 04:01
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