uv/crates
Andrew Gallant f9528b4ecd
pep440-rs: switch Version::release to smallvec
This commit attempts an optimization that switches a version's `release`
field over to a `smallvec` optimization. The idea is that most versions
are very small and can be stored inline.

Interestingly, I was unable to observe any obvious benefit:

    $ hyperfine \
        "./target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null" \
        "./target/profiling/puffin-dev-smallvec-release resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null"
    Benchmark 1: ./target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null
      Time (mean ± σ):     872.2 ms ±  26.5 ms    [User: 14646.0 ms, System: 2516.0 ms]
      Range (min … max):   833.0 ms … 912.0 ms    10 runs

    Benchmark 2: ./target/profiling/puffin-dev-smallvec-release resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null
      Time (mean ± σ):     882.3 ms ±  17.4 ms    [User: 14764.4 ms, System: 2520.9 ms]
      Range (min … max):   859.7 ms … 912.7 ms    10 runs

    Summary
      './target/profiling/puffin-dev-u32 resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null' ran
        1.01 ± 0.04 times faster than './target/profiling/puffin-dev-smallvec-release resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null'

My hypothesis is that because of an earlier commit that switched the
global allocator to jemalloc, the cost of allocation had precipitously
decreased. To the point that the reduction in allocs from the smallvec
becomes a wash. To test my hypothesis, I dropped the jemalloc commit and
measured the perf of the smallvec optimization against main:

    $ hyperfine \
        "./target/profiling/puffin-dev-main resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null" \
        "./target/profiling/puffin-dev-smallvec-release-no-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null"
    Benchmark 1: ./target/profiling/puffin-dev-main resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null
      Time (mean ± σ):     968.0 ms ±  20.0 ms    [User: 17637.4 ms, System: 2151.9 ms]
      Range (min … max):   940.2 ms … 1005.3 ms    10 runs

    Benchmark 2: ./target/profiling/puffin-dev-smallvec-release-no-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null
      Time (mean ± σ):     958.4 ms ±  15.7 ms    [User: 17119.7 ms, System: 2246.1 ms]
      Range (min … max):   944.7 ms … 993.3 ms    10 runs

    Summary
      './target/profiling/puffin-dev-smallvec-release-no-jemalloc resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null' ran
        1.01 ± 0.03 times faster than './target/profiling/puffin-dev-main resolve-many --cache-dir cache-docker-no-build --no-build pypi_top_8k_flat.txt --limit 1000 2> /dev/null'

Fiddlesticks. Even when allocation is (presumably) more expensive, the
smallvec optimization didn't help. This suggests something is off about
my mental model of the code. So there are more avenues to explore here!
2023-11-10 14:30:26 -05:00
..
bench distribution-filename: speed up is_compatible (#367) 2023-11-09 09:01:03 -05:00
distribution-filename Rename Distribution to Dist in all structs and traits (#384) 2023-11-10 14:55:11 +00:00
gourgeist Remove virtualenv setup from gourgeist (#339) 2023-11-06 18:32:45 +00:00
install-wheel-rs Delete any directories listed in the RECORD file (#394) 2023-11-10 18:17:52 +00:00
pep440-rs pep440-rs: switch Version::release to smallvec 2023-11-10 14:30:26 -05:00
pep508-rs pep440-rs: switch Version::release to smallvec 2023-11-10 14:30:26 -05:00
platform-host fix platform detection on Linux (#359) 2023-11-07 11:39:35 -05:00
platform-tags distribution-filename: speed up is_compatible (#367) 2023-11-09 09:01:03 -05:00
puffin-build Rename Distribution to Dist in all structs and traits (#384) 2023-11-10 14:55:11 +00:00
puffin-cache Add proper caching for pypi metadata fetching kinds (#368) 2023-11-10 11:03:40 +00:00
puffin-cli puffin-{cli,dev}: switch to mimalloc and jemalloc 2023-11-10 14:30:09 -05:00
puffin-client Add proper caching for pypi metadata fetching kinds (#368) 2023-11-10 11:03:40 +00:00
puffin-dev puffin-{cli,dev}: switch to mimalloc and jemalloc 2023-11-10 14:30:09 -05:00
puffin-dispatch Rename Distribution to Dist in all structs and traits (#384) 2023-11-10 14:55:11 +00:00
puffin-distribution Rename Distribution to Dist in all structs and traits (#384) 2023-11-10 14:55:11 +00:00
puffin-git Refactor distribution types to adhere to a clear hierarchy (#369) 2023-11-10 02:45:41 +00:00
puffin-installer Rename Distribution to Dist in all structs and traits (#384) 2023-11-10 14:55:11 +00:00
puffin-interpreter Make cache non-optional in most crates (#293) 2023-11-02 13:40:20 -04:00
puffin-normalize Split puffin-package into requirements.txt parser and pypi-types (#341) 2023-11-06 18:19:49 +00:00
puffin-resolver pep440-rs: use u32 instead of usize in Version representation 2023-11-10 14:30:10 -05:00
puffin-traits Special case missing header build errors (on linux) (#354) 2023-11-08 15:26:39 +00:00
puffin-workspace Update pyproject-toml to 0.8.0 (#329) 2023-11-06 13:16:36 +00:00
pypi-types Respect direct URLs in puffin installer (#345) 2023-11-07 09:11:27 -05:00
requirements-txt Split puffin-package into requirements.txt parser and pypi-types (#341) 2023-11-06 18:19:49 +00:00
README.md Add source distribution filename abstraction (#154) 2023-10-20 17:45:57 +02:00

Crates

pep440-rs

Utilities for interacting with Python version numbers and specifiers.

pep508-rs

Utilities for interacting with PEP 508 dependency specifiers.

platform-host

Functionality for detecting the current platform (operating system, architecture, etc.).

platform-tags

Functionality for parsing and inferring Python platform tags as per PEP 425.

puffin-cli

Command-line interface for the Puffin package manager.

puffin-client

Client for interacting with PyPI-compatible HTTP APIs.

puffin-installer

Functionality for installing Python packages into a virtual environment.

puffin-interpreter

Functionality for detecting and leveraging the current Python interpreter.

puffin-package

Types and functionality for working with Python packages, e.g., parsing wheel files.

puffin-resolver

Functionality for resolving Python packages and their dependencies.

distribution-filename

Functionality for parsing wheel filenames as per PEP 427.