| 1 |
Updates are done by explicitly looping through lists of objects and items. |
| 2 |
|
| 3 |
Kst::Objects keep track of and/or provide |
| 4 |
|
| 5 |
serial: the serial number (from doUpdates()) of the last time it was updated. |
| 6 |
|
| 7 |
serialOfLastChange: the serial number of the last time an update actually led to a change. |
| 8 |
|
| 9 |
minInputSerial(): the min serial of any input primitives to the object |
| 10 |
This method querries the inputs. |
| 11 |
|
| 12 |
maxInputSerialOfLastChange(): the max serial where on of the input primitives was actually changed. |
| 13 |
This method also querries the inputs |
| 14 |
|
| 15 |
objectUpdate(new_serial): |
| 16 |
return NoChange if serial == new_serial |
| 17 |
return Deferred if minInputSerial < new_serial (an input hasn't be updated yet) |
| 18 |
return Changed after calling internalUpdate() if maxInputSerialOfLastChange > serialOfLastChange |
| 19 |
return NoChange otherwise |
| 20 |
|
| 21 |
internalUpdate(): actually perform an update. ** should only be called by objectUpdate ** |
| 22 |
|
| 23 |
ObjectManager::doUpdates(): The loop for updating Kst::Objects. Calls objectUpdate(). |
| 24 |
doUpdates() is called by: |
| 25 |
-datasources, by their timer or watcher |
| 26 |
-dialogs, at the end of apply() or equivalent |
| 27 |
|
| 28 |
Algorithm: |
| 29 |
loop over all datasources |
| 30 |
set serialOfLastChange if there was new data |
| 31 |
|
| 32 |
do |
| 33 |
loop over all Objects (except data sources) |
| 34 |
retval = objectUpdate() |
| 35 |
until no retval's == Deferred |
| 36 |
|
| 37 |
|
| 38 |
MainWindow::updateViewItems(serial): update plotitems and then views |
| 39 |
called by a signal emitted at the end of doUpdates() |
| 40 |
|
| 41 |
loop over all plot items: |
| 42 |
plotItem::handleChangedInputs() |
| 43 |
|
| 44 |
if any plotItems changed |
| 45 |
_tabwidget->currentView()->update() |
| 46 |
|
| 47 |
-------------- |
| 48 |
ToDo/shortcomings |
| 49 |
|
| 50 |
-The object loop in doUpdates is inefficient, in that it may have to go through the loop |
| 51 |
up to D times, where D is the heirarchy depth. The loop could instead re-sort the objects as it |
| 52 |
goes, so that for future visits, nothing would be deferred. In practive, objectUpdate(new_serial) |
| 53 |
where new_serial == _serial is pretty cheap, and probably doesn't produce a noticible slowdown. |
| 54 |
In practice the heirarchy depth is 2 (curves of dataVectors) or three |
| 55 |
(curves of PSD's of dataVectors) |
| 56 |
|
| 57 |
-The updateViewItems loop only considers plot items to trigger a view update. It does not check |
| 58 |
if labels have changed. In practice, it is rare to have only labels from a data source, and no |
| 59 |
plots, but if one were to do this, it would not get real time redrawn. The solution is to add |
| 60 |
labels to the list it checks. |
| 61 |
|
| 62 |
-The updateViewItems loop will update the current view if any plots have changed: if only plots on |
| 63 |
other tabs had been changed, it would be better to not update the current view. Not common, and |
| 64 |
the update is pretty fast if the plot didn't change. |
| 65 |
|
| 66 |
-doUpdates() could be threaded |
| 67 |
the data source loop should not be threaded. It's to cheap to be worth the threading overhead. |
| 68 |
data primitives should be looped over before all other objects |
| 69 |
whether data primitives updates should be threaded depends on the nature of the datasource and |
| 70 |
on the media it is being read from to avoid disk thrashing - dirfiles will suffer from threading |
| 71 |
data primitive reads, but data sources that store their data contiguously will benefit (eg, ascii). |
| 72 |
Using flash drives should mean all data primitives would benefit from threading. |
| 73 |
|
| 74 |
other data object updates can be threaded. |
| 75 |
|
| 76 |
suggested algorithm |
| 77 |
make a pool of threads |
| 78 |
parcel out the data objects to the threads |
| 79 |
|
| 80 |
-updateViewItems() is probably the slowest operation, and could benefit from threading. |
| 81 |
the loop over plotItems can easily be threaded as with Objects. |
| 82 |
|
| 83 |
There is no way to thread the view update call with the current architecture. It is possible |
| 84 |
that the refresh pixmaps stuff could be threaded, but I don't know how yet. |
| 85 |
|
| 86 |
|
| 87 |
version: cbn Nov 26'09 |
| 88 |
|