Skip to content

Add Pyodide patch to remove redundant Python calls during the bootstrap - #8386

Merged
ryanking13 merged 1 commit into
mainfrom
gyeongjae/finalize-bootstrap-skip-run-python
Nov 17, 2026
Merged

ryanking13 merged 1 commit into
mainfrom
gyeongjae/finalize-bootstrap-skip-run-python

Conversation

@ryanking13

Copy link
Copy Markdown
Contributor

Adds a patch to apply upstream Pyodide PR to workerd (pyodide/pyodide#6534).

This removes expensive Python AST parse / Python function calls during the bootstrap to improve the cold start.

@ryanking13
ryanking13 requested review from a team as code owners November 12, 2026 07:24

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of a9900bcb.

This review, of feb3cdca

💬 Approved with comments — The patch logic is well guarded and matches the upstream change. The only note is an informational one about unrelated churn in MODULE.bazel.lock, including a transitive downgrade of hermetic_launcher.

Findings: 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

Patch logic is sound; the lockfile has unrelated transitive dependency churn.

Recommendation: 💬 Optional Nits

  • [INFO] MODULE.bazel.lock downgrades hermetic_launcher from 0.0.17 to 0.0.16 and adds other entries unrelated to the Pyodide bump. (MODULE.bazel.lock:145)
View full review
  • The finalizeBootstrap patches are strict: each one has expected: 1, matches an exact literal or shape, and throws when the structure doesn't match.
  • MODULE.bazel.lock also changes things the Pyodide bump doesn't explain: hermetic_launcher goes from 0.0.17 to 0.0.16, aspect_tools_telemetry gains 0.5.2 entries, and new extension entries appear for protobuf, rules_android and rules_rust. This usually means the lock was regenerated against an older main or with a different Bazel or registry state.

✅ All other checks passed

🚀 Release: ✅ LGTM

Low risk: the dependency bundle bump has updated integrity hashes.


🔒 Security: ✅ LGTM

The bundle URL host is unchanged, and the new sha256 integrity hashes are pinned. The AST rewrite runs at build time on fixed matches and takes no untrusted input.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md concerns.


⚡ Performance: ✅ LGTM

Removing the Python source compilation and execution from finalizeBootstrap should reduce cold-start cost.


📝 Documentation: ✅ LGTM

No documentation concerns.


Reviewed commit: feb3cdca

Comment thread MODULE.bazel.lock Resolved

@hoodmane hoodmane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to make the finalizeBootstrap: import _pyodide_core only when not restoring a snapshot patch shorter, it's a bit confusing this way.

@ryanking13
ryanking13 force-pushed the gyeongjae/finalize-bootstrap-skip-run-python branch from feb3cdc to a9900bc Compare November 16, 2026 08:40

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 22faa05f.

This review, of a9900bcb

✅ Approved — No issues found. Each new patch matches exactly one call and applies only to Pyodide 314.0.6, and the earlier MODULE.bazel.lock note no longer applies because that file is no longer changed.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

No issues found in src/pyodide/bundle/patch_pyodide_asm.ts.

  • Matching: isCallWithString checks the callee path, that there is exactly one argument, and that the argument is the expected string literal. Every patch sets expected: 1.
  • Version gating: the patches apply only to version 314.0.6.
  • arguments[0]: it is the snapshotConfig parameter of finalizeBootstrap. The caller in src/pyodide/internal/snapshot.ts passes LOADED_SNAPSHOT_META?.hiwire, which is set only when a snapshot is restored.
  • [0, ""]: it has the same [status, cause] shape that rawRun returns (src/pyodide/internal/util.ts), so the error check that follows still passes.

📝 Documentation: ✅ LGTM

No documentation concerns.


Reviewed commit: a9900bcb

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of de6ec1ec.

This review, of 22faa05f

✅ Approved — No issues found. The metadata values agree with each other, and the Pyodide patches, unchanged since the last review, are each scoped to one call and only to version 314.0.6.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

No issues found.

  • Metadata: build/deps/pyodide.MODULE.bazel and build/python_metadata.bzl agree on backport 12 for Pyodide 314.0.6, and no _11 reference is left in either file.
  • patch_pyodide_asm.ts: unchanged since the last review. Each new patch matches exactly one call and is applied only for version 314.0.6.

📝 Documentation: ✅ LGTM

No documentation concerns.


Reviewed commit: 22faa05f

@ryanking13
ryanking13 force-pushed the gyeongjae/finalize-bootstrap-skip-run-python branch from 22faa05 to de6ec1e Compare November 16, 2026 08:53

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 4b738fd8.

This review, of de6ec1ec

✅ Approved — No issues found. The lockfile now has the backport-12 Pyodide bundle with the same name, URL and sha256 as the other build files, and the patches have not changed since the last review.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

  • Bundle entry: in MODULE.bazel.lock, the pyodide_314.0.6_2026-08-17_12.capnp.bin name and URL match build/deps/pyodide.MODULE.bazel and build/python_metadata.bzl.
  • sha256: the new hash is the same in the lockfile (both the _12 entry and pyodide_dev.capnp.bin) and in python_metadata.bzl.
  • Repo list: the use_repo list and the lockfile's repo-name list were updated together.
  • Transitive digest: the bzlTransitiveDigest change is what a change to pyodide.bzl produces.
  • hermetic_launcher: the earlier note about its downgrade no longer applies. The lockfile diff no longer touches it, and the author explained it was an unsynced lockfile left over from an earlier pull request.
  • Patches: src/pyodide/bundle/patch_pyodide_asm.ts has not changed since the last review.

📝 Documentation: ✅ LGTM

No documentation concerns.


Reviewed commit: de6ec1ec

@ryanking13
ryanking13 force-pushed the gyeongjae/finalize-bootstrap-skip-run-python branch from de6ec1e to 4b738fd Compare November 17, 2026 03:59

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — No issues found. The lockfile now has the backport-12 Pyodide bundle with the same name, URL and sha256 as the other build files, and the patches have not changed since the last review.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

  • Bundle entry: in MODULE.bazel.lock, the pyodide_314.0.6_2026-08-17_12.capnp.bin name and URL match build/deps/pyodide.MODULE.bazel and build/python_metadata.bzl.
  • sha256: the new hash is the same in the lockfile (both the _12 entry and pyodide_dev.capnp.bin) and in python_metadata.bzl.
  • Repo list: the use_repo list and the lockfile's repo-name list were updated together.
  • Transitive digest: the bzlTransitiveDigest change is what a change to pyodide.bzl produces.
  • hermetic_launcher: the earlier note about its downgrade no longer applies. The lockfile diff no longer touches it, and the author explained it was an unsynced lockfile left over from an earlier pull request.
  • Patches: src/pyodide/bundle/patch_pyodide_asm.ts has not changed since the last review.

📝 Documentation: ✅ LGTM

No documentation concerns.


Reviewed commit: 4b738fd8 — same changes as de6ec1ec, so this is that commit's review (no new review was run; line numbers are as of de6ec1ec)

@ryanking13
ryanking13 enabled auto-merge November 17, 2026 04:28
@ryanking13
ryanking13 merged commit 6270be0 into main Nov 17, 2026
36 of 37 checks passed
@ryanking13
ryanking13 deleted the gyeongjae/finalize-bootstrap-skip-run-python branch November 17, 2026 04:29
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