WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 54912
Minimize calls to ubrk_setText()
https://bugs.webkit.org/show_bug.cgi?id=54912
Summary
Minimize calls to ubrk_setText()
Ned Holbrook
Reported
2011-02-21 15:22:40 PST
Text requiring ICU line breaking involves many calls to ubrk_setText(), or one per invocation of WebCore::isBreakable(). It should be possible to only call ubrk_setText() once per RenderText. For example, a test app drawing a paragraph of Japanese text currently requires 164 ubrk_setText() calls, but only one is strictly necessary in this case. A quick benchmark of this case showed a 3% overall speedup over 1000 iterations.
Attachments
Proposed changes.
(9.99 KB, patch)
2011-02-21 15:24 PST
,
Ned Holbrook
no flags
Details
Formatted Diff
Diff
Modified changes.
(12.34 KB, patch)
2011-02-22 11:00 PST
,
Ned Holbrook
no flags
Details
Formatted Diff
Diff
Changes per review.
(12.33 KB, patch)
2011-02-22 11:31 PST
,
Ned Holbrook
no flags
Details
Formatted Diff
Diff
Changes for Qt.
(14.01 KB, patch)
2011-02-23 10:24 PST
,
Ned Holbrook
mitz: review-
Details
Formatted Diff
Diff
Final changes.
(15.63 KB, patch)
2011-02-23 16:52 PST
,
Ned Holbrook
mitz: review-
Details
Formatted Diff
Diff
Final, final changes.
(16.63 KB, patch)
2011-02-23 17:32 PST
,
Ned Holbrook
mitz: review+
Details
Formatted Diff
Diff
This had better be it.
(16.66 KB, patch)
2011-02-23 17:40 PST
,
Ned Holbrook
mitz: review+
Details
Formatted Diff
Diff
glibc backtrace
(7.56 KB, text/plain)
2011-02-24 02:50 PST
,
Csaba Osztrogonác
no flags
Details
Reapplied changes.
(16.66 KB, patch)
2011-02-24 12:09 PST
,
Ned Holbrook
mitz: review-
Details
Formatted Diff
Diff
Changes for Qt.
(16.68 KB, patch)
2011-02-24 12:17 PST
,
Ned Holbrook
no flags
Details
Formatted Diff
Diff
Changes for Qt.
(16.70 KB, patch)
2011-02-24 13:37 PST
,
Ned Holbrook
no flags
Details
Formatted Diff
Diff
Changes for additional platforms.
(21.82 KB, patch)
2011-02-24 23:21 PST
,
Ned Holbrook
mitz: review+
Details
Formatted Diff
Diff
Show Obsolete
(10)
View All
Add attachment
proposed patch, testcase, etc.
Ned Holbrook
Comment 1
2011-02-21 15:24:35 PST
Created
attachment 83225
[details]
Proposed changes.
mitz
Comment 2
2011-02-21 16:11:41 PST
Comment on
attachment 83225
[details]
Proposed changes. View in context:
https://bugs.webkit.org/attachment.cgi?id=83225&action=review
> Source/WebCore/rendering/RenderText.h:162 > + LazyLineBreakIterator m_lineBreakIterator;
Increasing the size of RenderText by 16 bytes (I think) is going to have significant impact on memory use.
Ned Holbrook
Comment 3
2011-02-21 16:15:49 PST
I have another patch that doesn't require adding member variables to RenderText but isn't optimal w/r/t total ubrk_setText() calls.
Early Warning System Bot
Comment 4
2011-02-21 17:16:57 PST
Attachment 83225
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7944083
Ned Holbrook
Comment 5
2011-02-22 11:00:04 PST
Created
attachment 83343
[details]
Modified changes. This patch avoids adding the RenderText member variable. At least for my test case the number of ubrk_setText() calls is unchanged relative to the previous patch; I can't guarantee it is optimal in all cases, but it it certainly better than what's there now.
mitz
Comment 6
2011-02-22 11:21:07 PST
Comment on
attachment 83343
[details]
Modified changes. View in context:
https://bugs.webkit.org/attachment.cgi?id=83343&action=review
Looks good! A few coding style comments below.
> Source/WebCore/platform/text/TextBreakIterator.h:63 > + LazyLineBreakIterator(const UChar* string = 0, int length = 0)
Are you using these default parameters? If not, please remove them.
> Source/WebCore/platform/text/TextBreakIterator.h:68 > + { } > +
WebKit style is to do { }
> Source/WebCore/platform/text/TextBreakIterator.h:84 > + } > + void reset(const UChar* string, int length)
Missing newline here
> Source/WebCore/platform/text/TextBreakIteratorICU.cpp:81 > + setUpIterator(createdLineBreakIterator, > + staticLineBreakIterator, UBRK_LINE, string, length);
No reason to split this across two lines.
> Source/WebCore/platform/text/TextBreakIteratorICU.cpp:94 > + {
Leading whitespace
Ned Holbrook
Comment 7
2011-02-22 11:30:38 PST
(In reply to
comment #6
)
> > Source/WebCore/platform/text/TextBreakIterator.h:63 > > + LazyLineBreakIterator(const UChar* string = 0, int length = 0) > > Are you using these default parameters? If not, please remove them.
I am: the LineBreakIteratorInfo std::pair invokes the default constructor.
Ned Holbrook
Comment 8
2011-02-22 11:31:04 PST
Created
attachment 83351
[details]
Changes per review.
mitz
Comment 9
2011-02-22 11:52:51 PST
Comment on
attachment 83351
[details]
Changes per review. Ok. Let’s see what the EWS bots think. Not sure how this affects non-ICU builds.
mitz
Comment 10
2011-02-23 08:45:43 PST
So there are no EWS results yet, but the red Qt box next to the first patch suggests that this will break the Qt build, which doesn't use ICU.
Ned Holbrook
Comment 11
2011-02-23 10:24:14 PST
Created
attachment 83499
[details]
Changes for Qt. Let's see if this fixes the Qt build.
Ned Holbrook
Comment 12
2011-02-23 11:11:23 PST
Comment on
attachment 83499
[details]
Changes for Qt. I guess I have to set review? to run this by the build bots.
Darin Adler
Comment 13
2011-02-23 11:25:13 PST
Comment on
attachment 83499
[details]
Changes for Qt. Clearing review flag now that this is in the EWS queue. The EWS bots will still build this since it had review? at one point.
Ned Holbrook
Comment 14
2011-02-23 11:26:19 PST
(In reply to
comment #13
)
> Clearing review flag now that this is in the EWS queue. The EWS bots will still build this since it had review? at one point.
Great, thanks!
mitz
Comment 15
2011-02-23 16:36:24 PST
Comment on
attachment 83499
[details]
Changes for Qt. This seems to build everywhere (I trust that Ned has built on Mac OS X). Ned, would you like to change the review flag to '?' again?
mitz
Comment 16
2011-02-23 16:39:10 PST
Comment on
attachment 83499
[details]
Changes for Qt. Whoops, no change log!
Ned Holbrook
Comment 17
2011-02-23 16:41:21 PST
(In reply to
comment #16
)
> (From update of
attachment 83499
[details]
) > Whoops, no change log!
Whoops indeed! Coming right up…
Ned Holbrook
Comment 18
2011-02-23 16:52:14 PST
Created
attachment 83579
[details]
Final changes.
mitz
Comment 19
2011-02-23 16:59:11 PST
Comment on
attachment 83579
[details]
Final changes. View in context:
https://bugs.webkit.org/attachment.cgi?id=83579&action=review
> Source/WebCore/ChangeLog:34 > +2011-02-23 Ned Holbrook <
nholbrook@apple.com
> > + > + Reviewed by NOBODY (OOPS!). > + > + Minimize calls to ubrk_setText() > +
https://bugs.webkit.org/show_bug.cgi?id=54912
> + <
rdar://problem/9032774
> > + > + No new tests. (OOPS!) > + > + * platform/text/TextBreakIterator.h: > + (WebCore::LazyLineBreakIterator::LazyLineBreakIterator): > + (WebCore::LazyLineBreakIterator::~LazyLineBreakIterator): > + (WebCore::LazyLineBreakIterator::string): > + (WebCore::LazyLineBreakIterator::length): > + (WebCore::LazyLineBreakIterator::get): > + (WebCore::LazyLineBreakIterator::reset): > + * platform/text/TextBreakIteratorICU.cpp: > + (WebCore::acquireLineBreakIterator): > + (WebCore::releaseLineBreakIterator): > + * platform/text/qt/TextBreakIteratorQt.cpp: > + (WebCore::acquireLineBreakIterator): > + (WebCore::releaseLineBreakIterator): > + * rendering/RenderBlock.h: > + * rendering/RenderBlockLineLayout.cpp: > + (WebCore::RenderBlock::layoutInlineChildren): > + (WebCore::RenderBlock::findNextLineBreak): > + * rendering/RenderText.cpp: > + (WebCore::RenderText::computePreferredLogicalWidths): > + * rendering/break_lines.cpp: > + (WebCore::nextBreakablePosition): > + * rendering/break_lines.h: > + (WebCore::isBreakable): > +
Sorry, Ned, this is not how it works (even if some contributors sometimes get away with it) :-(. For a change like this, at the very least you should give an overview of the change before the file and function listing. This would also be a great place to say by how much the change reduces calls to ubrk_setText(). Alternatively, or in addition to this, you should fill out the function listing with comments about the changes in each function, where it makes sense. Finally, you should remove the “No new tests. (OOPS!)” line. The change log can’t be committed with that line, and instead you can comment that there are no new tests because this is only a performance optimization. But just removing the line is also fine, in my opinion. Thanks!
Ned Holbrook
Comment 20
2011-02-23 17:06:14 PST
Sorry, I'm new here. ;-) Thanks for bearing with me.
Ned Holbrook
Comment 21
2011-02-23 17:32:12 PST
Created
attachment 83590
[details]
Final, final changes.
WebKit Review Bot
Comment 22
2011-02-23 17:35:25 PST
Attachment 83590
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/ChangeLog:9: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:10: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:11: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:12: Line contains tab character. [whitespace/tab] [5] Source/WebCore/ChangeLog:13: Line contains tab character. [whitespace/tab] [5] Total errors found: 5 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
Adele Peterson
Comment 23
2011-02-23 17:36:07 PST
oh no! tabs!
Ned Holbrook
Comment 24
2011-02-23 17:37:24 PST
(In reply to
comment #23
)
> oh no! tabs!
You would not believe the profanities I just uttered. :-P
mitz
Comment 25
2011-02-23 17:38:32 PST
Comment on
attachment 83590
[details]
Final, final changes. I’ll fix the tabs in the change log when committing (the pre-commit hook won’t allow tabs to be checked in).
Ned Holbrook
Comment 26
2011-02-23 17:40:13 PST
Created
attachment 83591
[details]
This had better be it. The gazillionth time's the charm, right?
mitz
Comment 27
2011-02-23 17:45:34 PST
Committed
r79510
. <
http://trac.webkit.org/projects/webkit/changeset/79510
>
Csaba Osztrogonác
Comment 28
2011-02-23 23:05:45 PST
Reopen, because it was rolled out
http://trac.webkit.org/changeset/79518
. It made ~200 tests crash on Qt bot. I'm going to attach a crash log to help finding whar happened.
Ned Holbrook
Comment 29
2011-02-23 23:08:30 PST
(In reply to
comment #28
)
> Reopen, because it was rolled out
http://trac.webkit.org/changeset/79518
. > > It made ~200 tests crash on Qt bot. I'm going to attach a crash log to help finding whar happened.
Thanks, I was hoping my untested code worked, but I guess this puts the lie to that. Is there a quicker way to test my next attempt short of waiting for tests to fail again?
Csaba Osztrogonác
Comment 30
2011-02-23 23:23:49 PST
Longer way, but you have to install once the QtWebKit builder and tester VM:
http://webkit.sed.hu/blog/20101028/qtwebkit-builder-and-tester-virtual-machine
Shorter way: you upload patch to bugzilla or gist or ... and ping me on #webkit. My nick is ossy, and I can run a quick test between ~10:00-20:00 (CET).
Ned Holbrook
Comment 31
2011-02-24 00:02:39 PST
(In reply to
comment #30
) Thanks. Any further patches from me are going to have to wait until tomorrow, so I'll look for a crash log then and see what needs to be done.
Csaba Osztrogonác
Comment 32
2011-02-24 02:50:36 PST
Created
attachment 83627
[details]
glibc backtrace $ gdb WebKitBuild/Debug/bin/DumpRenderTree (gdb) run css1/text_properties/text_transform.html *** glibc detected *** /home/oszi/WebKit/WebKitBuild/Debug/bin/DumpRenderTree: realloc(): invalid pointer: 0xf77b4120 *** ======= Backtrace: ========= ... <attached> ... Program received signal SIGABRT, Aborted. (gdb) bt ... <absolutely useless backtrace :/> ...
Balazs Kelemen
Comment 33
2011-02-24 08:17:11 PST
Hopefully the qt bug has been fixed by
http://trac.webkit.org/changeset/79567
so a rebased patch won't cause regression.
Ned Holbrook
Comment 34
2011-02-24 09:18:49 PST
(In reply to
comment #33
)
> Hopefully the qt bug has been fixed by
http://trac.webkit.org/changeset/79567
so > a rebased patch won't cause regression.
I'll rebase the patch and we can try this again.
Ned Holbrook
Comment 35
2011-02-24 12:09:16 PST
Created
attachment 83694
[details]
Reapplied changes.
Ned Holbrook
Comment 36
2011-02-24 12:12:38 PST
Wait, the TextBreakIteratorQt.cpp needs further modification in order to compile with
r79567
.
mitz
Comment 37
2011-02-24 12:13:06 PST
Comment on
attachment 83694
[details]
Reapplied changes. Waiting
Ned Holbrook
Comment 38
2011-02-24 12:17:31 PST
Created
attachment 83695
[details]
Changes for Qt.
Early Warning System Bot
Comment 39
2011-02-24 13:15:25 PST
Attachment 83695
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7982552
Ned Holbrook
Comment 40
2011-02-24 13:37:48 PST
Created
attachment 83709
[details]
Changes for Qt. Fix copy-paste error in TextBreakIteratorQt.cpp.
Patrick R. Gansterer
Comment 41
2011-02-24 15:04:04 PST
Can you please also add changes to TextBreakIteratorWinCE.cpp? The last change broke WinCE build bot. I wanted to add the needed changes as patch here, but didn't found the time to create it today. :-(
Early Warning System Bot
Comment 42
2011-02-24 15:22:08 PST
Attachment 83709
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/7980608
Ned Holbrook
Comment 43
2011-02-24 15:35:21 PST
(In reply to
comment #42
)
>
Attachment 83709
[details]
did not build on qt: > Build output:
http://queues.webkit.org/results/7980608
The build output makes no sense to me: the line numbers don't correspond to my copy of the source, plus it's complaining about "no matching function for call to ‘WebCore::TextBreakIterator::TextBreakIterator(QTextBoundaryFinder::BoundaryType, QString)’" which I'm pretty certain is on line 46. Can someone help me figure this out?
Ned Holbrook
Comment 44
2011-02-24 23:21:01 PST
Created
attachment 83775
[details]
Changes for additional platforms. Let's see how this one goes, build-wise.
mitz
Comment 45
2011-02-25 01:15:02 PST
Comment on
attachment 83775
[details]
Changes for additional platforms. Setting r? to get builders’ attention.
Csaba Osztrogonác
Comment 46
2011-02-25 01:46:25 PST
(In reply to
comment #45
)
> (From update of
attachment 83775
[details]
) > Setting r? to get builders’ attention.
It works on Qt now, and all tests pass. Thanks for fixining.
Early Warning System Bot
Comment 47
2011-02-25 04:02:53 PST
Attachment 83775
[details]
did not build on qt: Build output:
http://queues.webkit.org/results/8043172
Csaba Osztrogonác
Comment 48
2011-02-25 04:10:47 PST
(In reply to
comment #47
)
>
Attachment 83775
[details]
did not build on qt: > Build output:
http://queues.webkit.org/results/8043172
OMG. :-S Qt EWS is stucked on
r78989
, but the ToT is
r79669
now. Eric, have you got any idea how is it possible? Otherwise the patch works on ToT with Qt, as I said before.
Eric Seidel (no email)
Comment 49
2011-02-25 04:12:58 PST
(In reply to
comment #48
)
> (In reply to
comment #47
) > >
Attachment 83775
[details]
[details] did not build on qt: > > Build output:
http://queues.webkit.org/results/8043172
> > OMG. :-S Qt EWS is stucked on
r78989
, but the ToT is
r79669
now. > Eric, have you got any idea how is it possible? > > Otherwise the patch works on ToT with Qt, as I said before.
I suspect the git checkout on that bot got confused.
Csaba Osztrogonác
Comment 50
2011-02-25 04:14:57 PST
(In reply to
comment #49
)
> I suspect the git checkout on that bot got confused.
I got it, update-webkit is failing now. I'm going to fix it. Is it possible to make EWS not trying build if update failed?
Eric Seidel (no email)
Comment 51
2011-02-25 04:19:40 PST
(In reply to
comment #50
)
> (In reply to
comment #49
) > > I suspect the git checkout on that bot got confused. > I got it, update-webkit is failing now. I'm going to fix it. > Is it possible to make EWS not trying build if update failed?
Bug 49395
. A lot like
bug 46636
.
Darin Adler
Comment 52
2011-02-25 10:33:55 PST
Comment on
attachment 83775
[details]
Changes for additional platforms. View in context:
https://bugs.webkit.org/attachment.cgi?id=83775&action=review
Some comments about slight improvements. These could wait until afterward, though. I do not mean to reverse Mitz’s review+ with these.
> Source/WebCore/platform/text/TextBreakIterator.h:61 > +class LazyLineBreakIterator {
Should probably mark this non-copyable with the macro.
> Source/WebCore/platform/text/TextBreakIterator.h:79 > + TextBreakIterator* get()
I’d prefer a noun name for this rather than a verb. Maybe iterator().
> Source/WebCore/platform/text/TextBreakIteratorICU.cpp:86 > + bool createdNewLineBreakIterator = false; > + setUpIterator(createdNewLineBreakIterator, lineBreakIterator, UBRK_LINE, string, length);
I think the local variable should have a name that makes it clear it’s not the same as the global. And why.
mitz
Comment 53
2011-02-25 10:37:13 PST
I committed <
http://trac.webkit.org/projects/webkit/changeset/79694
>.
Xianzhu Wang
Comment 54
2011-03-28 19:36:51 PDT
Thanks
nholbrook@apple.com
for fixing this. Just FYI, I also filed a bug similar to this one:
https://bugs.webkit.org/show_bug.cgi?id=52715
Xianzhu Wang
Comment 55
2011-03-28 19:47:38 PDT
***
Bug 52715
has been marked as a duplicate of this bug. ***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug