execute Task on ImagePipeline DispatchQueue using executorPreference #815
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ImagePipeline is currently creating a Task and then immediately switching to its internal queue. This results in unnecessary context switching from the Task’s originating queue to the pipeline’s internal queue.
So, to optimize this and reduce this overhead, we can leverage a custom Task Executor introduced in iOS 18 to ensure that the Task's queue pool chooses the internal queue directly, thus improving performance and minimizing context switching.
Note:
I have not added a specific Test that validate this workflow, as in, the Task is executed on the executer's queue. This is because the current test stack in Nuke is large and I could not figure out exactly with the limited time I have, how to leverage current components to write the tests.
I will leave it here, and hopefully, If needed, another, more codebase knowledgeable contributor can implement a test for it.