Skip to content

feat(libSceHttp): report a context's pool in sceHttpGetMemoryPoolStats - #8357

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
MarrasFederico:feat/http-memory-pool-stats
Oct 24, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
MarrasFederico:feat/http-memory-pool-stats

Conversation

@MarrasFederico

@MarrasFederico MarrasFederico commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

sceHttpGetMemoryPoolStats threw not implemented, and its debt entry listed the signature as unknown. SharpProspero Http.cs documents it as int sceHttpGetMemoryPoolStats(int httpCtxId, SceHttpMemoryPoolStats* currentStat), which reads a context's pool use. The struct holds the pool size, the peak and current use, and a 32-bit reserved word. main has since declared the struct as those three 64-bit fields (24 bytes) in fix(http): recover request metadata and memory stats signatures, so only those 24 bytes are written and the reserved word is left to the caller.

sceHttpInit now keeps the pool size it is given for each context, and sceHttpTerm drops it. The call:

  • Live context: writes {pool size given to sceHttpInit, 0, 0} and returns 0. The library takes nothing from the guest pool, so both use figures are 0; Http2 and NpWebApi2 already report their pools this way.
  • No live context: returns ERROR_BEFORE_INIT (0x80431001) without writing.
  • Unknown or terminated id: returns ERROR_INVALID_ID (0x80431100) without writing. Both errors and their order follow sceHttpCookieFlush.
  • Null currentStat: throws, as the console's error for it is unknown. It is checked first, as Http2 does.

The debt entry records that nothing here is measured on a console and that a console already uses part of the pool for a live context.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

  • guest_http:
    • Before any sceHttpInit, ids 0, -1 and a request id return ERROR_BEFORE_INIT.
    • With a live context, ids 0, -1, INT32_MAX and a request id return ERROR_INVALID_ID. Two live contexts report their own pool sizes (0x10000 and 0x23000), and a pool above 32 bits (0x123456000) and a pool of 0 are reported unchanged.
    • A terminated context returns ERROR_INVALID_ID while the other is unaffected, and ERROR_BEFORE_INIT comes back after the last sceHttpTerm.
    • A null pointer throws with a valid and with an invalid id. No error writes into the sentinel-filled output or the 16 bytes after it.
  • The test fails on main, where the call throws. Storing a constant pool size, not dropping it on sceHttpTerm, or skipping the ERROR_BEFORE_INIT check makes it fail.
  • All three tests matching http pass.
  • Updated to main 524398151f. The branch adopts main's declaration and 24-byte struct. The test now checks that nothing past those 24 bytes is written; writing a reserved word after them makes it fail. All 4 guest_http tests pass.
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py finds no conflicting lines. It could not compare test: organize library tests and label CTest suites #6044 (test reorganization), which conflicts with main. The branch also merges cleanly with feat(libSceHttp): keep options per template, connection and request and implement their getters #8245, which reworks the HTTP options in the same file.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(http): preserve context and epoll state on allocation failure #9630
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Progress report (8b3e398 → 73822f3)

📈 System libraries: 43.24% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceHttp sceHttpGetMemoryPoolStats

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 6044 core/libs/tests/GuestHttp.cpp
PR 9822 core/libs/prx/libSceHttp/Export.cpp
PR 9826 core/libs/prx/libSceHttp/Export.cpp

@xXPBSXx

xXPBSXx commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Independent Windows run of this PR (data only).

Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against main 339217e is clean. I built only guest_http_tests; ctest -N -R guest_http lists exactly one test.

Results (3 runs each):

  • PR head: guest_http passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/libs/prx/libSceHttp/Export.cpp with the version from the PR's merge base (777bd0f4b2), then rebuilt. The test fails 3/3 (exit 0xc0000409, a failed Require). I restored the PR's Export.cpp afterwards.

Not run: other platforms, the other Http tests, the full repository CTest, and any title or console run.

AI-assisted (Claude Code).

@adriadam10 adriadam10 self-assigned this Oct 21, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 21, 2026
…ol-stats

# Conflicts:
#	core/libs/prx/libSceHttp/Export.cpp
#	docs/dev/debt/libSceHttp.md
@Ondra97

Ondra97 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

I opened #9630 to fix allocation-failure ownership in HTTP initialization, epoll creation and final-context teardown. Your pool-size registry also adds work to initialization and termination. I propose merging #9630 first, then rebasing this PR and retaining rollback across every context registry. #9630 has no dependency on the pool-stat implementation.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@Ondra97 agreed: #9630 first, then I'll rebase this PR onto it.

You're right about the registry. This PR inserts the pool size before g_contexts.insert, so a later allocation failure in sceHttpInit would leave a stale entry. When I rebase, the pool-size insertion will move inside your rollback: on failure it is erased together with the context and its options. sceHttpTerm keeps erasing it with the context.

I'll note the dependency here once #9630 is merged.

@DoubleAAGuy

Copy link
Copy Markdown

Thanks for the detailed pool-stats work. My separate PPSA90210 request-transport PR also registers net/SSL state in sceHttpInit and removes it on sceHttpTerm. I plan to sequence after #9630 and #8357, then rebase and integrate your pool-size registry without touching sceHttpGetMemoryPoolStats. Does that order work for you?

@DoubleAAGuy

Copy link
Copy Markdown

The request-transport work is now in draft #9834. It declares #9630 and #8357 as prerequisites; I will compose the transport context map with your pool-size registry inside #9630’s rollback/teardown after both land. I will not change sceHttpGetMemoryPoolStats.

@MarrasFederico

Copy link
Copy Markdown
Contributor Author

@DoubleAAGuy yes, that order works for me: #9630, then this PR, then #9834. When #9630 lands I'll rebase here and put the pool-size insertion and its erase inside #9630's rollback and teardown, next to the context and options, so your transport map can sit beside it. I won't change the registry's shape after that rebase without telling you here.

@adriadam10
adriadam10 merged commit a39be62 into boykopovar:main Oct 24, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked against current main: the feature commit is unchanged, guest_http still fails on main where the call throws and covers invalid ids, two live contexts, a pool above 32 bits, pool 0, untouched output on errors and a null pointer; debt entry present, Windows run by @xXPBSXx on the earlier head; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants