Skip to content

Evaluate inferred modules for SDK compile performance - #1653

Draft
corymhall wants to merge 3 commits into
masterfrom
triage/go-sdk-1652
Draft

Evaluate inferred modules for SDK compile performance#1653
corymhall wants to merge 3 commits into
masterfrom
triage/go-sdk-1652

Conversation

@corymhall

Copy link
Copy Markdown
Member

This draft evaluates inferred modules as an option for the Go SDK compile-time and memory problem in #1652.

New resources and functions use inferred product-family modules, while hard compatibility clones retain the complete v6.19 index surface. Existing programs remain source compatible; migrated Go programs can import smaller packages. schema-tools reports 238 new resources, 405 new functions, 2,624 new types, and no breaking changes against v6.19.0.

Important tradeoffs:

  • Inference creates 140 modules. These generally match Terraform resource families, but some upstream names produce awkward divisions such as worker/workers and customPage/customPages.
  • The compatibility Go package remains about 29 MB. Existing users receive no compile benefit until they move imports to modular packages.
  • Keeping both surfaces greatly increases generated SDK size: the SDK commit contains 16,675 files and about 2.45 million inserted lines.
  • C# modules must use Pulumi.Cloudflare.Modules.* because retained root classes conflict with inferred namespace names. New C# resources also keep descriptive class names to avoid class/member name conflicts.
  • The v6.19 compatibility manifest is an immutable snapshot. Inference handles future resources, but this approach adds compatibility and generation complexity.

The commits intentionally separate provider logic, schema output, and generated SDKs so each part can be reviewed independently.

Validation: provider tests; all Go SDK tests; Node.js type checking; .NET and Java builds; Python compilation; schema comparison against v6.19.0.

This is a design evaluation, not a request to merge the approach as-is.

Re #1652

Summary:
- Infer modules from Terraform resource and data source names.
- Retain every v6.19 resource and function token with hard clones.
- Record the immutable v6.19 compatibility surface in a manifest.
- Avoid data source token conflicts and C# namespace conflicts.

Rationale:
- The single Go index package is too large to compile reliably.
- Hard compatibility resources keep existing programs source compatible while
  new programs can import smaller module packages.

Tests:
- cd provider && go test . ./pkg/...
Summary:
- Regenerate the provider schema and bridge metadata with inferred modules.
- Add tests for the retained v6.19 resources, functions, types, and aliases.
- Update the provider overview example to use the modular DNS resource.

Rationale:
- Keep the generated schema review separate from provider implementation and
  language SDK output.
- Verify that modular tokens are additive to the complete v6.19 surface.

Tests:
- cd provider && go test . ./pkg/...
- schema-tools compare v6.19.0 with the local schema: no breaking changes
Summary:
- Regenerate the Go, Node.js, Python, .NET, and Java SDKs.
- Add packages for all inferred Cloudflare resource families.
- Retain the complete v6.19 root SDK surface for compatibility.

Rationale:
- Keep the large generated SDK change isolated from provider and schema logic.
- Let new Go programs import small packages instead of the large index package.

Tests:
- cd sdk && go test ./go/cloudflare/...
- yarn install --frozen-lockfile && yarn run tsc
- dotnet build
- gradle --console=plain compileJava
- python3 -m compileall -q sdk/python/pulumi_cloudflare
@peter-ambiorix

Copy link
Copy Markdown

Tested this directly against the PR commit (e2460a2) rather than going on the file listing alone — pulled it as a pseudo-version and cold-compiled the two modules our program actually needs.

mkdir cf1653test && cd cf1653test
printf 'module cf1653test\ngo 1.25\n' > go.mod
GOFLAGS=-mod=mod go get github.com/pulumi/pulumi-cloudflare/sdk/v6@e2460a2014b59cbaa9c71aeb10a18453a2b06575
GOCACHE=$(mktemp -d) time GOFLAGS=-mod=mod go build \
  github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare/dns \
  github.com/pulumi/pulumi-cloudflare/sdk/v6/go/cloudflare/zone

Same machine/method as the measurements in #1652:

Wall CPU (user+sys) Peak RSS
v6.19.0 monolith (current) 326 s 769 s 4.53 GB
v5.49.1 (for reference) 26 s 98 s 3.32 GB
this PR — dns + zone only 24 s 103 s 0.91 GB

This fully resolves our case — not just "isolated cleanly" as hoped, but 3.6× lower peak memory than v5, since we're now compiling ~646 KB of actual surface (8 + 19 files) instead of the full 27 MB / 666-file provider. On a 7 GB CI runner this moves from "reliably OOMs" to a non-issue.

Happy to be a real-world data point if it's useful context for the merge decision — glad to re-test against later iterations too.

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.

2 participants