pants: Pants export runs slower going from 2.9.0 to 2.11.0
Describe the bug
After upgrading pants from 2.9.0 to 2.11.0, I noticed a significant slowdown when running pants export ::. Went from 19 seconds to 153 seconds. Also tested with version 2.13.0dev2 and that ran in 330 seconds.
Pants version 2.9.0 and 2.11.0
OS ubuntu:20.04 vscode devcontainer (host is OSX)
Additional info
When running without -ldebug, the console output stops after Completed: Scheduling: Get interpreter version for a long time and looks like it has hung. It will eventually finish if I wait long enough.
I ran pants export :: -ldebug twice for each version and clipped the last few lines for each run to indicate execution time. You can see how long the output stalls by looking at the timestamps.
## v2.9.0
19:34:49.45 [DEBUG] Completed: Scheduling: Create virtualenv
Wrote virtualenv for CPython==3.8.* to dist/export/python/virtualenv
19:34:59.55 [DEBUG] Completed: `export` goal
19:34:59.55 [DEBUG] computed 1 nodes in 18.479455 seconds. there are 2158 total nodes.
19:35:20.09 [DEBUG] Dependency SessionValues of Some("@rule(pants.engine.environment.environment_subset())") changed.
Wrote virtualenv for CPython==3.8.* to dist/export/python/virtualenv
19:35:20.17 [DEBUG] Completed: `export` goal
19:35:20.17 [DEBUG] computed 1 nodes in 0.093260 seconds. there are 2160 total nodes.
## V2.11.0
19:36:10.91 [DEBUG] Completed: Scheduling: Get interpreter version
Wrote virtualenv for the resolve 'None' (using CPython==3.8.*) to dist/export/python/virtualenv
19:38:37.53 [DEBUG] Completed: `export` goal
19:38:37.53 [DEBUG] computed 1 nodes in 153.387390 seconds. there are 1911 total nodes.
19:39:26.87 [DEBUG] Dependency SessionValues of Some("@rule(pants.engine.environment.environment_subset())") changed.
Wrote virtualenv for the resolve 'None' (using CPython==3.8.*) to dist/export/python/virtualenv
19:42:26.90 [DEBUG] Completed: `export` goal
19:42:26.90 [DEBUG] computed 1 nodes in 195.992491 seconds. there are 1913 total nodes.
## 2.13.0.dev2
19:47:12.79 [DEBUG] Completed: pants.backend.python.util_rules.pex.build_pex
Wrote virtualenv (using Python 3.8.10) to dist/export/python/virtualenv
Wrote virtualenv for the tool 'pytest' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'black' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'bandit' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'docformatter' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'flake8' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'isort' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'pylint' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'mypy' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'pyupgrade' to dist/export/python/virtualenvs/tools
19:52:36.23 [DEBUG] Completed: `export` goal
19:52:36.23 [DEBUG] computed 1 nodes in 330.323559 seconds. there are 2078 total nodes.
19:53:38.46 [DEBUG] Dependency SessionValues of Some("@rule(pants.engine.environment.environment_subset())") changed.
Wrote virtualenv (using Python 3.8.10) to dist/export/python/virtualenv
Wrote virtualenv for the tool 'pytest' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'black' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'bandit' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'docformatter' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'flake8' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'isort' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'pylint' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'mypy' to dist/export/python/virtualenvs/tools
Wrote virtualenv for the tool 'pyupgrade' to dist/export/python/virtualenvs/tools
19:58:46.87 [DEBUG] Completed: `export` goal
19:58:46.87 [DEBUG] computed 1 nodes in 335.367800 seconds. there are 2080 total nodes.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 22 (21 by maintainers)
And could you attach (or DM me) your requirements.txt (with any internal/secret stuff redacted), so I can get a real-world case to benchmark on?
Yes, I don’t think this has anything to do with tool venvs. I think this is because we don’t do the slightly sketchy symlink thing any more. @KevinMarquette how disruptive a problem is this?
Ah, but the exported venv in 2.9.0 symlinks into the pex cache I think, while the 2.11.0 it may be created without such taint. @benjyw can confirm.
That extra time is likely due to the fact that all the tools also get their individual venvs exported. (#15098) However, if those tool venvs are unused, exporting them is time wasted. There’s now a per tool option to not export that particular venv (#15509)