Skip to content

ps2link: Send each fileio write as one request with one reply - #69

Merged
fjtrujy merged 1 commit into
ps2dev:masterfrom
rickgaiser:fio-write-stream
Nov 3, 2026
Merged

fjtrujy merged 1 commit into
ps2dev:masterfrom
rickgaiser:fio-write-stream

Conversation

@rickgaiser

@rickgaiser rickgaiser commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

pko_write_file split every write into PKO_MAX_WRITE_SEGMENT (1448 byte) pieces and waited for a PKO_WRITE_RLY after each one, so writes to host: cost a network round trip per 1448 bytes. ps2client already reads a write request's nbytes from the socket whatever their size (ps2link_request_write, with a heap buffer above 64 KiB). So this sends one request header for the whole length, then the data straight from the caller's buffer, then waits for one reply. The reply is checked as before (pko_fileio_write_progress_valid, now against the whole length).

The ZEROCOPY option only chose between copying each segment into the packet buffer and sending it in place. The data is now always sent in place, so the option is removed from both Makefiles.

Measured

Real PS2 over Ethernet, ps2client on Linux. One fileio call from the EE per size, 1 MiB per size, data read back and checked:

Size WRITE before WRITE after READ (unchanged)
4 KiB 5.3 ms 3.8 ms 2.9 ms
16 KiB 20.4 ms 11.2 ms 7.9 ms
32 KiB 40.7 ms 22.5 ms 15.7 ms
256 KiB 324 ms 179 ms 125 ms
rate 0.80 MB/s 1.46 MB/s 2.1 MB/s

Tested

  • tests/fileio_reply.c and tests/exception_packet.c pass.
  • Normal and LOADHIGH=1 builds.
  • On the PS2: the LOADHIGH=1 build started from the installed ps2link, then writes and reads of 4 KiB–256 KiB through host: with the data checked.

🤖 Generated with Claude Code

pko_write_file split every write into PKO_MAX_WRITE_SEGMENT (1448 byte)
pieces and waited for a PKO_WRITE_RLY after each one, so writes to host:
cost a network round trip per 1448 bytes. ps2client already reads a
write request's nbytes from the socket whatever their size, so send one
request header for the whole length, the data straight from the
caller's buffer, and wait for one reply (checked as before).

On a PS2 (ps2link over Ethernet to ps2client on Linux), one fileio
WRITE call of 32 KiB from the EE goes from 40.7 ms to 22.5 ms, and the
sustained write rate from 0.80 MB/s to 1.46 MB/s at every size from
16 KiB to 256 KiB. Reads are unchanged (2.1 MB/s).

The ZEROCOPY option only chose between copying each segment into the
packet buffer or sending it in place; the data is now always sent in
place, so the option is gone.

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

@fjtrujy fjtrujy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice improvement!

@fjtrujy
fjtrujy merged commit 22c08eb into ps2dev:master Nov 3, 2026
6 checks passed
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