Breakwater

Sandboxes / #1147

perf: add __slots__ to Marker

pypa/packaging#1147 · merged 2026-04-05 · base 04a7600a21 → head 76cc629825 · ran on Sandboxes

BLOCK

At least one behaviour change looks like an unintended regression.

Known regressions in this PR

Counterexamples · 1 class: 1 likely bug

P4

Old pickles break

known regression: marker-pickle
inputMarker("\"b\" > \"a\"")
basepickled object loads and compares equal
headload: raises AttributeError
Likely bugvotes: 2 likely-bug, 1 needs-human

Adding __slots__ changes the pickling format; objects pickled by the base version (which had a __dict__) cannot be unpickled by the head version (which expects slot storage), causing an AttributeError. The PR introduces the slots without any compatibility handling, and the change is described only as a performance tweak.

__slots__ = ( '_markers', )
perf: add __slots__ to Marker

Found by: project's test strings, hostile mutation · also caught by: Mutations of the PR's own test strings

ran onToken Factory Sandboxes · image 583e9e77-230e-4727-b18e-e799efeb03f4

Regression test verified passes on base, errors on head
def test_1147_p4_base_head_load_0():
    """Breakwater P4: base behaviour pinned (found by differential testing; label: likely-bug)."""
    import base64
    import pickle
    # pickled by the base version (lazy caches warmed first)
    old = pickle.loads(base64.b64decode('gASVlgAAAAAAAACMEXBhY2thZ2luZy5tYXJrZXJzlIwGTWFya2VylJOUKYGUfZSMCF9tYXJrZXJzlF2UjBFwYWNrYWdpbmcuX3BhcnNlcpSMBVZhbHVllJOUKYGUTn2UjAV2YWx1ZZSMAWKUc4aUYmgHjAJPcJSTlCmBlE59lGgMjAE+lHOGlGJoCSmBlE59lGgMjAFhlHOGlGKHlGFzYi4='))
    assert old is not None  # loading must not raise
Reproduce
uv run breakwater probe --repo https://github.com/pypa/packaging --base 04a7600a21fe --head 76cc62982548 --target packaging.markers:Marker --backend contree --input "\"b\" > \"a\""

Regression tests

1 of 1 classes have a generated pytest that pins the old behaviour. Each passed on the base commit and failed on the head commit in the sandbox before it was offered.

Download test_1147.py

Performance · Marker

No realistic input family measured slower.

head slowerhead faster1×100input size (characters)F2F2: 1.00× at ~27 charsF2: 1.00× at ~27 charsF2: 1.00× at ~27 charsF2: 1.00× at ~27 charsF2: 1.00× at ~27 charsF2: 1.00× at ~27 charsF2: 1.00× at ~27 chars
  • F2
Head/base cachegrind instructions per call, by input size (log-log). Each line is one input family Nemotron proposed; points above 1× are where the "faster" code does more work.
FamilyInputsRatio range Slope base → headVerdict
F2many simple markersclaimed speedup · plan1.00× – 1.00×0.00 → 0.00neutral

Receipt

TargetBackendImageRun AuditAdjudication
packaging.markers:MarkerToken Factory Sandboxes583e9e77-230e-4727-b18e-e799efeb03f4bt-1147-6bdc51$0.031$0.011

Nemotron cost on Nebius Token Factory. Backend: where the untrusted code ran. Token Factory Sandboxes (a microVM branched from a kept image, cited by its UUID). Every image is content-addressed (repo at each commit + harness), so every card re-runs from the image and seed 0. Raw data: audit, adjudication.