Ticket #546 (closed task: moved)

Opened 6 years ago

Last modified 5 years ago

Minimize time spent harmonizing Datasets/ImagePluses

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej-2.0.0
Component: Legacy Compatibility Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking: #1011, #1170

Description

Right now, in LegacyPlugin, prePluginHarmonization() code is run that makes sure all Datasets that have associated ImagePluses refresh the ImagePlus data before the legacy plugin is run.

We could improve the performance of this process by making LegacyImageMap track which Datasets have changed. It could track that via listening to Dataset events. New Dataset/ImagePlus mappings would be marked as "same". On event firings specifc Datasets would get marked "different".

In LegacyPlugin we'd only harmonize those ImagePluses whose Dataset has been recorded as "different" by the LegacyMap. And in postPluginHarmonization() the LegacyImageMap could be informed that the the Dataset is "same".

Change History

comment:1 Changed 6 years ago by bdezonia

  • Priority changed from minor to major

comment:2 Changed 6 years ago by bdezonia

trick question: when are Dataset events processed? The legacy layer can generate them during harmonization. Are they handled immediately or are they handled after return from running the LegacyPlugin itself? If the latter then marking as "same" would be immediately undone by the old events sitting around from harmonization. Thus all the tracking/updating optimizations could be fruitless. Investigate.

comment:3 Changed 6 years ago by bdezonia

Another thought: can we set ImagePlus.changes to false before plugin call and check it afterwards to decide whether to do harmonization? Need to see how good IJ! is about maintaining the changes flag.

comment:4 Changed 6 years ago by bdezonia

There are other ways to minimize harmonization and keep ImagePluses fresh:

  • have the legacy layer track a dirty bit for Datasets. In prepluginHarmonization() only update ImagePluses whose associated Dataset is dirty.
  • have the legacy layer track Dataset events and make some immediate changes (such as setPosition() with regard to slider changes) or record other changes that can be run later (such as DatasetChangedEvent). Then during prepluginHarmonization() update ImagePluses that have recorded events. The legacy layer could define its own internal update needs (via bitmask or enum).
  • in prePluginHarmonization mark each ImagePlus changes field to false. On postPluginHarmonization() only update Datasets whose associated ImagePlus has the changes flag set to true. The changes flag might not catch everything and so maybe we always need to do some updating (metadata perhaps).
  • hook more IJ1 methods via CodeHacker and update or event record changes in that direction also.

comment:5 Changed 6 years ago by bdezonia

  • Milestone changed from imagej-2.0-beta1 to imagej-2.0-beta2

comment:6 Changed 6 years ago by curtis

  • Blocking 1011 added

comment:7 Changed 6 years ago by bdezonia

  • Blocking 1070 added

comment:8 Changed 6 years ago by bdezonia

  • Milestone changed from imagej-2.0.0-beta3 to imagej-2.0.0-beta4

comment:9 Changed 5 years ago by bdezonia

  • Blocking 1170 added; 1070 removed

comment:10 Changed 5 years ago by bdezonia

  • Milestone changed from imagej-2.0.0-beta4 to imagej-2.0.0

comment:10 Changed 3 years ago by curtis

  • Status changed from new to closed
  • Resolution set to moved
Note: See TracTickets for help on using tickets.