-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve the ImageEx control performance #3255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the ImageEx control performance #3255
Conversation
merge original source
Thanks h82258652 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
@h82258652 The My guess is that you have all the loading being run synchronously on the UI thread. If you are loading a lot of images, most of the code from I haven't tried it yet but looking at the code it seems that add a |
@vgromfeld You are right. I try to add |
I tried to investigate more this week-end but still didn't found the root cause. I found that |
@Sergio0694 curious on if you have any thoughts in this area? I'm hesitant to do anything in this area without us knowing the root cause and understanding a proper fix. @vgromfeld @azchohfi I'm thinking we may want to just defer this to 7.0 and maybe investigate a revamp or audit of the ImageEx control? |
The ConfigureAwait(false) should speed things up, not slow them down... I wonder if this has anything to do with the AsTask(), but I honestly don't know how it works internally. I believe we should defer this to 7.0. |
Agree to move this to 7.0. My current guess is a thread pool issue with too many tasks competing for the UI thread but this will require more tests to validate. |
Sorry for the delat @michael-hawker - completely missed the notification here! 😅 I agree with @azchohfi on this, the culprit is very unlikely to be the To elaborate on |
@h82258652 did you have some time to look at this? Thanks! |
Sorry so late for the response. |
@h82258652 Ok uh... This is indeed very strange 🤔 ✅ The weird part is that in this case both changes should be unrelated from "the UI thread". Which means that in theory the rest of the asynchronous method will already be in a thread pool thread and not in the original synchronization context, regardless of the changes done in this PR in particular. Also I'm really not sure why would this line in particular change anything, considering there are 4+ other At this point if I had to make a wild guess I'd say maybe that At this point @azchohfi I'd say it's a matter of deciding whether to just accept the PR as a temporary workaround or hold until we can actually understand what's going on here? If you're concerned about the flow to the UI thread, that |
@Sergio0694 |
Here is link that may help to investigate this issue: .NET Threadpool starvation, and how queuing makes it worse. We may face the same kind of issue when trying to load a lot of images. The queueing between .Net Using the Thread Pool ETW events and Diagnosing .NET Core ThreadPool Starvation with PerfView (Why my service is not saturating all cores or seems to stall), we should be able to confirm if it is the case or not. |
Going to convert this to a draft PR as we're still trying to figure out the best solution to this problem, thanks! |
@h82258652 have you looked through the guidance that both @Sergio0694 and @vgromfeld have provided? Curious if you're still planning to investigate a better solution or if we should close this PR for now? |
@michael-hawker |
Thanks @h82258652 I'll close this for now and point in the issue to the discussion in the PR here. |
Fixes #3250
Remove
AsTask().ConfigureAwait(false)
from two lines inCacheBase.cs
.I don't know why but it really works.
PR Type
What kind of change does this PR introduce?
What is the current behavior?
If you load lots of images at the same time, it will block the UI very long.
What is the new behavior?
Load faster than before, it only blocks the UI 1/4 times long on my computer.
PR Checklist
Please check if your PR fulfills the following requirements:
Other information