PSA for Developers: If you have performance issues in your homebrew recompile with latest VitaSDK

Discussion in 'PS Vita - Hacking & Homebrew' started by Mastak, Apr 7, 2017.

  1. Mastak
    OP

    Mastak Advanced Member

    Newcomer
    99
    40
    Oct 17, 2015
    United States
    Kudos to Kerbangman for being my VPK-tester over the last 5 weeks because I don't have a PS Vita and frangarcj for resolving the newlib-bug within 2 hours.

    FOR USERS:

    In most cases the only noticable change is a significant reduction in loading times, e.g. for roms in Retroarch (RA already applied the fix, start testing). No, this will not allow Dolphin Emulator on PSVita. No, this will not make all RetroArch cores reach 60 FPS. Framedrops are usually caused by the slow CPU/GPU of the Vita, not by slow file reading. Due to the location of the bug probably other functions were affected, too, which means there could be minimal framerate improvements in general - Don't expect any wonders.

    FOR DEVS:

    You need at least SDK v274. The MacOS build of this SDK version failed. Only the Windows and Linux VitaSDK are fixed.

    tl;dr: This usually affects you when you use stdio (fopen, fread & friends), the C++ equivalent (std::fstream) or pthreads (sce-Api is unaffected). Due to the location of the bug (Reentrancy handling and Thread local storage) it could also make other functions significantly slower. Simply recompiling with the latest VitaSDK is enough - No code changes needed.

    Benchmark: The IO is, depending on how often you do it, up to 25 (!) times faster. We designed a test program which needs 2 seconds with the old SDK and 80 milliseconds with the new SDK. We have no benchmark for pthreads but in theory they should be slightly faster because the buggy code was shared with them.

    The bug (https://github.com/vitasdk/newlib/issues/18) was introduced in the VitaSDK beginning of September 2016. Since end of February '17 (I was a bit behind with VitaSDK updating) I was investigating a significant performance regression that was reported in my homebrew. After 5 weeks (was not working fulltime on this) the cause was still not found and out of sheer despair I downgraded newlib to an August 2016 version and it magically fixed the problem.

    You probably never heard about Newlib before: Newlib is basicly a library that provides a POSIX (Linux-like) abstraction layer, so you can use normal C/C++ standard APIs on embedded hardware and everything works as expected. Fancy stuff!