Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13712] Android: Experiment: The event subsystem is slow because it performs calculations even when there are no event listeners

GitHub Issuen/a
TypeStory
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-05-06T22:45:57.000+0000
Affected Version/sRelease 3.1.0
Fix Version/s2013 Sprint 09 API, 2013 Sprint 09
ComponentsAndroid
Labelsexperiment, performance
ReporterMatt Langston
AssigneeSabil Rahim
Created2013-04-29T18:48:23.000+0000
Updated2017-03-22T00:08:49.000+0000

Description

1. Design an experiment to measure the validity of the hypothesis "The event subsystem is slow because it performs calculations even when there are no event listeners". 2. Run the experiment and collect the data. 3. Analyze the data. 4. Create a short writeup presenting results and conclusions.

Comments

  1. Sabil Rahim 2013-04-29

    The hypothesis : The event subsystem is slow because it performs calculations even when there are no event listeners.

    ---------------------

    Experiment to test out the hypothesis.

    * Log the amount of time required/data creation cost to fire events through dofireEvent method in KrollObject.java. Changes can be viewed [here](https://github.com/srahim/titanium_mobile/compare/timob-13712). * Initial test was conducted with a sample app containing a window and button. [CODE](https://gist.github.com/srahim/5485115). * Results of the test [log1](http://tinyurl.com/bw73vn4), [log2](http://db.tt/HS1XyFIa), [log3](http://db.tt/9wOAu59E). * Initial Analysis of the logs shows that our system fires a lot of unnecessary events even though nobody is listening for it. But the cost associated with it (forming the actual event and its related data) seems negligible(less than 0ms in most cases). * Repeated the same test with a bit more complex app [Matt's touch test app ](http://db.tt/1wB3sDCL). * Results of the test [log1](http://db.tt/OwNh0P49), [log2](http://db.tt/QRJKmNfL), [log3](http://db.tt/izkBe4Ro), [log4](http://db.tt/USy46eav). * Logs showed the same observation as we made before. We do fire a lot of unnecessary events when there are no listeners. * Repeated the test with TableViews in KS. Results [log1](http://db.tt/I30KD5QC), [log2](http://db.tt/SZQM84h9), [log3](http://db.tt/pUzkCMig). * KS also shows the same results for scroll events. We generate a lot of scroll events when not required. ---------------------

    Conclusions

    * The excess processing of unwanted events does not result in any perceivable app performance hit. * It might be worth noting that in bigger apps where each window might contain numerous child views, this could result in the event queue getting filled up and actual events that the user is listening for could be delayed. * Even though each individual event does not cost much to process, as whole this could lead to a small delay(1 - 250ms depending on the complexity of the app) in the app. ---------------------

    Recommendations

    * We should always check if the current event being processed has any listeners and the listening proxy should be the first one to be notified instead of going through the hierarchy of child to parent. * Even though this would result in cleaning up the code flow and event queue significantly, this fix might not show any significant app performance improvement.
  2. Lee Morris 2017-03-22

    Closing ticket as fixed.

JSON Source