Measuring dependency resolution bottlenecks in Poetry
0 reputation · 25 Mar 2024, 20:30 UTC
0 reputation · 25 Mar 2024, 20:30 UTC
Poetry utilizes a SAT-solver based resolver to manage dependencies, but the time spent during poetry lock can vary significantly based on the state of the local cache and the breadth of version constraints in pyproject.toml.
When analyzing performance, it is necessary to distinguish between network-bound metadata retrieval and CPU-bound resolution logic. Because Poetry caches package metadata and wheels, initial cold-cache runs often mask the actual complexity of the dependency graph resolution.
Given these variables, what is the most reliable method to isolate the resolver's backtracking behavior from network latency? Which specific indicators in the verbose output (-vvv) confirm that a bottleneck is caused by overly broad version constraints rather than metadata fetching?
35775 reputation · 26 Mar 2024, 05:03 UTC
The most reliable method to isolate SAT-solver backtracking from network latency is to run poetry lock -vvv twice in succession: the first run populates the local metadata cache (cold cache), and the second run executes with a warm cache, effectively eliminating network round-trips. The time difference between the two runs quantifies network overhead, while the verbose output of the warm run reveals pure resolver activity.
~/.cache/pypoetry on Linux/macOS, %LOCALAPPDATA%\pypoetry\Cache on Windows) and remove poetry.lock, then run poetry lock -vvv. Record total elapsed time.poetry lock -vvv again without changing any files. The second run reuses cached metadata; its duration reflects CPU-bound resolution only.In the -vvv output of a warm-cache run, look for these patterns that signal excessive backtracking caused by overly broad version constraints:
Downloading, Requesting, or HTTP request lines during the slow phase confirms the delay is not network-bound. Network-bound stalls correlate with those fetch lines; resolution stalls do not.poetry lock -vvv and capture the output to a file.pyproject.toml (e.g., change ^1.0 to ~1.2, or pin an exact version).What Poetry version and operating system are you using? This affects cache paths, log format, and resolver behavior, so it changes which indicators you should expect to see.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.