[Screensaver] add a cap to the number of random images processed#14521
Conversation
| local files = {} | ||
| local num_files = 0 | ||
| -- Slippery slope ahead! Ensure the number of files does not become unmanageable, otherwise we'll have performance issues. | ||
| -- NOTE: empirically, a kindle 4 found and sorted 128 files in 0.274828 seconds. |
There was a problem hiding this comment.
Shouldn't this go by the file_cap? I'm not too sure about the name btw: in a programming context it sounds more like capacity than like an arbitrary limit.
Anyway, the actual reason I'm commenting, and I may have said this before, but this sounds like it's a fairly low default even on a Kindle 4?
There was a problem hiding this comment.
256? 300? 500? what do you have in mind? to be fair though, no has complained about the 128. people with 5000+ tend to be the exception not the rule... we know 128 good, 5000 bad. and those same people can now change that value to anything the wish to.
a cap is a limit on something.
There was a problem hiding this comment.
The time measurement sounds like 256 or even 512 should still be okay even on the Kindle 4, which is pretty much the worst case scenario. But perhaps you disagree?
Iirc I did some measurements and tests on my old H2O once and decided it was basically okay up to about a thousand, but of course that device is much faster than a Kindle 4, even if it's much slower than my newer Libra 2.
There was a problem hiding this comment.
the worst case scenario is really a kindle 2/3, I believe 128 is fine. Most people won't have more than perhaps a few dozen images, besides, is simple enough to increase the cap now. but if you want 256 I am happy to increase it.
| -- Slippery slope ahead! Ensure the number of files does not become unmanageable, otherwise we'll have performance issues. | ||
| -- Power users can increase this cap if needed. Beware though, this grows at O(n * c) where c increases with the number of files. | ||
| -- NOTE: empirically, a kindle 4 found and sorted 128 files in 0.274828 seconds. | ||
| local file_cap = G_reader_settings:readSetting("screensaver_file_cap") or 256 |
I would have named it with |
|
Not quite too late; no one's used it yet. Sorry, I thought you were on vacation so I figured I wouldn't wait for you. |
|
File-cap-nb? A cap is an upper limit imposed to something, it already means maximum and number etc. Edit: a little example
on the run, something to do with some jewels or something ;) |
May be in the wild - but not in our codebase, where explicite is better than english-scholar'ite.
After my font list got ugly radio buttons, I thought I would change trade... |
not sure what is scholar about that... what is it exactly that you want? |
|
|
|
but you now know what it means... file_count_cap? |
…ndom images processed (koreader#14521)
what's new
file_capparameter toutil.findFilesto limit the number of files scanned during directory traversal. The scan stops once the cap is reached.filemanagerutil.getRandomFileto accept and pass thefile_capparameter toutil.findFiles, ensuring random file selection respects the cap._getRandomImageto use thescreensaver_file_capsetting (defaulting to 128) for both alphabetical cycling and random image selection, preventing performance issues with large image directories.screensaver_file_capG_setting.related issues
This change is