Possible performance degradation
Quoting @patook
I have done some testing over the past couple of hours. The XF2.2 version compiles/runs for me.
However, I am seeing some perf degradation in the alpha nugets compared to the original nugets. My observations: 1- Loading the images on start-up (from DiskCache I'm guessing) seems particularly slow as well. If I turn the app off/on there is always a long lag at the beginning until the images show up. This lag feels slower than what I had in the previous FF nugets.
2- Are the images loaded in a different order than before? Looks like some of the last ones now show up first. This could be what's causing the slowness perception.
Is this expected? Is it possible to revert to the "old" method of caching within this nuget?
@patook yes the scheduler changed:
- it supports priorization
- it loads latest tasks first
I expected that loading latest tasks first would increase speed perception therefore you say the opposite.
You can see the change here: https://github.com/molinch/FFImageLoading/blob/master/source/FFImageLoading.Common/Work/WorkScheduler.cs#L344
ThenByDescending(t => t.Position)
Could you test using git sources & change the following line so it becomes ascending?
OK that makes sense. In my case (which is a common scenario I think), I have a list of 16 images top-to-down and they get loaded in reverse order so the top images stay white for the longest time.
Yes, I can get the source code from git but it will be on Monday, is that OK? Might not be a bad idea to make this configurable regardless (i.e. let the user pick between descending/ascending based on scenario).
Also, you mentioned we can now prioritize images, quickly looking at your code it looks like this is the parameter: public Work.LoadingPriority LoadingPriority? I will play around with that as well
Sure Monday is totally fine, many thanks for your help! And don't worry: if the sorting change makes no sense we will revert it.
Yes you can now add a priority: lowest, low, high, highest or even a custom value since the enum maps to an int.
Please note that DiskCache implementation changed. So cached images will have to be redownloaded. Basically we no longer rely on a journal file. Instead the implementation is much much simpler, hence easier to maintain/debug.
@patook have you managed to play with it?
Hi @molinch
Yes - I have just finished testing after replacing ThenByDescending with ThenBy.
I believe the performance appears as good as the original nugets now so I am happy.
Personally I can work around this by customizing the priorities but I think ThenBy might be optimal for a larger number of common scenarios than ThenByDescending.
Thank you
Actually please wait a couple more hours as I am still seeing some low perf behavior after more testing.
Out of curiosity was there any change to the way local images (i.e. those under Resources) are loaded? I am perceiving a small difference in perf for them but I've tested it so many times now that I'm not 100% sure anymore.
Many thanks for the feedback ! There are a couple of changes but I don't see a particular one that would harm loading local resources. If you confirm the performance degradation I will make deeper tests.
Most changes:
- journal based disk cache to file system only
- the lib uses targets rather than specific views, a target receives the bitmap data and uses it, this allows more fine control & specific cases (like Preload)
- a few scheduler changes
- a couple of extra checks (null, target valid, ...)
- new functionalities: Preload, Priorization, Skip memory/disk caches, Delay
OK thank you @molinch . I did some more testing and I cannot conclusively say anything about local resources.
For the moment I just moved the local resources (for example the icons) to LoadingPriority.Highest and that looks good. Before that, sometimes they would be the last to load which maybe contributed to the "slowness" perception.
Since you've replaced with "ThenBy", I am fine with closing this bug if you'd like to. If I see something bad in the next week I will re-open it (or if our users will yell at us :p).
Ok let's do this way :)