Skip to content

docs(libc): record std::thread::hardware_concurrency as measured on a PS5 - #11164

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
orezraey:docs/libc-hardware-concurrency-measured-ps5
Oct 27, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
orezraey:docs/libc-hardware-concurrency-measured-ps5

Conversation

@orezraey

Copy link
Copy Markdown
Contributor

What

This records what std::thread::hardware_concurrency returns on a retail PS5 (firmware 13.60). Only docs/dev/debt/libc.md changes. The entry said the value a title expects was unverified. Measured with homebrew probes from a payload process; the sources and console logs are in this gist (phwconc, phwconc2).

On the console:

  • The system libSceLibcInternal returns 5, on the main thread and on a second thread.
  • scePthreadGetaffinity(scePthreadSelf()) gives 0xea00 on both threads, which has 5 bits set.
  • In the same process hw.ncpu, _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF read 16, and sceKernelGetAvailableCpumask reads 0x1fff (13).

So the count is the popcount of the thread's libkernel affinity mask, not a processor count. This is the rule #9447 uses for the versioned std::__sce_v2::_Thrd_hardware_concurrency, which it read from a title's libc.prx.

Whether the value follows a later affinity change is still open: scePthreadSetaffinity returned 0x80020001 in the payload process, and the POSIX cpuset_getaffinity returned ERANGE. AnyPS5 still returns the host count, because libc cannot read the libkernel mask yet. #9447 adds that path, and the code change can follow once it lands.

Tested

Documentation only. Head a4ef5fd8a9 on main 74ac0e7912. tools/check_conventions.py passes; the entry is under 1000 characters.

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(libc): set EDOM in fmod and fmodf where titles' libc.prx does #10345 (it edits the fmodf entry next to this one; merge order only)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

… PS5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head a4ef5fd8a9d9cbcc5b0940f369924a5021bbf4c6.

The new entry records the measured system-libc result separately from the host count and distinguishes it from the 16 online/configured CPUs and the available CPU mask. It also preserves the uncertainty around whether the value tracks later affinity changes. I checked the current implementation still returns the host std::thread::hardware_concurrency(), and #9447 remains open with the libkernel affinity path, so this documents an unresolved implementation dependency rather than duplicating its code change.

Checks: git diff --check upstream/main...HEAD passes; the gist URL is reachable; eligibility, conventions, intake and label checks pass. The one-line documentation change conflicts with the existing #10345 edit to the adjacent fmodf entry in docs/dev/debt/libc.md, as declared in the PR body; this is a manual merge-order conflict.

@github-actions

github-actions Bot commented Oct 25, 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 5021 docs/dev/debt/libc.md
PR 6713 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7544 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 10113 docs/dev/debt/libc.md
PR 10226 docs/dev/debt/libc.md
PR 10324 docs/dev/debt/libc.md
PR 10749 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11341 docs/dev/debt/libc.md

@github-actions github-actions Bot added the docs label Oct 25, 2026
@adriadam10 adriadam10 self-assigned this Oct 27, 2026
@adriadam10
adriadam10 merged commit 71a2001 into boykopovar:main Oct 27, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the entry against Threads.cpp on main (still returns the host std::thread::hardware_concurrency()), the diff (one line of docs/dev/debt/libc.md) and Conventions; the measured PS5 values are from the linked gist and consistent with #9447's affinity-popcount rule; merged.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants