wiki:TEXT_PERFORMANCE_R1
Last modified 15 years ago Last modified on 06/18/10 16:59:53

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=TEXT_PERFORMANCE_R1, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

Text performance is still not good enough. The purpose of this task is to improve it and make Sophie usable with large text (see TEXT_PERFORMANCE_R0). At this revision, testing and profiling should indicate bottlenecks that need to be fixed.

Task requirements

  • Fix known issues after the first revision of the task:
    • Mouse clicking leads to a lot of processing currently.
    • The text that is drawn is not calculated after a synchronization with server, a saved book and after performing "undo/redo".
  • Determine bottlenecks that slow down text performance (describe them in design):
    • Manual testing should help see which regular user operations on text take a lot of time to perform.
    • Automatic testing using performance tests should pin out the most time-consuming pieces of code.
  • Suggest solutions or ways of improvement (describe them in design)
    • Provide estimate for how much time is needed for them to be done.
  • Implement feasible solutions based on the estimates given and the available time left.

Task result

  • The Design section of this wiki page
  • Source code

Implementation idea

Look at the tests and results from the first revision of this task. The number of characters used in the test might be increased for easier interpretation of results.

TEXT_PERFORMANCE_R0

How to demo

  • Show the better performance by pasting a large text and editing it.
  • Run the performance tests written and describe the results.

Design

There were several ideas what to optimize currently in the text. The first thing was that clicking around causes too much processing - this was because TextModelLogic was registered twice, SceneInteractionLogic fired the event twice for a frame, and finally because we processed both on MOUSE_PRESSED and on MOUSE_CLICKED with click count 1 ( a total of 23 = 8 times processing the text per click ). Next TextLinkProcessor needed optimizations (it used to process the whole text when called), now it hopefully processes only the changes, but when collaborating with the server and updating according to a list of changes we need to process the text after each change (hopefully the processing will be fast); also optimized applying the style a bit. Finally, ImmHotText.replace used to make some calls to getRunEnd (I don't really understand why, but anyway), which traversed through the whole text if all of it was the same style. I also tried to optimize the calls to getStyledHash (it's calculated linearly since we use a new text when typing/clicking around), but it didn't seem to produce a noticeable performance gain, while we're not able to update the hash correctly in constant time (we can update it a bit incorrectly and hope for no collisions on different texts (which is most likely for meaningful texts), but as I said, I didn't notice a gain) Also the re-flowing and layout sync could be said to be slow, but I didn't find a meaningful way to improve them.

Implementation

The implementation is in the patch attached to the ticket

Testing

Comments