Skip to content

rules_python is very very slow #1624

@peakschris

Description

@peakschris

🐞 bug report

Affected Rule

py_binary

Is this a regression?

No

Description

There are significant performance issues with the python tools in pkg_zip in a bazel environment (on Windows). We were finding when bazel was simultaneously packaging many zips, each one could take 45s instead of 2s expected. A single zip would take 20s, but multiple simultaneous ones slow down to 45s. We discovered that this is because Bazel's hermetic python toolchain (rules_python) uncompresses many files to prepare for every single python invocation. More discussion here: https://bazelbuild.slack.com/archives/CA306CEV6/p1701253691249489

See corresponding issue in rules_pkg: bazelbuild/rules_pkg#795. The workaround there is to rewrite their tooling in a different language.

But the correct fix would be to resolve the problem in rules_python. I wonder why the large set of files cannot be prepared one single time per workspace?

🔬 Minimal Reproduction

Compare build_zip.py performance with go version here: https://github.com/peakschris/build_zip_go. Python version takes 45s when running in parallel. Go version is 2s.

🔥 Exception or Error





🌍 Your Environment

Operating System:

  
Windows 10
  

Output of bazel version:

  
7.0.0
  

Rules_python version:

  
0.27.1
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions