Skip to content

fix(libkernel): raise the open file soft limit on Linux - #1645

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
XairRrR:fix/raise-open-file-limit
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
XairRrR:fix/raise-open-file-limit

Conversation

@XairRrR

@XairRrR XairRrR commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

Each direct memory backing keeps a memfd open, so a title such as Dreaming Sarah (PPSA02929) holds about 1100 descriptors at startup and about 1180 once in game. With the systemd default soft RLIMIT_NOFILE of 1024, later opens fail with EMFILE: memfd_create throws "create direct memory backing: Too many open files", or the title's fopen returns NULL and it faults in fread.

libkernel now raises the soft limit to the hard limit when it is loaded, before the title creates any descriptor, and throws if the limit cannot be read or raised. If the hard limit itself is 1024 the title still runs out of descriptors, as before. Nothing in core uses POSIX select(), so descriptors above 1023 are safe.

Environments that already raise the soft limit (some IDE terminals, CI runners) do not show it; it reproduces from a default desktop terminal or with ulimit -Sn 1024.

Tested

Arch Linux (kernel 7.2, RTX 4070 Ti SUPER), Dreaming Sarah (PPSA02929), soft limit 1024 unless stated:

  • main (4b005b2): crashes at startup on 3/3 runs; the process reaches exactly 1024 open descriptors before it dies
  • main with soft limit 4096: runs, peaking at about 1180 open descriptors
  • this branch: 3/3 runs of 30 s reach gameplay, ~60 fps
  • ctest: 463/463 passed; tools/check_conventions.py --base origin/main passed

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 in TechnicalDebt
  • 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: none
  • AI-assisted: yes

Each direct memory backing keeps a memfd open, so a title such as
Dreaming Sarah (PPSA02929) holds about 1100 descriptors at startup.
With the systemd default soft limit of 1024, later opens fail with
EMFILE: memfd_create throws "create direct memory backing: Too many
open files", or the title's fopen returns NULL and it faults in fread.

libkernel now raises the RLIMIT_NOFILE soft limit to the hard limit
when it is loaded, before the title creates any descriptor, and throws
if the limit cannot be read or raised.
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#1777 core/libs/prx/libkernel/CMakeLists.txt L9
#1860 core/libs/prx/libkernel/CMakeLists.txt L9

@popcoder565

Copy link
Copy Markdown
Contributor

Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head df3aa1a9, merged onto main 8b393b6 in one build with 31 other PRs that had no Windows run.

No title was run.

🤖 Addressed by Claude Code

@oneandonlydean
oneandonlydean merged commit c963432 into boykopovar:main Oct 10, 2026
7 of 8 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…imit

fix(libkernel): raise the open file soft limit on Linux
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.

3 participants