RSDKv5-Decompilation icon indicating copy to clipboard operation
RSDKv5-Decompilation copied to clipboard

Use setvbuf and allocate a heap buffer on file access

Open davidgfnet opened this issue 1 year ago • 4 comments

This works around the default 1KB buffer that 3DS newlib has, which makes I/O slow. With this "hack" I mean, workaround, load times are reduced to 25% (around 3-4x faster), making the experience enjoyable. Level loading times around around 4-6 seconds (vs ~25s).

This is a hack, ideally some intermediate loading method should be added for consoles that do not have enough ram to load the entire datapack but have enough memory to load a significant amount of it (i.e. an LRU buffer cache or something).

davidgfnet avatar Sep 08 '23 22:09 davidgfnet

Please push this fix! 🙏

obscurerev avatar Sep 09 '23 04:09 obscurerev

Interesting workaround! Though I'm not quite sure if the o3DS has enough RAM left to fit some of the bigger files entirely in memory? Also do you mind if I steal this idea for my Wii port?

Mefiresu avatar Sep 09 '23 06:09 Mefiresu

After playing a bit more, maybe I should cap the buffer at 512KB or so, or exclude ogg/ogv files. Theres a small 400ms freeze when the audio track changes.

davidgfnet avatar Sep 09 '23 10:09 davidgfnet

After playing a bit more, maybe I should cap the buffer at 512KB or so, or exclude ogg/ogv files. Theres a small 400ms freeze when the audio track changes.

The audio freeze is mostly due to the asynchronous load not being implemented yet.

Mefiresu avatar Sep 09 '23 11:09 Mefiresu