test(libSceIcu): convert the scalar sweep in runs instead of one call per scalar #26783
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26783"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by cozejarr on 2026-11-24T21:34:13Z.
What
guest_icu_utf_conversionsruns close to its 10 sTIMEOUTand times out under parallel load.Scalars()converts each of the 1,112,064 Unicode scalars with three separate calls (u_strFromUTF8,u_strToUTF8,u_strFromUTF8Lenient), about 3.3 million calls. Since #25526, the two strict conversions copy their operands through guest memory on every call, so the sweep alone takes about 7.4 s on Windows. The whole test took 9.03 s in a fullctest -j12run onmainon Windows. On a 4-core Linux container it took 9.5 s on its own and timed out at 10.15 s in a fullctest -j4run onmainat5f04682cef.This PR converts the scalars in runs of about 8 KiB of UTF-8, 535 runs in all. Each run goes through all three directions, and the test compares every unit, the length and the terminator. The two strict directions get room for exactly the result plus its terminator, and a canary after it is checked.
u_strFromUTF8Lenientneeds a capacity sized from the UTF-8 source, so it gets that capacity (bytes + 1) plus one element beyond it, and every element after the terminator, including the one past the capacity, must be untouched. The single-scalar checks, with their canaries, still run for the scalars at every UTF-8 and UTF-16 width boundary (0,1,7f,80,7ff,800,d7ff,e000,fffd,ffff,10000,10ffff). Every scalar is still converted and compared exactly. The runs also span several pages, so the page-sized chunksGuestCopyInreads now split multibyte sequences, which the one-scalar calls never did. The library is not changed.Tested
main5f04682cef:guest_icu_utf_conversionsgoes from 7.39 to 7.45 s (3 runs) down to 0.08 s (5 runs). All 95guest_icu*tests pass.guest_icu*tests pass.UtfConversions.cppdecoding U+5432 as U+5433, the test fails with "scalar run UTF-8 decode". With it encoding a wrong lead byte for U+ABCD, the test fails with "scalar run UTF-16 encode".0ad66daf9fc): the check of the lenient buffer's tail. On Linux the test passes 3 of 3 in 0.06 s, and with that check's expected value changed it fails with "scalar run lenient tail", so the check runs.c2a0c13039f(since5f04682cef,mainchanged no ICU files), on Linux: 95 of 95guest_icu*tests pass, and the test takes 0.06 s (3 runs).tools/check_conventions.pyandtools/debt_fold.py --checkpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-24T21:57:26Z.
Review: COMMENTED
The batching is sound and independently removes the Windows timeout risk at exact head
2e22f7b8510ec2e7bfc2bf50bf9f1bc6eb625196. I count all 1,112,064 non-surrogate scalars in 535 non-empty runs, plus the 12 deliberate boundary probes. Counted U+0000 remains covered. In a clean WinLibs Release build,guest_icu_utf_conversionspassed 5/5; after the cold run the reported test time was 0.05 s in each of four runs (the cold run itself was 0.88 s). A local one-scalar expected-value mutation at U+5432 failed atscalar run UTF-8 decode; after byte-exact restoration and rebuild, the test passed again at 0.11 s.One small coverage/description correction is worth making before merge. The strict run directions check the terminator and the immediately following canary, but the lenient run checks only its terminator. Because that API currently requires capacity based on the UTF-8 source length, its buffer is intentionally larger than the UTF-16 result, so the PR description's “room for exactly the result plus its terminator” is not true for this direction. Please give the lenient vector one extra element beyond the declared capacity and verify the untouched tail (at minimum the element immediately after the terminator and the canary just beyond the passed capacity), then describe that capacity rule accurately.
The causality sentence should also distinguish the paths: #25526 added checked guest copies to the two strict conversions; the lenient conversion's guest-pointer change is still open in #22460. The measured improvement remains valid.
I found no duplicate batching PR. #22460 touches this fixture in non-overlapping hunks.
AI-assisted: yes (OpenAI Codex); exact head/base/blob, loop counts and bounds, build output, CTest runs, negative-control failure, and byte-exact restoration were checked directly.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-24T22:09:09Z.
Review: APPROVED
Both review points are resolved at exact head
0ad66daf9fc405f3a7df34df952d944d5261deca.The lenient run now keeps its required source-length-based capacity, allocates one additional element beyond that capacity, and verifies every element after the terminator through the out-of-capacity canary. The PR description now correctly attributes the checked guest copies to the two strict conversions added by #25526 and explains the lenient capacity rule separately.
I rebuilt the exact changed test blob (
b6e8f684bcb7ac2932adfbf13b2c243d21bad1a5) in the same clean Windows WinLibs Release review build.guest_icu_utf_conversionspassed 5/5 at the new head (0.05–0.12 s reported test time). As a negative control, I locally changed the first lenient tail element after the terminator; the test failed atscalar run lenient tail. After byte-exact restoration and rebuild, it passed again at 0.12 s.The earlier full-coverage check still holds: all 1,112,064 non-surrogate scalars are converted in 535 non-empty runs, with 12 separate boundary probes. No production code changes.
AI-assisted: yes (OpenAI Codex); exact head/blob, diff, loop coverage, capacity/tail bounds, Windows build, five positive runs, negative control, and byte-exact restoration were checked directly.