Draft: PS2 Optimization Corpus v2 integration - #16
Draft
PunishedSnake wants to merge 156 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Integrate the PS2 Optimization Research Library v2 into
fhdb-bootstrap-manageron an isolated performance branch without destabilising the known-good HDL installer line.Base:
feature/hdl-game-installerHead:
perf/corpus-v2-integrationInitial audited baseline:
4b5aa8d85e86c9de570a2128b52d1eaa5b334844Frozen Phase-0 hardware A/B point:
7875b14d837d6332f5edc37f1c12a55527d7dd87/ CI #666Frozen resume-hash experiment:
a43b073c32348e020c234fff64615c8c4cddc98d/ CI #706Engineering rules
PS2_PERFORMANCE_BIBLE.mdsupplies the optimization workflow.-O3,-ffast-math, globalALIGN(64), MMI/VU/Scratchpad, larger buffers or higher priorities.Primary docs:
docs/CORPUS_V2_IMPLEMENTATION_PLAN.mddocs/PHASE0_HARDWARE_AB_PROTOCOL.mddocs/HDL_RESUME_HASH_BENCHMARK.mddocs/HDL_DATAFLOW_CONTRACTS.mddocs/HDL_IOP_RAM_BUDGET.mddocs/ALIGNMENT_CONTRACT_AUDIT.mddocs/ALLOCATION_LIFETIME_AUDIT.mdPhase 0: measurement foundation
Implemented:
HDDMAN.LOGparser;HDL_PROFILE=1/0builds;Frozen CI #666:
Static deltas prove PROFILE OFF is actually compiled out. They do not quantify runtime profiler overhead; that remains a real-console A/B.
Phase 1: remove unnecessary work/code
Accepted source-level cuts:
Rejected experiments remain documented, including the local draw2d shim which increased
.text.Phase 3: storage/HDL recovery experiment
CI #706 freezes the resume-hash/source-lifetime experiment. It can restore SHA state for already copied data and, for a valid complete
PAYLOAD_VERIFIEDcheckpoint, skip source reopen/fingerprint/ISO-probe work while retaining mandatory full HDD SHA-256 read-back.Any checkpoint failure falls back to the legacy source path. Journal authority and metadata durability are unchanged.
Status: HIPOTEZA DO TESTU until real PS2 correctness/crash-window/performance validation.
Phase 4: IOP/SIF preparation
Current fast COPY already follows:
USB producer prefetch is already double-buffered. SIF completion remains synchronous because EE immediately consumes one destination buffer; removing that wait without a new ownership protocol would be a race.
Known current incremental IOP budget for one active stream:
No third stage/ring is accepted before runtime free-memory and exposed-latency evidence.
Phase 5: allocation, lifetime and peak working set
Transaction workspace
CI #724 freezes workspace v1: one transaction-owned 64 KiB / 64-byte-aligned EE workspace is borrowed sequentially by COPY/source-hash and target verification. It removes one alloc/free pair without increasing peak workspace.
CI #733 workspace v2 extended ownership backwards into source admission. It removed another alloc/free pair but grew the transaction controller by 24 B / 6 instructions and lengthened the buffer lifetime. Rejected/held unless hardware data proves the extra allocator cut worthwhile.
CI #739 tests only
source_fingerprint()memalign(64, 64 KiB)->malloc(64 KiB). Pinned fileXio accepts ordinary caller alignment, but residual edge handling can still cost time. Static footprint is slightly smaller; runtime remains HIPOTEZA DO TESTU.CI #743 removed two unsupported 64-B static scratch alignments and produced zero section/BSS/text/instruction benefit. Rejected as layout-only source cleanup.
Forensic HDDMETA bounded read-back
Baseline forensic snapshot keeps a complete canonical APAMETA1 image and an equally large read-back copy alive simultaneously.
At 2048 patches:
CI #749 bounded v1 reduces read-back scratch to 64 KiB while preserving exact byte comparison, format, slot/non-overwrite policy, truncation detection and trailing-data rejection.
CI #752 bounded v2 removes v1's two
fileXioLseek()size-check RPCs. It reads exactly the expected byte count and requires one final one-byte read to report EOF.Bounded v2 vs bounded v1:
CI #752 bounded-v2 hashes:
This is a POTWIERDZONE static peak-working-set reduction and still a HIPOTEZA DO TESTU for real-PS2 recovery latency/correctness.
An independent APAMETA1 reference vector is now pinned before any canonical streaming experiment:
A future streaming serializer must reproduce that byte stream before hardware testing.
Full EE + IOP direct allocator inventory
CI #753 extends the source inventory beyond libc and distinguishes EE heap from IOP SysMem:
IOP direct ownership classes are now documented for:
The metadata verify allocation remains KEEP because it participates in write -> HIOCFLUSH -> read-back -> memcmp durability verification and costs only 1 KiB once per commit.
ThreadMan backing memory is intentionally not guessed from
CreateThread/CreateSema; real runtime IOP inventory is still required.Current gates
aligned(64)consumer-contract auditThis PR intentionally remains draft until the real-hardware A/B and regression gates are complete. Static size, architecture diagrams and emulator timing do not promote a hypothesis into a PS2 performance result.