Skip to content

Pack HTTP cache policy flags and optional integers - #22078

Merged
charliermarsh merged 2 commits into
charlie/windows-wheel-cache-lock-keyfrom
charlie/compact-http-cache-policy
Sep 30, 2026
Merged

charliermarsh merged 2 commits into
charlie/windows-wheel-cache-lock-keyfrom
charlie/compact-http-cache-policy

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

We store the same HTTP cache information in fewer bytes, without changing cache freshness or revalidation behavior.

  • Booleans become bits. Ten fields like no_cache, no_store, and immutable each occupied a byte. We pack them into bits of one integer.
  • Optional numbers share their presence flags. Each archived Option<u64> occupies 16 bytes: the number, an indicator of whether it exists, and alignment padding. We store the numbers together and use one bit per number to indicate whether it exists.

For example, max_age = None and max_age = Some(0) both store the number 0, but their presence bits differ. Getters reconstruct the normal Option<u64>.

We apply this to cache-control directives and response timestamps. The fixed archived policy shrinks from 320 to 200 bytes. We use bitflags for typed flag operations and retain endian-aware integers in the archived representation.

The cache bucket bumps cover the new representation.

@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Sep 29, 2026
@charliermarsh
charliermarsh force-pushed the charlie/compact-http-cache-policy branch from b301269 to 115b8f0 Compare September 29, 2026 17:50
@charliermarsh
charliermarsh marked this pull request as ready for review September 29, 2026 17:50

@ww-oai ww-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me! One small question: can we use bitflags here or does it not compose well with rkyv?

(Just noticed we're doing some of the same things that I think bitflags handles for us with e.g. previews.)

@charliermarsh
charliermarsh force-pushed the charlie/compact-http-cache-policy branch from 115b8f0 to a2e0171 Compare September 30, 2026 01:43
@charliermarsh charliermarsh added performance and removed internal A refactor or improvement that is not user-facing labels Sep 30, 2026
@charliermarsh
charliermarsh merged commit f4f42c3 into main Sep 30, 2026
113 of 174 checks passed
@charliermarsh
charliermarsh deleted the charlie/compact-http-cache-policy branch September 30, 2026 02:07
@codspeed

codspeed Bot commented Sep 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.9%

❌ 1 regressed benchmark
✅ 71 untouched benchmarks
⏩ 28 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ WallTime revalidate_shared 80.9 ms 86 ms -5.9%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing charlie/compact-http-cache-policy (a2e0171) with charlie/windows-wheel-cache-lock-key (0872944)2

Open in CodSpeed

Footnotes

  1. 28 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on charlie/windows-wheel-cache-lock-key (4d4ac81) during the generation of this report, so 1587889 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

charliermarsh added a commit that referenced this pull request Oct 1, 2026
We revert the cache-format stack so `main` retains the 0.12 cache
formats and bucket versions. These changes are deferred to 0.13.

This reverts the following PRs together, including the six cache bucket
bumps and the serialization and Windows lock-name changes that depend on
them:

- #22052: Refresh HTTP cache policies in place
- #22059: Store source distribution revision IDs inline
- #22060: Remove the legacy hash digest cache representation
- #22061: Derive serialization for cached artifact records
- #22062: Use bounded wheel cache lock names on Windows
- #22078: Pack HTTP cache policy flags and optional integers
- #22079: Align cached HTTP policies within the payload buffer
charliermarsh added a commit that referenced this pull request Oct 1, 2026
Reapplies #22078 for 0.13.

We store the same HTTP cache information in fewer bytes, without
changing cache freshness or revalidation behavior.

- **Booleans become bits.** Ten fields like `no_cache`, `no_store`, and
`immutable` each occupied a byte. We pack them into bits of one integer.
- **Optional numbers share their presence flags.** Each archived
`Option<u64>` occupies 16 bytes: the number, an indicator of whether it
exists, and alignment padding. We store the numbers together and use one
bit per number to indicate whether it exists.

For example, `max_age = None` and `max_age = Some(0)` both store the
number `0`, but their presence bits differ. Getters reconstruct the
normal `Option<u64>`.

We apply this to cache-control directives and response timestamps. The
fixed archived policy shrinks from **320 to 200 bytes**. We use
`bitflags` for typed flag operations and retain endian-aware integers in
the archived representation.

The cache bucket bumps cover the new representation.
zanieb pushed a commit that referenced this pull request Oct 7, 2026
Reapplies #22078 for 0.13.

We store the same HTTP cache information in fewer bytes, without
changing cache freshness or revalidation behavior.

- **Booleans become bits.** Ten fields like `no_cache`, `no_store`, and
`immutable` each occupied a byte. We pack them into bits of one integer.
- **Optional numbers share their presence flags.** Each archived
`Option<u64>` occupies 16 bytes: the number, an indicator of whether it
exists, and alignment padding. We store the numbers together and use one
bit per number to indicate whether it exists.

For example, `max_age = None` and `max_age = Some(0)` both store the
number `0`, but their presence bits differ. Getters reconstruct the
normal `Option<u64>`.

We apply this to cache-control directives and response timestamps. The
fixed archived policy shrinks from **320 to 200 bytes**. We use
`bitflags` for typed flag operations and retain endian-aware integers in
the archived representation.

The cache bucket bumps cover the new representation.
zanieb pushed a commit that referenced this pull request Oct 9, 2026
Reapplies #22078 for 0.13.

We store the same HTTP cache information in fewer bytes, without
changing cache freshness or revalidation behavior.

- **Booleans become bits.** Ten fields like `no_cache`, `no_store`, and
`immutable` each occupied a byte. We pack them into bits of one integer.
- **Optional numbers share their presence flags.** Each archived
`Option<u64>` occupies 16 bytes: the number, an indicator of whether it
exists, and alignment padding. We store the numbers together and use one
bit per number to indicate whether it exists.

For example, `max_age = None` and `max_age = Some(0)` both store the
number `0`, but their presence bits differ. Getters reconstruct the
normal `Option<u64>`.

We apply this to cache-control directives and response timestamps. The
fixed archived policy shrinks from **320 to 200 bytes**. We use
`bitflags` for typed flag operations and retain endian-aware integers in
the archived representation.

The cache bucket bumps cover the new representation.
astral-automations-bot Bot pushed a commit to astral-sh/uv-dev that referenced this pull request Oct 10, 2026
Reapplies astral-sh#22078 for 0.13.

We store the same HTTP cache information in fewer bytes, without
changing cache freshness or revalidation behavior.

- **Booleans become bits.** Ten fields like `no_cache`, `no_store`, and
`immutable` each occupied a byte. We pack them into bits of one integer.
- **Optional numbers share their presence flags.** Each archived
`Option<u64>` occupies 16 bytes: the number, an indicator of whether it
exists, and alignment padding. We store the numbers together and use one
bit per number to indicate whether it exists.

For example, `max_age = None` and `max_age = Some(0)` both store the
number `0`, but their presence bits differ. Getters reconstruct the
normal `Option<u64>`.

We apply this to cache-control directives and response timestamps. The
fixed archived policy shrinks from **320 to 200 bytes**. We use
`bitflags` for typed flag operations and retain endian-aware integers in
the archived representation.

The cache bucket bumps cover the new representation.

This branch was previously deployed

1 inactive deployment
automations — a2e0171a Deployed Sep 30, 2026 by charliermarsh via review / security review #48414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants