Performance MetaDataEditor When Selecting Many Images #5122
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.
Related Issues:
In a meta data editor with 2000 images, the method
DataEditorForm.consecutivePagesSelected
is called over 2000 times when selecting an image. For large gallery sections (>100 images) and large selections (>10 images), it's execution time is relatively slow (milliseconds), which adds up when called over 2000 times to multiple seconds.For example, when selecting 50 images in a gallery section of 500 images:
simplescreenrecorder-2022-05-06_10.39.12.mp4
Or, when selecting:
Most of it's execution time seems to be related to the
distinct().count()
call. For large selections, this should be slower, since it involves pairwise comparisons. However, I'm not sure why it is also slower for large gallery sections, since the size of a gallery section should not have any influence here.Anyway, the proposed implementation improves the runtime of the method signficantly. The same selection of 50 images loads much faster:
simplescreenrecorder-2022-05-06_10.36.52.mp4
The execution time of
DataEditorForm.consecutivePagesSelected
is reduced to about 36ms in the worst case (selecting 500 images in a gallery section of 500).The remaining delay when selecting images is related to the full reloading of the gallery, structure and pagination panel.