mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-20 17:59:08 +02:00
Through Android's storage framework, every exists check, create and open is a round trip to the storage provider, and writing each file took four of them (a check of its directory, a check of the file, the create, the open). That made a 6.61 install take around 30 s on a phone, against a fraction of a second of decrypting and inflating. The install unpacks into a staging directory it has just cleared, so nothing in it can exist yet. With the new outputDirIsEmpty option, each directory is created once and each file is created and opened without checking for it first (File::WriteDataToNewFile), on the IO threads while decoding goes on. A name that turns up twice still goes the careful way, overwriting the first. The swap into place at the end is unchanged. Headless --unpack-updater uses the same path when the output directory doesn't exist yet. Its output is identical either way. With SIMULATE_SLOW_IO, unpacking the fonts went from 17 s to 7.5 s, most of what's left being the fixed cost of opening the updater. The UI's install already runs on a thread pool IO thread, so writes queued on the same pool could stall behind other long IO tasks, and the pool drops queued tasks unrun at teardown, which would have left the install waiting forever on its in-flight count. Eight threads owned by the writer (attached for JNI) avoid both, and headless no longer has to start the pool for it. Also compare file names case-insensitively when looking for repeats, since the storage usually is case-insensitive and a second create there makes a renamed copy. Checked with ThreadSanitizer, and on a read-only destination (every file fails, no hang). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>