feat: memory-only mode skips the timed rounds (closes #124)#127
Open
FBumann wants to merge 1 commit into
Open
Conversation
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>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #124.
Problem
A capacity benchmark marked
@pytest.mark.benchmem(isolate=True)only wantsrss, 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:
time=False(per-test)--benchmark-memory-only(a per-testtime=Trueopts back in)Both entry points honour it — the
benchmark_memoryfixture and the--benchmark-memorymonkeypatch — by routing the timed leg throughpedantic(rounds=1, warmup_rounds=0, iterations=1). The memory pass (repeats / isolate / ceilings) is untouched.Design notes
profile_native(_memory_only_from_node/_global_memory_only).—) 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.timerow + an isolate-path tip; the live flags table picks up--benchmark-memory-onlyautomatically.Tests
time=Falsecollapses to one round while leaving the memory blob and unmarked tests intact;--benchmark-memory-onlycollapses all;time=Trueoverrides the flag; and the--benchmark-memorypatch path honourstime=False. Full suite green; ruff + format + mypy clean.🤖 Generated with Claude Code