Skip to content

test(cache): respect kernel purges in history eviction checks - #819

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
yucelokan:codex/purgeable-history-test
Oct 20, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
yucelokan:codex/purgeable-history-test

Conversation

@yucelokan

Copy link
Copy Markdown
Contributor

Summary

Make the purgeable-history eviction regression independent of when the kernel reclaims consumed packet data. Check the no-eviction case while packets are still unread and therefore protected from purging.

What changed

  • Move the initial no-eviction assertion before consuming packets. After consumption, history is legitimately purgeable, so assuming it remains resident makes the test depend on memory pressure.
  • Preserve the explicit purge, eviction, stale-cursor refusal, and unread-data assertions.
  • Explain the ordering in the test and update CHANGELOG.md. Production code and public APIs are unchanged.

Test plan

  • Device / OS: MacBookPro18,1, macOS 27.0.1 (26A434); Xcode 27.1 (27A9275), Swift 6.4.
  • Source media: synthetic packet records in the existing memory FIFO fixtures; no container, codec, audio, or HDR/DV decoding involved.
  • Result: swift build -j 2 passed, including ExampleSources. swift test -j 2 --filter SoftwarePacketMemoryFIFOTests passed all 11 tests. python3 Scripts/check-doc-links.py passed.
  • Validation covers the affected FIFO behavior. The full suite and device playback were not rerun for this test-only change.

Checklist

  • CHANGELOG.md updated
  • Commit messages follow Conventional Commits
  • The fix lives in the engine's regression test, not in a host-side workaround
  • Public API changes are intentional and documented (no public API changes)

@superuser404notfound
superuser404notfound merged commit 9c544c3 into superuser404notfound:main Oct 20, 2026
4 checks passed
superuser404notfound pushed a commit that referenced this pull request Oct 20, 2026
… it (#819)

#819 fixed the race in the eviction test, where the kernel could empty
consumed history between pop() and the no-eviction check. The same race
sat in every test that re-reads history: a cursor restore, a still walk,
the history-cap recent restore and the read-ahead's seek-back hit could
all fail at random under suite memory pressure.

SoftwarePacketMemoryFIFO gains an internal kernelMayPurge switch. With it
off, consumed chunks are marked volatile in the store's bookkeeping only
and stay non-volatile for the kernel, so purgeHistoryForTesting (which
also empties a non-volatile region) is the only thing that empties them.
The history-reading tests use it, and the eviction test checks the
no-eviction case on real history again instead of before any exists. The
purge, walk-refusal and residency-count tests keep real kernel purging.
Playback always constructs the store with the default (true).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged, thanks @yucelokan. The diagnosis is right: consumed chunks are volatile VM, and the kernel may empty them between pop() and the next line.

Two follow-ups landed on main in a320dab:

  • The same race was in the other tests that re-read history. restoreBackward, readHistory, the recent restore in historyCap, the read-ahead seek-back hit and purgedMemoryHistory in the resident-range suite could all fail with a cache miss under suite memory pressure.
  • Before the first pop(), !evictPurgedHistory() holds trivially (headID == 0, so no chunk qualifies as history). The test therefore no longer covered "history exists, nothing emptied, so nothing is evicted".

The fix is an internal kernelMayPurge: false on SoftwarePacketMemoryFIFO. With it set, consumed chunks count as volatile in the store's own bookkeeping, but the kernel keeps them non-volatile. That leaves purgeHistoryForTesting as the only thing that empties them, which works on a non-volatile region as well. The tests that re-read history use it, and the eviction test is back to checking for no eviction after the 90 pops. The purge, walk-refusal and residency-count tests keep real kernel purging, so the vm_purgable_control path is still covered. Playback is unchanged.

superuser404notfound pushed a commit that referenced this pull request Oct 21, 2026
…changelog for #829

A prepared commit rebuilt the primary takeover by hand and skipped three things the ordinary
external select does: it left a running OCR worker armed, logged nothing (a commit was invisible
in the diagnostic log), and did not re-assert the native rendition while the picture is off this
device (Sodalite#156). Preparation and commit also refused a session mid-seek as stale, although
`loadGeneration` already catches teardown; `.seeking` now counts as the same session.

The AVERROR_EOF literals read `FFmpegErr.eof`, and the intent counter no longer sits between
`loadGeneration` and its doc comment. The #819 and #827 changelog entries had landed under
7.40.0 and move to Unreleased with the #829 one, now in house style.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.45.0 (52802af).

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.

2 participants