Maybe we should have a pinned post or blog for developers for how to optimise for the switch and best practices.
Use apple lock exit, always commit fs when creating file and closing, multithread where possible (not included same source transfer obviously), 4mb buffers for fs r/w, use boost mode during io transfers, always set file size upfront, when final size isn't known or working with limited memory (sysmod) always increase the file size in chunks of around 64k or bigger if possible, always use native fs, benchmark everything and never assume, never use ai to write code for the switch, lazy load everything (do not load all icons, metadata, configs at startup ffs), binary size is important the bigger it is the longer it takes to load and in the case of sysmod it takes up more limited memory, just like with lazy load try to multi thread exiting code to speed up exiting by 2-3x, it can sometimes pay to compress assets bundled in romfs and then inflate them at runtime as inflating GREATLY outperforms io read time, etc.etc.etc...
I can go on but you get the point.
Use apple lock exit, always commit fs when creating file and closing, multithread where possible (not included same source transfer obviously), 4mb buffers for fs r/w, use boost mode during io transfers, always set file size upfront, when final size isn't known or working with limited memory (sysmod) always increase the file size in chunks of around 64k or bigger if possible, always use native fs, benchmark everything and never assume, never use ai to write code for the switch, lazy load everything (do not load all icons, metadata, configs at startup ffs), binary size is important the bigger it is the longer it takes to load and in the case of sysmod it takes up more limited memory, just like with lazy load try to multi thread exiting code to speed up exiting by 2-3x, it can sometimes pay to compress assets bundled in romfs and then inflate them at runtime as inflating GREATLY outperforms io read time, etc.etc.etc...
I can go on but you get the point.
Post automatically merged:
Setsize is just ftruncate. You can shrink, grow etc. normally you can let the os/kernel handle growing the file optimally especially as writes are buffered, but this isn't the case on the switch.I thought the set size function only allowed you to make files larger for some reason? Guess I was wrong.
I actually found this out rewriting JKSV. If you know the end size of a file, creating the file with the size needed is a lot faster when writing than resizing and writing.











