You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Fusuma has a somewhat high cpu usage (~9% while performing a swipe on my laptop) for a background process performing a task that isn't computationally intensive.
I was looking at the "main pipeline" to see if there are any inefficiencies in the way events are processed. There seem to be a few.
Running fusuma with the builtin profiles shows that lines 21, 22 and 24 in swipe_detector.rb take a significant amount of time
Closer insepction of the function definitions in gesture_buffer.rb shows that this is due to searching long arrays that contain all events since the beginning of the last gesture in lines 102
Since this search is performed at every event, the work that is done is quadratic in the number of events in one gesture, and touchpads emit more than 100 events per second.
But there should be no need to re-select the first 99 "update" events in line 24 when we're processing the 100th update event, since we already selected them when processing the 99th event.
It seems like the "merge" step of the pipeline also takes plenty of time, but I don't really understand the code there well enough to identify the reason.
The text was updated successfully, but these errors were encountered:
Thank you for creating the issue and the pull request. I'm really happy about it.
I'm currently unable to dedicate time immediately, so it may take some time to review and reply. 🙏
I did some more changes to the pr and I've been trying to find a good way to reliably measure the speedups. I might make some more changed in the coming days, so no need to rush. :)
Is your feature request related to a problem? Please describe.
Fusuma has a somewhat high cpu usage (~9% while performing a swipe on my laptop) for a background process performing a task that isn't computationally intensive.
I was looking at the "main pipeline" to see if there are any inefficiencies in the way events are processed. There seem to be a few.
Running fusuma with the builtin profiles shows that lines 21, 22 and 24 in
swipe_detector.rb
take a significant amount of timefusuma/lib/fusuma/plugin/detectors/swipe_detector.rb
Lines 20 to 24 in b68ab60
Closer insepction of the function definitions in
gesture_buffer.rb
shows that this is due to searching long arrays that contain all events since the beginning of the last gesture in lines 102fusuma/lib/fusuma/plugin/buffers/gesture_buffer.rb
Line 102 in b68ab60
fusuma/lib/fusuma/plugin/buffers/gesture_buffer.rb
Line 66 in b68ab60
Since this search is performed at every event, the work that is done is quadratic in the number of events in one gesture, and touchpads emit more than 100 events per second.
But there should be no need to re-select the first 99 "update" events in line 24 when we're processing the 100th update event, since we already selected them when processing the 99th event.
It seems like the "merge" step of the pipeline also takes plenty of time, but I don't really understand the code there well enough to identify the reason.
The text was updated successfully, but these errors were encountered: