Skip to content

perf: reduce use of to_list in py_image_layer - #1442

Merged
jbedard merged 1 commit into
mainfrom
image-less-to_list
Aug 17, 2026
Merged

perf: reduce use of to_list in py_image_layer#1442
jbedard merged 1 commit into
mainfrom
image-less-to_list

Conversation

@jbedard

@jbedard jbedard commented Aug 15, 2026

Copy link
Copy Markdown
Member

This removes a single .to_list() call, which will actually have minimal impact since the same depset is already flattened elsewhere.

However this also removes the use of some large temp dicts (interpreter_reference_paths) and makes it a bit clearer how the reference_mappings creates the last-write-wins list passed to awk.

Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

@jbedard
jbedard requested review from thesayyn and xangcastle August 15, 2026 19:43
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d8b49bc-5c9b-48c1-9f98-c6b5c90843c3

📥 Commits

Reviewing files that changed from the base of the PR and between dec1bc1 and 0548a51.

📒 Files selected for processing (1)
  • py/private/py_image_layer.bzl

Included review availability: Your plan includes up to 3 reviews per rolling hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The image layer implementation now preserves separate symlink mapping functions for source, interpreter, and rule-group files. The tar action applies each mapper to its corresponding files while retaining ordered precedence and directory tree inputs.

Changes

Symlink mapping

Layer / File(s) Summary
Ordered per-layer mapping and tar integration
py/private/py_image_layer.bzl
_py_image_layer_impl creates ordered mappings for source/first-party, interpreter, and rule-group files. _run_tar_action applies each mapping’s files with its corresponding mapper.

Estimated code review effort: 3 (Moderate) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 0548a

This localized refactor removes temporary data structures without changing end-user behavior, and no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: xangcastle, thesayyn

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the performance cleanup in py_image_layer and matches the main changes.
Description check ✅ Passed The description accurately covers the removed to_list call, temporary dictionary cleanup, and test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch image-less-to_list

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

@aspect-workflows

aspect-workflows Bot commented Aug 15, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Sat Aug 15 19:44:30 UTC 2026

✅ 44 successful tasks

  • ✅ buildifier · ⏱ 17.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Format complete (clean)
  • ✅ gazelle · ⏱ 15s · 🐙 GitHub Actions · ☑️ Check
    💬 Gazelle complete (clean)
  • ✅ test-e2e-bazel-8 [test] · ⏱ 4m 7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (271/271 passed)
  • ✅ test-e2e-bazel-9 [test] · ⏱ 4m 10s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (265/265 passed)
  • ✅ test-e2e-crossbuild-bazel-8 [test] · ⏱ 1m 4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (10/10 passed)
  • ✅ test-e2e-crossbuild-bazel-9 [test] · ⏱ 1m 17s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (10/10 passed)
  • ✅ test-e2e-interpreter-build-config-bazel-8 [test] · ⏱ 21.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-build-config-bazel-9 [test] · ⏱ 59.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-8 [test] · ⏱ 15.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-9 [test] · ⏱ 38s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-8 [test] · ⏱ 28.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-9 [test] · ⏱ 51.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-8 [test] · ⏱ 20.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-9 [test] · ⏱ 31.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-8 [test] · ⏱ 1m 50s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-9 [test] · ⏱ 1m 17s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-python-interop-bazel-8 [test] · ⏱ 52.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (15/15 passed)
  • ✅ test-e2e-rules-python-interop-bazel-9 [test] · ⏱ 1m 19s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (15/15 passed)
  • ✅ test-e2e-rules-python-provider-compat-bazel-8 [test] · ⏱ 24s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (4/4 passed)
  • ✅ test-e2e-rules-python-provider-compat-bazel-9 [test] · ⏱ 1m 5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (4/4 passed)
  • ✅ test-examples-debugger-bazel-8 [test] · ⏱ 24s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-debugger-bazel-9 [test] · ⏱ 55.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-8 [test] · ⏱ 29s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-9 [test] · ⏱ 44.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-django-bazel-8 [test] · ⏱ 27.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-django-bazel-9 [test] · ⏱ 45.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-multi_version-bazel-8 [test] · ⏱ 31.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-multi_version-bazel-9 [test] · ⏱ 55.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-protobuf-bazel-8 [test] · ⏱ 1m 28s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-protobuf-bazel-9 [test] · ⏱ 1m 56s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_binary-bazel-8 [test] · ⏱ 25.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_binary-bazel-9 [test] · ⏱ 36s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_pex_binary-bazel-8 [test] · ⏱ 22.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_pex_binary-bazel-9 [test] · ⏱ 51s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_venv-bazel-8 [test] · ⏱ 21.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed · 3 cached)
  • ✅ test-examples-py_venv-bazel-9 [test] · ⏱ 1m 5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed)
  • ✅ test-examples-pytest-bazel-8 [test] · ⏱ 39.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (11/11 passed)
  • ✅ test-examples-pytest-bazel-9 [test] · ⏱ 1m 29s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (11/11 passed)
  • ✅ test-examples-uv_pip_compile-bazel-8 [test] · ⏱ 25.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-uv_pip_compile-bazel-9 [test] · ⏱ 52.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-8 [test] · ⏱ 26.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-9 [test] · ⏱ 57.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-root-bazel-8 [test] · ⏱ 2m 59s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (298/298 passed)
  • ✅ test-root-bazel-9 [test] · ⏱ 3m 18s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (297/297 passed)

⏱ Last updated Sat Aug 15 19:50:48 UTC 2026 · 📊 GitHub API quota 2,172/15,000 (14% used, resets in 13s)
🚀 Powered by Aspect CLI (v2026.28.2)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions

Copy link
Copy Markdown

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.7 (baseline) 166.514 158.477 ±21.528 43.62
HEAD main 54.113 54.155 ±0.570 -67.5% 9.20
This PR 55.222 54.212 ±4.528 -66.8% +2.0% 6.78

Measured with hyperfine --warmup 5 --runs 50 on Linux
Gate: PR vs HEAD main (threshold: 10%). BCR is shown only as a historical baseline.
Build time: cold bazel build //:bench with isolated output base, no disk cache.

sys.path quality

Version sys.path entries distinct site-packages roots duplicate realpaths
BCR 1.11.7 (baseline) 6 1 0
HEAD main 7 2 0
This PR 7 2 0

sys.path quality measured by bench_syspath inside the assembled venv. Duplicate realpaths indicate symlink redundancy; many distinct site-packages roots suggest an inefficient venv layout.

Bazel analysis benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Targets Actions
BCR 2.0.0-alpha.5 (baseline) 10248.265 10276.876 ±165.544 301 13672
HEAD main 8959.331 8939.199 ±89.068 -12.6% 301 13540
This PR 8899.107 8909.285 ±114.342 -13.2% -0.7% 301 13540

Measured with hyperfine --warmup 1 --runs 10 on Linux
Gate: PR vs HEAD main (threshold: 10%). BCR is shown only as a historical baseline.
Command: cold bazel build --nobuild //workspace/... with isolated output base, no disk cache.

@jbedard
jbedard enabled auto-merge (squash) August 15, 2026 20:02
@jbedard
jbedard disabled auto-merge August 17, 2026 02:56
@jbedard
jbedard merged commit 9fba827 into main Aug 17, 2026
96 checks passed
@jbedard
jbedard deleted the image-less-to_list branch August 17, 2026 02:56
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