Skip to content

fix: make benchmark page-cache clearing opt-in, never prompt for sudo - #252

Closed
d-v-b wants to merge 7 commits into
mainfrom
claude/zarr-4199-audit-b52b46
Closed

fix: make benchmark page-cache clearing opt-in, never prompt for sudo#252
d-v-b wants to merge 7 commits into
mainfrom
claude/zarr-4199-audit-b52b46

Conversation

@d-v-b

@d-v-b d-v-b commented Jul 29, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

Fixes zarr-developers#4199.

clear_cache() in tests/benchmarks/test_e2e.py ran sudo unconditionally in every benchmark's setup, so a plain pytest run blocked on a password prompt (and pytest-benchmark executes each benchmark once even under --benchmark-disable, so this hit ordinary test runs, not just benchmark runs). CI never noticed because GitHub runners have passwordless sudo.

Changes:

  • clear_cache() is a no-op unless ZARR_BENCHMARK_CLEAR_CACHE=1 is set; the codspeed and benchmark-smoke CI jobs now set it, preserving current CI behavior.
  • Uses sudo -n so it can never block on an interactive password prompt even when opted in.
  • Fixes the broken Darwin invocation: subprocess.call(["sync", "&&", "sudo", "purge"]) passed && and sudo as arguments to sync, so the purge never ran.
  • Unsupported platforms now warn-and-skip instead of raising (env input is handled tolerantly).

Verified: all 181 benchmark tests collect and a write+read benchmark pair passes with no sudo interaction.

🤖 Generated with Claude Code

d-v-b added 6 commits July 14, 2026 13:25
* fix: byte-order handling for structured dtypes in the bytes codec

The bytes codec neither byte-swapped structured-dtype fields to its
configured endian on encode (numpy reports byteorder '|' for void
dtypes, so the top-level byteorder comparison never detected a
mismatch) nor honored its endian when decoding, silently corrupting
any structured data whose field byte order differed from the stored
one (e.g. virtual references to external big-endian data).

Encode now detects byte-order mismatches by comparing full dtypes via
newbyteorder, and decode reinterprets raw bytes in the stored byte
order before converting to the data type's declared byte order, so the
stored layout (codec state) and the in-memory layout (array data type)
are independent.

Closes zarr-developers#4141

Assisted-by: ClaudeCode:claude-fable-5

* test: fold structured byte-order cases into existing bytes codec tests

Extend test_endian's parametrization with structured dtypes and
test_bytes_codec_sync_roundtrip with endian/dtype parametrization plus
stored-layout and decoded-dtype assertions, instead of adding parallel
test functions for the same properties.

Assisted-by: ClaudeCode:claude-fable-5

* refactor: rename stored_dtype to view_dtype in BytesCodec decode

The variable is the dtype used to view the raw chunk bytes (byte order
from the codec's endian configuration), not a property of the stored
data or of the returned buffer, which always carries the array's
declared dtype.

Assisted-by: ClaudeCode:claude-fable-5

* docs: note that the decode-side byte-order conversion copies the chunk

Assisted-by: ClaudeCode:claude-fable-5
clear_cache() in tests/benchmarks/test_e2e.py ran sudo unconditionally in
every benchmark's setup, so a plain `pytest` run blocked on a password
prompt (zarr-developers#4199). It is now a no-op unless ZARR_BENCHMARK_CLEAR_CACHE is
set, uses `sudo -n` so it can never block interactively, and the broken
Darwin invocation ("&&" passed as an argument to sync) is fixed. The
benchmark CI jobs set the variable to keep clearing caches.

Closes zarr-developers#4199

Assisted-by: ClaudeCode:claude-fable-5
@d-v-b
d-v-b force-pushed the claude/zarr-4199-audit-b52b46 branch from c3bd2e4 to 6fc35d1 Compare July 29, 2026 11:25
@d-v-b

d-v-b commented Jul 29, 2026

Copy link
Copy Markdown
Owner Author

🤖 AI text below 🤖

Superseded: this landed upstream as zarr-developers#4200 (commit b213b54), which is now on this fork's main.

@d-v-b d-v-b closed this Jul 29, 2026
@d-v-b
d-v-b deleted the claude/zarr-4199-audit-b52b46 branch July 29, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests/benchmarks/test_e2e.py requires sudo

1 participant