Skip to content

feat(psp): expose allocator telemetry and arena diagnostics - #422

Merged
doodlewind merged 12 commits into
pocket-stack:mainfrom
psplumberdev:publish/psp-progress-20260912
Sep 17, 2026
Merged

doodlewind merged 12 commits into
pocket-stack:mainfrom
psplumberdev:publish/psp-progress-20260912

Conversation

@psplumberdev

@psplumberdev psplumberdev commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

PSP applications need to distinguish QuickJS request pressure from reusable arena capacity. This PR adds process-lifetime QuickJS allocation counters and a non-allocating arena free-space snapshot, without introducing product logic into the host.

Follow-up integration:

  • Preserve the last failed nonzero request across malloc(0), and saturate the call counter on long-running devices.
  • Document requested bytes versus allocator overhead, owning-thread access, and the O(free-block-count) cost of the diagnostic snapshot.
  • Exercise production arena/qjs allocator code through host substitutes in debug and optimized Rust. Cover in-place/moving/shrinking realloc, failed realloc with preserved data, zero-size calls, free-list splitting, permanent storage, and diagnostic accounting.
  • Add hosts/psp/examples/allocator-check.rs: an interactive PSP test of an 18,200,001-byte permanent buffer and real QuickJS allocation/GC/runtime teardown. CROSS repeats the workload without allocating another permanent buffer; HOME exits.

This branch includes #423 for the combined tests and device example. Merge #423 first; its changes will then disappear from this PR's main-relative diff. Original contributor commits are retained, with integration/follow-up commits appended; use merge commits rather than squash/rebase.

Validation:

  • 22 allocator cases passed (11 scenarios in debug and optimized Rust), plus 9 test-suite registration checks: 31 passed, 0 failed.
  • TypeScript check and patch whitespace check passed.
  • Pinned PSP release builds of both Hero and allocator-check passed. Generated binaries remain outside Git.
  • Linux/macOS PSP allocator and native harness checks, plus dynamic-text checks, run on the PR.
  • Physical PSP acceptance passed: the maintainer confirmed the combined allocator example after PSPLINK deployment. The captured screen showed PASS round 1, live QuickJS bytes returning to zero, and READY with no FAIL; user interaction acceptance was then confirmed.

Device build: #422 174b5c5d02ee3de733a5962884e990a0831ab68f, #423 dc4fce0ea95d0634c4fa4f014081de79fd106e53.
Command: POCKETJS_ALLOCATOR_REVISION='422:174b5c5d 423:dc4fce0e' bun tools/psp.ts hero --release --example allocator-check.
Allocator EBOOT SHA-256: 0fd19fa2ffe8b5488fbca2a2169d5f5fbde0aba3ade9bbc3bd478ae207a21431.
Acceptance procedure and API boundaries: docs/PSP_ALLOCATOR.md. No downstream game acceptance is implied.

Hardware acceptance covers #422 174b5c5d02ee3de733a5962884e990a0831ab68f and #423 dc4fce0ea95d0634c4fa4f014081de79fd106e53. Deployed PRX SHA-256: 3eaf5c10e2b97c92596a783670de8db323e0eb8608d0ac1fbded3c553296ba42. Device model was not recorded; this does not claim a downstream game acceptance.

@doodlewind
doodlewind marked this pull request as ready for review September 17, 2026 16:42
@doodlewind
doodlewind merged commit 5d191af into pocket-stack:main Sep 17, 2026
5 checks passed
@doodlewind

Copy link
Copy Markdown
Collaborator

Thanks for the contribution! The QuickJS allocation telemetry and arena diagnostics will make PSP memory issues much easier to investigate. We have completed hardware acceptance and merged this while preserving your original commits. I really appreciate the work you have put into improving PocketJS for downstream projects. Feel free to DM @pocket_js on X — I would love to connect!

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