When a diectory is updated we have to check the age of every file in it, to find the newest (QFileSystemWatcher does not give the changed file name). This can be slow on windows, e.g. a second for a few thousand images. During this time new notifications can arrive.
Previously, each notification as acted when it was received. If the rate of notification was to high, then a queue of signals would build up, and MI would appear stuck.
Now we can quickly handle the notification in _handle_notified_of_directry_change(), and defer the work with a timer. Any extra notifications can get aborbed by this, and the actuall work in _handle_directory_change() only needs to run once.
Also adds a stress test script. e.g.
simulate_live_data_stress.py -d \mi_test\live -s 0 -f 1000 -r 0.1 -v
Creates 1000 files at a rate of one every 0.1 seconds.
Testing
Not easy to add an automated test
Acceptance Criteria
See bug report for methods to trigger issue. Check that you can trigger it on main. Test that there are not long hangs with changes.
Not that this does nothing to make finding the new file faster. So with a large number of files there will still be a few seconds between a file arriving and being displayed.
coverage: 72.736% (-0.01%) from 72.75%
when pulling 810eee1364ab9143f2ba7fc31124fe4debc5dcf5 on 2204-fast-handle-changed
into f0def70b3a8c928fc9185db4ec63c6d71aa1f304 on main.
coverage: 72.69% (-0.02%) from 72.705%
when pulling 7b5f1424c12b639325a48fe1492e8c2afbb768b2 on 2204-fast-handle-changed
into 06f179e795d048342469aed93f20079de8850511 on main.
Issue
Closes #2204
Description
When a diectory is updated we have to check the age of every file in it, to find the newest (QFileSystemWatcher does not give the changed file name). This can be slow on windows, e.g. a second for a few thousand images. During this time new notifications can arrive.
Previously, each notification as acted when it was received. If the rate of notification was to high, then a queue of signals would build up, and MI would appear stuck.
Now we can quickly handle the notification in
_handle_notified_of_directry_change()
, and defer the work with a timer. Any extra notifications can get aborbed by this, and the actuall work in_handle_directory_change()
only needs to run once.Also adds a stress test script. e.g.
simulate_live_data_stress.py -d \mi_test\live -s 0 -f 1000 -r 0.1 -v
Creates 1000 files at a rate of one every 0.1 seconds.Testing
Not easy to add an automated test
Acceptance Criteria
See bug report for methods to trigger issue. Check that you can trigger it on main. Test that there are not long hangs with changes.
Not that this does nothing to make finding the new file faster. So with a large number of files there will still be a few seconds between a file arriving and being displayed.
Documentation
release notes