bazel-contrib / bazel-contrib/rules_python

Hermetic toolchains incur a significant overhead to running py_binary and py_test

未关闭
#1,653 13 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

# 🐞 bug report

### Affected Rule

`py_binary` and `py_test`

### Is this a regression?

No

### Description

Hermetic toolchains incur a significant overhead to executing Python targets due to the large amount of files which are added to the runfiles tree.
You find an analysis of the issue here: https://github.com/martis42/show_hermetic_python_overhead

Bazel caching of course negates much of this issue in daily working.
Still, whenever a test has to rerun we pay this additional overhead.

I don't know if there is a "perfect" solution possible given how Bazel sandboxing works.
However, it would be great if rues_python would add a note in its documentation for hermetic toolchains that adding `--nolegacy_external_runfiles` to the `.bazelrc` file is recommended.

Maybe the `rules_python` maintainer can even convince the Bazel maintainer to prioritize working on flipping `--legacy_external_runfiles` in Bazel 8 ?

## 🔬 Minimal Reproduction

You see reproduce this with this small example workspace https://github.com/martis42/show_hermetic_python_overhead

## 🔥 Exception or Error

NA

## 🌍 Your Environment

**Operating System:**

  

Linux Mint 21.1

**Output of `bazel version`:**

  

Bazelisk version: v1.16.0
Build label: 7.0.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Dec 11 16:51:49 2023 (1702313509)
Build timestamp: 1702313509
Build timestamp as int: 1702313509

**Rules_python version:**

  

0.27.0

**Anything else relevant?**

https://github.com/bazelbuild/rules_python/issues/1624 might be related.
It is however maybe Windows specific.

贡献指南

打开贡献指南

调研方向

从链接的 show_hermetic_python_overhead workspace 开始,比较使用 hermetic toolchain 时 py_binary 和 py_test 的执行情况。阅读 hermetic-toolchain 文档以及 .bazelrc 设置 --nolegacy_external_runfiles;当 overhead 和建议得到清晰记录,或限制得到解释时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system, performance
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。