Skip to content

feat: optimize py_binary start-up times: build venv with symlink actions instead of during py_binary bootstrap phase#944

Open
gregmagolan wants to merge 7 commits intomainfrom
optimized_py_binary
Open

feat: optimize py_binary start-up times: build venv with symlink actions instead of during py_binary bootstrap phase#944
gregmagolan wants to merge 7 commits intomainfrom
optimized_py_binary

Conversation

@gregmagolan
Copy link
Copy Markdown
Member

@gregmagolan gregmagolan commented Apr 23, 2026

No description provided.

@gregmagolan gregmagolan force-pushed the optimized_py_binary branch from 5de72ac to cc215c4 Compare April 23, 2026 23:31
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Apr 23, 2026

Bazel 8 (Test)

Buildkite build #3274 is running...


Bazel 9 (Test)

Buildkite build #3274 is running...


Bazel 8 (Test)

e2e

⚠️ Buildkite build #3274 is currently failing.

Failing tests (1)
//cases/interpreter-features-836:test [k8-fastbuild]🔗

💡 To reproduce the test failures, run

bazel test //cases/interpreter-features-836:test

Bazel 9 (Test)

e2e

⚠️ Buildkite build #3274 is currently failing.

Failing tests (1)
//cases/interpreter-features-836:test [k8-fastbuild]🔗

💡 To reproduce the test failures, run

bazel test //cases/interpreter-features-836:test

Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 444ms.


Buildifier

Buildifier managed files require formatting

--- ./py/private/py_image_layer.bzl	2026-04-24 06:43:14.753998545 +0000
+++ /tmp/buildifier-tmp-1944581848	2026-04-24 06:45:08.928799435 +0000
@@ -173,6 +173,7 @@
         srcs = [binary],
         **kwargs
     )
+
     # Rewrites `type=file content=` entries whose content path is
     # actually a symlink into proper `type=link` entries — otherwise
     # bsdtar follows the symlinks while building the archive, sees a
--- ./py/private/mtree_preserve_symlinks.bzl	2026-04-24 06:43:14.753998545 +0000
+++ /tmp/buildifier-tmp-3486313903	2026-04-24 06:45:08.952799183 +0000
@@ -32,6 +32,7 @@
         assignments.append(("owner", ctx.attr.owner))
     if ctx.attr.group:
         assignments.append(("group", ctx.attr.group))
+
     # Retained for contract compatibility with the upstream awk — the
     # plain-readlink-first branch in our script rarely consults it, but
     # absolute-symlink cases still use `resolved_path ~ bin_dir` for the

💡 Run the following to apply the suggested formatting fixes

bazel run //:buildifier

@gregmagolan gregmagolan force-pushed the optimized_py_binary branch 4 times, most recently from 51aff4f to 6a61c17 Compare April 24, 2026 01:27
Comment thread uv/private/whl_install/rule.bzl
Comment thread py/private/providers.bzl Outdated
Comment thread py/private/py_library.bzl
Comment thread py/private/py_library.bzl
@gregmagolan gregmagolan force-pushed the optimized_py_binary branch 2 times, most recently from 5cdfc60 to e6249ef Compare April 24, 2026 02:07
@gregmagolan gregmagolan changed the title WIP: optimizing py_binary start times Optimize py_binary start-up times: build venv with symlink actions instead of during py_binary bootstrap phase Apr 24, 2026
@gregmagolan gregmagolan changed the title Optimize py_binary start-up times: build venv with symlink actions instead of during py_binary bootstrap phase feat: optimize py_binary start-up times: build venv with symlink actions instead of during py_binary bootstrap phase Apr 24, 2026
@gregmagolan gregmagolan force-pushed the optimized_py_binary branch from e6249ef to 959ece0 Compare April 24, 2026 02:35
Comment thread py/private/py_binary.bzl
default = "error",
values = ["error", "warning", "ignore"],
),
"interpreter_options": attr.string_list(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This just moved?

Comment thread py/private/py_binary.bzl Outdated
# PyWheelsInfo (hand-written py_unpacked_wheel without `top_levels`, or
# non-wheel py_library deps) falls through to the .pth path below.
wheels_depset = _py_library.make_wheels_depset(ctx)
wheels = wheels_depset.to_list()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you think about avoiding the to_list() calls?

Comment thread py/private/py_binary.bzl
test_attrs = _test_attrs,
toolchains = [
PY_TOOLCHAIN,
VENV_TOOLCHAIN,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean the entire toolchain can be deleted?

@gregmagolan gregmagolan force-pushed the optimized_py_binary branch 3 times, most recently from 729fa53 to dfaff69 Compare April 24, 2026 06:00
@gregmagolan gregmagolan force-pushed the optimized_py_binary branch from dfaff69 to f6f2a7c Compare April 24, 2026 06:02
@gregmagolan gregmagolan force-pushed the optimized_py_binary branch from 95d83d5 to 6ad48de Compare April 24, 2026 06:25
@gawk is failing

(05:40:22) ERROR: /mnt/ephemeral/output/rules_py/__main__/external/gawk+/BUILD.bazel:58:11: Compiling support/regex.c [for tool] failed: (Exit 1): clang failed: error executing CppCompile command (from target @@gawk+//:support) external/llvm++_repo_rules+llvm-toolchain-minimal-22.1.3-linux-amd64/bin/clang -target x86_64-linux-gnu -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__=redacted' ... (remaining 70 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/gawk+/support/regex.c:71:
external/gawk+/support/regexec.c:188:36: error: call to undeclared function '_REGEX_NELTS'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  188 |          size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
      |                                           ^
1 error generated.
@gregmagolan gregmagolan force-pushed the optimized_py_binary branch from 5635c83 to e25d4b0 Compare April 24, 2026 06:44
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