Repository navigation
Conversation
DSperate reads a zipped DS game itself and, since it maps the ROM from a file instead of holding it in RAM, inflates it once to .dsperate/<zip stem>.nds beside the zip and keeps it for the next launch. Its own frontend keeps that folder under 2 GB (cart.cache_mb), the least recently launched first. The libretro wrapper never set that cap, so every zipped DS game I ever played stayed there at its full unpacked size, and Delete Game left it behind too. Nothing of the player's needs that copy: the save is named after the zip and a state knows its ROM by the unpacked header and size, which a copy unpacked again has too. So the launcher now holds DSperate's own rule after each DS game (2 GB a .dsperate folder, oldest launch first, never the game just played), Delete Game takes a game's copy and tag with it, and Storage counts the copy as the game's and follows it when it is unpacked again. make check-dscache fails on every part without this. Asked for on Discord.
…d DS Games The rest of the .dsperate cleanup. - The core: mk/patches/dsperate-lr-zip-cache.patch makes the wrapper set NDS::rom_cache_max_bytes to DSperate's own 2 GB, so the core removes the oldest copies as it unpacks a new one, as the launcher does after each game. mk/dsperate-zipcache-check.sh loads a zip beside 2.5 GB of unpacked games in the built core; the build runs it. New sha pinned: the same toolchain without the patch gives the old sha byte for byte. - Rename moves the copy and its tag and points the tag's archive line at the new zip, so the game is not unpacked again. A copy already under the new name does not refuse the rename. - MENU > Storage: Unpacked DS Games, a third recommendation. It sums every .dsperate from the walk's listings and deletes the copies, their tags and .part files there and nothing else; saves and states are out of reach. Strings in all 8 languages, shots in both themes. - Diatom logs how long each retro_load_game took, which is how to measure the unpacking on the handheld. Asked for on Discord.
Ubuntu's GCC failed check-linux on tools/dscache-check.c with -Werror=format-truncation: every path it built went into a buffer the size of the folder's own. Each path in that check and in the core's zip-cache check now goes through PATHF, which stops the check and says where when a path would not fit, instead of testing a cut path. The launcher files the check links were built with -Werror on Linux for the first time too, and their paths are held to the same rule now: a system's states folder, a game's .media and file in Storage, a Ports folder's subfolder, a NAOMI set's CHD folder in Delete Game and a GAMEDIR name in portinfo.c are each skipped when they would not fit, not used cut; a port's title is cut at a whole UTF-8 character. The DS paths I added (the romdir after a DS game, a game's .dsperate in Storage's signature, the realpath a renamed tag names) check theirs.
Ubuntu builds with _FORTIFY_SOURCE=3, and glibc's fortified realpath
aborts ("buffer overflow detected") on a buffer smaller than PATH_MAX,
whatever the path. check-dscache's Rename part passed realpath 1200
bytes, and so did Storage's Linux-only look at the card's partitions
(st_measure's /sys/dev/block), which the check's Storage part reaches.
Both are PATH_MAX now.
Unpacked DS Games asks with the new panel: CQ_STORE_DS_COPIES, the 40th question, the 34th marked as losing something, as Unused Art is. Its heading is the action in each language (storage.ds_heading); French and Italian short enough for one line. The question is storage.ds_ask, as before. Storage's shot of it is confirm_preview's, and check-confirm and i18n-shots know it.
This branch has not been deployed
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.
Asked for on Discord: decompressed ROMs pile up in
Roms/Nintendo DS/.dsperate.What writes
.dsperate, and whyThe core writes it, not Diatom or the launcher. dsperate-lr sets
block_extract, so DSperate gets the zip itself. DSperate maps the ROM from a file instead of holding it in RAM, so it inflates a deflated zip once to.dsperate/<zip stem>.nds(plus a.nds.tagnaming the zip) beside the zip, and keeps it so the next launch maps it at once (DSperate'ssrc/core/cart/zip_cache.h). A zip that stores its ROM is mapped in place, and a loose.ndsneeds nothing.DSperate's own frontend keeps that folder under 2 GB (
cart.cache_mb = 2048), oldest launch first. The libretro wrapper never setNDS::rom_cache_max_bytes, so on ZyperOS there was no cap at all. Delete Game left the copy behind, Rename orphaned it, and Storage counted it under the DS page's Other Files.Nothing of the player's needs the copy. The save is named after the zip, and a state checks its ROM by the unpacked header and size (
NDS::rom_identity), which a copy unpacked again has too. A removed copy only costs the next launch its unpacking.What changes
mk/patches/dsperate-lr-zip-cache.patch): the wrapper setsrom_cache_max_bytesto DSperate's own 2 GB, so the core removes the oldest copies as it unpacks a new one.mk/dsperate-zipcache-check.shloads a zip beside 2.5 GB of unpacked games in the built core. The build script runs it, and the new sha is pinned. The other DS core checks (clock, extended BGs, v3.0.5 state) still pass.src/dscache.{h,c},src/launch_screen.c): 2 GB a.dsperatefolder, oldest launch first, never the game just played. It uses DSperate's own count and order. A card that a core without the patch filled comes back under the cap after its next DS game..nds,.nds.tagand.nds.part, then.dsperateonce it is empty (src/gamedel.c). Storage sizes a game by that plan, so the copy now shows on the game's row, not under Other Files.archiveline to the new zip's realpath, so DSperate does not unpack the game again (src/gamern.c). A copy already under the new name (a game deleted elsewhere) does not refuse the rename: this copy then stays behind for DSperate to sweep.src/storage.c,src/storage_screen.c). It sums every.dsperate, at a system folder's top and in each folder of games, from the walk's own listings. It deletes.nds,.nds.tagand.nds.partthere and nothing else, then the folder once it is empty. It never follows a link and never leavesRoms/, so saves and states are out of reach. Its question: "Delete the unpacked copies of zipped DS games? 1.8 GB. Saves and states stay, and each game unpacks again when it starts." A game's size also follows its.dsperatefolder's time, so a copy unpacked again is sized again.retro_load_game's time, as it already does for dlopen and retro_init. That line is how to measure the unpacking on the handheld (below).You need to rebuild the core
vendor/is not in git, so your checkout still has the old core. Runsh mk/build-dsperate.sh(about four minutes, in Docker). Until thenmk/payload.shrefuses it, throughmk/core-stamp.sh: "dsperate_libretro.so is not the build of the patches here ... run sh mk/build-dsperate.sh". The new core's sha256 is0361a61a571ce61d34d3c8407cc71a6c288cf808c7bd9efc449d6ec03763093b. I built it with the wrapper's own Dockerfile toolchain (GCC 13.3.0-6ubuntu2~24.04.1). The same toolchain without the new patch gives the pinned5b42bc5c...byte for byte, so the patch is the only difference.Measured
On this Mac (M-series, arm64 Docker VM, the built core's own
open_zipthroughretro_load_game), on DS-like images of 55% incompressible data, 15% structured data and 0xFF padding, zipped with Deflate level 6:macOS's
unzip -pof the 512 MB zip took 2.27 s. The Pixel 2's Cortex-A35 inflates several times slower, and its microSD card writes at tens of MB/s, so I expect seconds to tens of seconds for a large game there. That is why the copies are worth keeping under a cap rather than deleting after each game. I did not measure it on the Pixel 2. To measure it there:tools/px2-deploy.sh), and put a zipped DS game inRoms/Nintendo DS/.ssh root@zyperos.local, thenrm -f "/mnt/SDCARD/Roms/Nintendo DS/.dsperate/<zip name>.nds"*so the next start unpacks it.tools/px2 log | grep "retro_load_game dsperate": the first line is the unpack plus the load, and the second is the load alone. The difference is the unpack.ls -lthe copy for its size.Choices I made
.dsperatefolder, DSperate's own default, in both the core and the launcher. A folder of games has its own, as in DSperate.store_ask). The confirm-panels branch is not pushed yet. When it lands, this needs aCQ_STORE_DS_COPIESentry in its table, as Unused Art and Old Save States get there.Checked
make check-dscache: the paths; the cap; Delete Game; Rename (the copy and tag moved, the tag naming the new zip and nothing else in it changed, a copy under the new name not refusing it, a loose.ndstaking nothing); Storage (a game's size holds its copy and follows it); and Unpacked DS Games (it measures both.dsperatefolders and deletes the copies, tags and.partand nothing else, and a stray file, the zips, the save and the state stay). Without each change it fails: Delete Game 7 times and Rename 4 times. Withsrc/storage.cas on main it does not link (nost_delete_ds_copies); without only the.dsperatetime in a game's signature, it fails once.mk/dsperate-zipcache-check.sh: the old core fails "the oldest launch's copy went", and the new one passes all four.diatom/test/coreend.pyasserts the new log line on every game's load. It fails 6 times without it.make native, thenmake -j4 check: all 274 checks pass, check-i18n-shots included.Confirm panels (#479)
main, with #479, is merged in. Unpacked DS Games asks with the new panel:
CQ_STORE_DS_COPIES, the 40th question and the 34th marked as losing something, as Unused Art is. Its heading is the action (storage.ds_heading: "Delete Unpacked DS Games", "Entpackte DS-Spiele löschen", "Supprimer les copies DS", ...), and the question isstorage.ds_ask. Storage's shot of it isconfirm_preview's,i18n-shotshasask-storage-ds-copies, andcheck-confirmcounts 40 and 34 and lays it out on every handheld in every language: side by side, nothing cut.Linux
check-linuxfailed on two things in the DS check, and both are fixed:-Werror=format-truncation. Every path intools/dscache-check.candtools/dsperate-zipcache-check.cnow goes throughPATHF, which stops the check and says where when a path would not fit. The launcher files the check links are held to the same rule: a path that would not fit is skipped, not used cut. This covers Storage's states folder,.mediaand Ports subfolder, Delete Game's NAOMI folder andportinfo.c'sGAMEDIR. A port's title is cut at a whole UTF-8 character.realpath(Ubuntu builds with_FORTIFY_SOURCE=3) aborts on any buffer smaller thanPATH_MAX. The check's Rename part, and Storage's Linux-only look at the card's partitions (/sys/dev/block), gave it 1200 bytes. Both usePATH_MAXnow.