Repository navigation
fix(libkernel): bound equeue pending events - #7509
Conversation
Undrained triggers queued without limit and AddEvent copied the whole queue, so a flip/vblank flood could exhaust the host heap while guest memory stayed free. Keep the armed event plus at most 64 queued events per registration, dropping the oldest queued event past the cap and keeping the latest payload; an AddEvent carrying more keeps the latest 64. Drained bursts report as before.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Linux datapoint at head |
|
Thanks for the Linux run. That independently confirms the bounded AMPR flood and the seeded AddEvent queue pass on the current head, complementing the Windows focused run in the description. |
|
Confirmed on Ubuntu 24.04 (GCC 13.3) as well as Windows, with this PR merged onto
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
Windows run of head
Titles: VideoOut is the only producer that queues behind an armed event. PPSA99169 (RetroArch), PPSA01153 (OliSe Player) and PPSA74126 (Stremio Plus), 60 s each against the same build with On the limit itself: FreeBSD 11.4 has no per-knote queue (repeated activations of an Not checked: Linux, macOS, a console, the Written with Claude Code assistance (validation by a subagent, reviewed in this session). |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, To pick it up: Head is |
|
Rebase handoff — rebased onto current
Verified on Linux (CachyOS, kernel 7.2.10, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
@Pouare514 thanks for this. Main still has an unbounded pending-event queue, so this is still wanted. It needs a rebase: the library change applies cleanly, and the only conflicts are add/add in core/libs/tests/GuestEqueueEvents.cpp and docs/dev/debt/libkernel.md. One question while you're there: where do 64 and drop-oldest come from? A dropped completion is a silent loss for a guest that drains later expecting every event. If it's a chosen bound rather than a console measurement, please say so in the debt entry, and say how many in-flight completions you've seen titles actually queue. |
# Conflicts: # core/libs/prx/libkernel/Equeue/Equeue.cpp # core/libs/tests/GuestEqueueEvents.cpp # docs/dev/debt/libkernel.md
…dropping them silently Triggers and AddEvent past the 64-event pending cap dropped the oldest queued events with no record. Each dropped-oldest batch is now counted per queue (DroppedPendingEvents()) and logged, gated on APS5_TRACE_EQUEUE and rate-limited to the first drop and each power-of-two of the cumulative total, so a long burst reports in log2 lines rather than one per drop. The cap value and the drop-oldest (keep-newest) semantics are unchanged, pending the console queue-depth / keep-newest-vs-oldest question on #7509. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What
Bound
pendingEventsper equeue registration to the armed event plus at most 64 queued events. A trigger past the cap drops the oldest queued event and keeps the latest payload; anAddEventcarrying more than 64 keeps the latest 64. Drained bursts report exactly as before. The cap lives inKernelEqueuePrivate::kMaxPendingEventsand is enforced centrally inTriggerEvent/AddEvent, so it covers every producer with the queue-behind pattern (VideoOut flip/vblank, AMPR completions) instead of patching one filter.AddEventbuilds the stored event field-by-field and copies at most 64 queued entries, so it never copies an unbounded host queue.Tested
Release Ninja
BUILD_TESTING=ON(MinGW GCC 15.2) on Windows.ctest -R "guest_equeue_events|guest_kqueue|guest_socket_events": 3/3 pass (equeue 0.48s, kqueue 3.06s, socket_events 0.21s).guest_equeue_eventscases: 100k undrained AMPR triggers stay bounded (deliver exactly 65 = 1 + 64, last payload is the latest) and anAddEventseeded with 20k queued events is truncated to 65 with the latest preserved; small bursts (existing 2- and 3-completion AMPR tests) still deliver every event.Equeue.cppreverted (new tests kept),guest_equeue_event_testsaborts onRequire(total <= kBound)after the flood (unbounded 100k deliveries). Pass-with: same binary passes after restoring the fix (exit 0).git diff --checkclean;python3 tools/check_conventions.py --base origin/mainpasses; no//in added C++ lines.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)