Ticket #2495 (closed bug: obsolete)
TEXT_PERFORMANCE_R2
Reported by: | diana | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | uncategorized | Version: | 2.0 |
Keywords: | Cc: | ||
Category: | unknown | Effort: | |
Importance: | Ticket_group: | text,performance | |
Estimated Number of Hours: | 0 | Add Hours to Ticket: | 0 |
Billable?: | yes | Total Hours: | 0 |
Analysis_owners: | diana | Design_owners: | diana |
Imp._owners: | diana | Test_owners: | |
Analysis_reviewers: | pap | Changelog: | Changelog |
Design_reviewers: | pap | Imp._reviewers: | todor, pap |
Test_reviewers: | Analysis_score: | 3 | |
Design_score: | 4 | Imp._score: | 3.5 |
Test_score: | 0 |
Description
There are some slow operations in the current text. The performance can be improved a little bit.
Attachments
Change History
comment:2 Changed 15 years ago by diana
- Status changed from s1b_analysis_finished to s2a_design_started
In order to provide a better performance the following changes were made:
- In ImmHotText:
- in replace method : getRunEnd() function is no longer used: the equals method of two
HotStyleDef objects is not fast enough to be used. In order to use the HotStyleDef.derive method as
rarely as possible two last values (of the last unit stule and last derived unit style) is used and if the
Hash of the lates used unit style value is equal to the current one - the last derived style is used.
- in applyStyle: the latest described change in the replace function is used here.
- a new function private ImmHotText replaceUnits(ImmTextInterval interval, ImmHotText text) is made -
it is used in the ImmTextUtils - this is faster replace thatuses ImmList.set(i) which is faster than removing and then adding
units to the list. The interval's length should be equal to the text's size.
- In ImmTextUtils:
- a new function is added: ImmText fastReplaceInterval(ImmTextInterval interval,
ImmText oldText, ImmText replacedText) - Method for fast(faster than using the replace function of the text) replacing
interval of a text with another text. The replacing text should be the same length as the interval. The styles of the new
text are not derived - they are the same as using concat function.
- In TextUtils:getPreffix:if the to index is the end of the text - the text is returned;
the same with the getSuffix method.
- In all processors(Caret, Selection, Underlining, Search, TextLink): the apply change method no longer returns the whole text
interval but a smaller one - the really damaged one.This is needed in order to make a smarter apply change in the text link processor
(and faster) and the processing of the whole text is no longer needed.
- In HotStyleDef:
- make a private Hash hashCode - keeps the value from the getHash function.
- In TextLinkProcessor: *in apply change: process only the damaged interval text, not the whole one;use the ImmTextUtils:fastReplaceInterval function. *in process: apply the style of the given link to the whole interval , not only to one text unit.
Really useful notes:
The changes are made using some the profiler test and some tests (not included because meddle won't like them).
The following changes were tried but made the text slower:
- in ImmHotText use Hashing tree instead of immtreelist in order to make the getHash faster(applyStyles and remove were 30 times slower, getStyledHash - 10 times faster).
- in text processors, all but text link processor,in apply change - process only the damaged interval(a bit slower).
- in text processors, all but text link processor, in set options - again not process the whole text(a bit slower).
- in HotAreaLayout:create try to use a map of (newArea, baseY, lineHeight->List<HorizontalInterval>) in order to use
List<HorizontalInterval> intervals = LayoutUtils.splitToIntervals(newArea, baseY, lineHeight); less(a bit slower...or a little bit more).
Things to be tried and tested(maybe will make the text faster):
- Use buffered image in the drawing method of the text-if nothing has changed in the text layout - the stored image is used.
- Make TextLinkProcessor:setOptions smarter-much more difficult task.
- See if the bound controls can affect the text processing only once although they submit twice.
- The chaining is still very slow...when inserting in the beginning of a chained text all the areas are layouted again... can parts of them be used?
NOTE:the patch below is with the not integrated yet patch from the
task for the video performance(ticket 2494).So some of the changes
are described in the video performance ticket.
comment:3 Changed 15 years ago by diana
- Status changed from s2a_design_started to s3b_implementation_finished
Changed 15 years ago by pap
- Attachment 2495-reduced.patch added
removed the #2494 code from the patch
comment:4 Changed 15 years ago by pap
- Status changed from s3b_implementation_finished to s3c_implementation_ok
- Analysis_reviewers set to pap
- Analysis_score changed from 0 to 3
- Imp._reviewers set to todor, pap
- Design_score changed from 0 to 4
- Design_reviewers set to pap
- Imp._score changed from 0 to 3.5
- Committed in [9260].
- Commented out code left but it may really be needed someday.
- Maybe the replaceUnits method should be named better and put in the interface? This way it won't be so badly reflection-ed.
- The really useful notes really seem useful. Where should I link them so that they don't get lost?
comment:5 Changed 15 years ago by diana
- The replaceUnits function should not be in the interface - this implementation is needed only because we use ImmTreeList in the ImmHotText and the replace function is slow because of the fact. This is some kind of a "bug" or maybe a drawback of using this structure. In another implementation of the ImmText maybe a better structure will be used and there will be no need of such a method. Thats's why I put this function there and in the ImmTextUtils I assume(and hope) that the implementation is only for the ImmHotText. But the reflection is not cool...I don't like it either as you may know :)...if any better ideas occur to you- I can fix it.
- The link may be made if another TEXT_PERFORMANCE ticket is made later.