|
| 1 | +# Pipenv Package Manager Benchmark |
| 2 | + |
| 3 | +This directory contains benchmarking tests for pipenv based on the [python-package-manager-shootout](https://github.com/lincolnloop/python-package-manager-shootout) project. |
| 4 | + |
| 5 | +## Purpose |
| 6 | + |
| 7 | +These benchmarks help validate that pipenv performance doesn't regress over time by testing common package management operations against a real-world dependency set from [Sentry's requirements](https://github.com/getsentry/sentry/blob/main/requirements-base.txt). |
| 8 | + |
| 9 | +## Operations Benchmarked |
| 10 | + |
| 11 | +- **tooling** - Installing pipenv using the current development version |
| 12 | +- **import** - Converting requirements.txt to Pipfile format |
| 13 | +- **lock** - Generating Pipfile.lock from dependencies |
| 14 | +- **install-cold** - Installing packages with empty cache |
| 15 | +- **install-warm** - Installing packages with populated cache |
| 16 | +- **update** - Updating all packages to latest versions |
| 17 | +- **add-package** - Adding a new package and updating lock file |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### Local Testing |
| 22 | + |
| 23 | +```bash |
| 24 | +# Run all benchmark operations |
| 25 | +make benchmark |
| 26 | + |
| 27 | +# Clean benchmark artifacts |
| 28 | +make benchmark-clean |
| 29 | + |
| 30 | +# Run individual operations |
| 31 | +cd benchmarks |
| 32 | +python benchmark.py # Run full benchmark suite |
| 33 | +python benchmark.py setup # Download requirements.txt |
| 34 | +python benchmark.py tooling # Benchmark pipenv installation |
| 35 | +python benchmark.py import # Benchmark requirements import |
| 36 | +python benchmark.py lock-cold # Benchmark lock with cold cache |
| 37 | +python benchmark.py lock-warm # Benchmark lock with warm cache |
| 38 | +python benchmark.py install-cold # Benchmark install with cold cache |
| 39 | +python benchmark.py install-warm # Benchmark install with warm cache |
| 40 | +python benchmark.py update-cold # Benchmark update with cold cache |
| 41 | +python benchmark.py update-warm # Benchmark update with warm cache |
| 42 | +python benchmark.py add-package # Benchmark adding a package |
| 43 | +python benchmark.py stats # Generate stats.csv |
| 44 | +``` |
| 45 | + |
| 46 | +### CI Integration |
| 47 | + |
| 48 | +The benchmarks run automatically in GitHub Actions on the `ubuntu-latest` runner as part of the CI pipeline. Results are: |
| 49 | + |
| 50 | +- Displayed in the job summary with timing statistics |
| 51 | +- Uploaded as artifacts for historical analysis |
| 52 | +- Used to detect performance regressions |
| 53 | + |
| 54 | +## Files |
| 55 | + |
| 56 | +- `benchmark.py` - Main benchmark runner script |
| 57 | +- `Pipfile` - Base Pipfile template (dependencies added during import) |
| 58 | +- `requirements.txt` - Downloaded from Sentry's requirements-base.txt during setup |
| 59 | +- `timings/` - Directory created during benchmarks to store timing data |
| 60 | +- `stats.csv` - Generated CSV with benchmark results |
| 61 | + |
| 62 | +## Dependencies |
| 63 | + |
| 64 | +The benchmark uses Sentry's `requirements-base.txt` as a representative real-world dependency set. This includes packages like: |
| 65 | + |
| 66 | +- Django and related packages |
| 67 | +- Database connectors |
| 68 | +- Serialization libraries |
| 69 | +- HTTP clients |
| 70 | +- Development tools |
| 71 | + |
| 72 | +## Notes |
| 73 | + |
| 74 | +- Benchmarks only run on Linux in CI to ensure consistent timing measurements |
| 75 | +- System dependencies (libxmlsec1-dev, librdkafka-dev) are installed for Sentry requirements |
| 76 | +- Cache clearing ensures cold/warm scenarios are properly tested |
| 77 | +- Results include CPU time, memory usage, and I/O statistics |
0 commit comments