Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

libtxt: Clone an ICU line break iterator for each Paragraph/WordBreaker#22594

Merged
fluttergithubbot merged 1 commit intoflutter:masterfrom
jason-simmons:txt_icu_iter_clone
Nov 20, 2020
Merged

libtxt: Clone an ICU line break iterator for each Paragraph/WordBreaker#22594
fluttergithubbot merged 1 commit intoflutter:masterfrom
jason-simmons:txt_icu_iter_clone

Conversation

@jason-simmons
Copy link
Member

The recent roll to ICU 18.1 introduced some expensive data conversion
during rule-based break iterator construction. Each instance of
Libtxt's Paragraph class creates a Minikin LineBreaker/WordBreaker
which in turn creates an ICU break iterator. The increased cost of
calling icu::BreakIterator::createLineInstance caused regressions
on several Flutter benchmarks.

Libtxt always uses the ICU default locale for break iterators. This
change calls icu::BreakIterator::createLineInstance once to create
a global instance with the default locale and then calls
icu::BreakIterator::clone to create copies for each paragraph.

Fixes flutter/flutter#70623
Fixes flutter/flutter#70700

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

// by constructing a global iterator using the default locale and then
// creating a clone for each WordBreaker instance.
std::once_flag gLibtxtBreakIteratorInitFlag;
icu::BreakIterator* gLibtxtBreakIterator = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe gLibtxtDefaultBreakIterator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

The recent roll to ICU 18.1 introduced some expensive data conversion
during rule-based break iterator construction.  Each instance of
Libtxt's Paragraph class creates a Minikin LineBreaker/WordBreaker
which in turn creates an ICU break iterator.  The increased cost of
calling icu::BreakIterator::createLineInstance caused regressions
on several Flutter benchmarks.

Libtxt always uses the ICU default locale for break iterators.  This
change calls icu::BreakIterator::createLineInstance once to create
a global instance with the default locale and then calls
icu::BreakIterator::clone to create copies for each paragraph.

Fixes flutter/flutter#70623
Fixes flutter/flutter#70700
@jason-simmons jason-simmons added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Nov 20, 2020
@fluttergithubbot fluttergithubbot merged commit 6c26217 into flutter:master Nov 20, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 24, 2020
chaselatta pushed a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in several benchmarks Regression in BM_ParagraphBuilderLongParagraphConstruct & BM_ParagraphBuilderShortParagraphConstruct

3 participants