Bug 89666 - Writer long paragraphs very slow to format with HbLayoutEngine
Summary: Writer long paragraphs very slow to format with HbLayoutEngine
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
4.3.0.4 release
Hardware: Other All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:5.0.0 target:4.3.7 target:4.4.2
Keywords: perf
Depends on:
Blocks:
 
Reported: 2015-02-25 22:17 UTC by Michael Stahl (allotropia)
Modified: 2016-09-16 09:18 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Stahl (allotropia) 2015-02-25 22:17:30 UTC
4.3 lifts the 64k paragraph limit;
unfortunately the long paragraphs take a long time to format
(at least on Linux, with the harfbuzz backend).
Comment 1 Michael Stahl (allotropia) 2015-02-25 22:30:27 UTC
callgrind says >95% of CPU time goes into vcl::ScriptRun::next(),
called from HbLayoutEngine::Layout().

there is already a patch by mjayfrancis in gerrit to
substantially accelerate ScriptRun::next() but it was abandoned:

https://gerrit.libreoffice.org/#/c/11775/

i've done some callgrind profiling and have 3 potential fixes of my own,
one of which is an obvious 50% win, the second is a complete waste
of 1.5 days since at last i learned writer was already doing
something very similar itself, and the third almost eliminates the
other 50% at the cost of parentheses script correctness.
Comment 2 Commit Notification 2015-02-25 23:13:11 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7fde44c85620f8079bc4863fe3f7ea1f69a0f88c

tdf#89666: vcl: speed up HbLayoutEngine line layout for large paragraphs

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Commit Notification 2015-02-27 12:03:34 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=623f16d7a47020600e2b4ba03aa6a617545b0d93&h=libreoffice-4-3

tdf#89666: vcl: speed up HbLayoutEngine line layout for large paragraphs

It will be available in 4.3.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 4 Commit Notification 2015-02-27 12:03:41 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8a58579a35bb275c985ff0fd412c92f10cd8a085&h=libreoffice-4-4

tdf#89666: vcl: speed up HbLayoutEngine line layout for large paragraphs

It will be available in 4.4.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2015-03-28 15:35:28 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1efe5fe38031f7bc23150c35e4c68940621a1d5b

tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2015-03-29 01:52:47 UTC
Norbert Thiebaud committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3c6fd5a59b08cec8705a31d17a60204acf6b7173

Revert "tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo"

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2015-03-31 18:24:59 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b9782a2b59428e1bc398b5f3a895785a072c93b6

tdf#89666: vcl: speed up HbLayoutEngine with cache in SwTxtFormatInfo

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Elie Roux 2015-06-14 12:44:35 UTC
See also https://bugs.documentfoundation.org/show_bug.cgi?id=92064 (the attached example might be relevant to test)
Comment 9 Robinson Tryon (qubit) 2015-12-10 11:01:54 UTC Comment hidden (obsolete)
Comment 10 Xisco Faulí 2016-09-15 22:25:59 UTC
Hello,
Is this bug fixed?
If so, could you please close it as RESOLVED FIXED?
Comment 11 Michael Stahl (allotropia) 2016-09-16 09:18:08 UTC
guess this can be called fixed now

there was some further commit to optimize ScriptRun class:

commit b9880e49e5fbae377eca82e60b88cbbdca8bd5d2
Author:     Noel Grandin <noel@peralex.com>
AuthorDate: Wed Mar 11 13:55:51 2015 +0200

    Speed up ScriptRun::getPairIndex

    Noted as a hot spot in the callgrind of
    test-files/loperf/091_fdo#39372.odt
    
    The idea for the lookup tables is credited to mjayfrancis.
    
    This takes it from 1.8 billion instructions to 1.1 billion instructions.
    
    This change has been submitted upstream (along with other changes
    to these source files that have not yet been pushed there)
    in ICU ticket:
        http://bugs.icu-project.org/trac/ticket/11577