Skip to content

feat: memory-only mode skips the timed rounds (closes #124)#127

Open
FBumann wants to merge 1 commit into
mainfrom
feat/memory-only-mode
Open

feat: memory-only mode skips the timed rounds (closes #124)#127
FBumann wants to merge 1 commit into
mainfrom
feat/memory-only-mode

Conversation

@FBumann

@FBumann FBumann commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closes #124.

Problem

A capacity benchmark marked @pytest.mark.benchmem(isolate=True) only wants rss, but pytest-benchmark still runs its full timed rounds. When the payload rebuilds heavy state every round (the linopy LP-writer sweep in the issue: ~79 s/case, almost all of it discarded timing), that's pure overhead.

Solution

A memory-only mode that runs the memray pass as usual, then a single timed call — the timing column shows that one call's duration — instead of the full rounds:

@pytest.mark.benchmem(isolate=True, time=False)
def test_whole_pipeline(benchmark_memory):
    benchmark_memory(build_and_write, spec, n)   # rss measured; one timed call, not N rounds
  • marker: time=False (per-test)
  • suite-wide: --benchmark-memory-only (a per-test time=True opts back in)

Both entry points honour it — the benchmark_memory fixture and the --benchmark-memory monkeypatch — by routing the timed leg through pedantic(rounds=1, warmup_rounds=0, iterations=1). The memory pass (repeats / isolate / ceilings) is untouched.

Design notes

  • Resolver mirrors the existing marker+global blend used by profile_native (_memory_only_from_node / _global_memory_only).
  • Truly dropping timing () isn't clean — pytest-benchmark needs a stats entry to emit the row and carry the memory blob — so "exactly one round" is the realistic form, as flagged on the issue.
  • Reference marker table gains a time row + an isolate-path tip; the live flags table picks up --benchmark-memory-only automatically.

Tests

time=False collapses to one round while leaving the memory blob and unmarked tests intact; --benchmark-memory-only collapses all; time=True overrides the flag; and the --benchmark-memory patch path honours time=False. Full suite green; ruff + format + mypy clean.

🤖 Generated with Claude Code

A capacity benchmark marked isolate=True only wants rss, but pytest-benchmark
still runs its full timed rounds — and when the payload rebuilds heavy state each
round, that timing dominates wall-clock and is then discarded.

Add a memory-only mode that runs the memray pass as usual, then a *single* timed
call (the timing column shows that one call) instead of the full rounds:

- marker: @pytest.mark.benchmem(time=False)
- suite-wide: --benchmark-memory-only (a per-test time=True opts back in)

Both call paths honour it — the benchmark_memory fixture and the
--benchmark-memory monkeypatch — by routing the timed leg through pedantic(
rounds=1, warmup_rounds=0, iterations=1). The memory pass (repeats, isolate,
ceilings) is untouched.

Resolver mirrors the existing marker+global blend (_memory_only_from_node /
_global_memory_only). Reference marker table + an isolate-path tip added; the
flags table picks up --benchmark-memory-only automatically.

Tests: marker collapses to one round while leaving the memory blob and unmarked
tests intact; the suite flag collapses all; time=True overrides the flag; and the
--benchmark-memory patch path honours time=False.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 pytest-benchmem | 🛠️ Build #33350614 | 📁 Comparing cf908f9 against latest (96275d9)

  🔍 Preview build  

2 files changed
± compare-plot/index.html
± reference/index.html

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.

Memory-only mode: skip the timed rounds for isolate/rss capacity benchmarks

1 participant