As an aside, I've since tracked down a few choice performance optimizations:
Just giving a count should be very fast now:
https://github.com/koreader/koreader/pull/5819 That is, subfolders won't significantly slow down the folder they're in anymore.
The most taxing part of the code for displaying folders is ideally ~20% faster:
https://github.com/koreader/koreader/pull/5827 The percentage is based on my test with 10k files. Also the performance improvement is less for the whole, that's just for that specific loop. But that loop is one of the slowest parts.