Bug 105426 - Performance regression in hunspell 1.4.0 vs 1.3.4 vs 1.3.3
Summary: Performance regression in hunspell 1.4.0 vs 1.3.4 vs 1.3.3
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Linguistic (show other bugs)
Version:
(earliest affected)
5.2.0.4 release
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:5.4.0 target:5.3.1
Keywords: bibisected, bisected, perf, regression
: 101987 106173 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-18 18:42 UTC by Telesto
Modified: 2017-07-11 09:53 UTC (History)
6 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 Telesto 2017-01-18 18:42:35 UTC
Description:
The right click menu containing spellcheck suggestions is opening quite slow

Steps to Reproduce:
1.Open a Writer document
2.Type a misspelled word. Like "Hollo"
3. Right click it, for the spelling suggestions


Actual Results:  
There is quite a delay before the menu opens compared to LibO5.0.0.5

Expected Results:
Should open instantly like in LibO5.0.0.5


Reproducible: Always

User Profile Reset: No

Additional Info:
Found in
Version: 5.4.0.0.alpha0+
Build ID: 99eed82939999d9a9689788a4134dd05d5c20c5a
CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-01-14_23:37:40
Locale: nl-NL (nl_NL); Calc: CL

and in
Version: 5.2.0.4

but not in
Version: 5.0.0.5
Build ID: 1b1a90865e348b492231e1c451437d7a15bb262b
Locale: en-US (nl_NL)


User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Comment 1 Telesto 2017-01-18 18:49:53 UTC
Setting to new:
[19:04] <bearon> Telesto: you're right, it's noticeably slower now
Comment 2 Aron Budea 2017-01-18 19:05:57 UTC Comment hidden (bibisection)
Comment 3 Aron Budea 2017-01-18 19:08:36 UTC
So this got slower in two steps (seemingly, I've yet to bibisect the second one). This is the first one, hunspell update to 1.3.4:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=ce9e8630b4df2f515bd77d77b3450890b87de30a
"bump hunspell to 1.3.4"
Comment 4 Xisco Faulí 2017-01-18 20:14:12 UTC
Current hunspell version in LibreOffice is 1.5.4 and the latest hunspell version is 1.6.0 which fixes some performance problems. Perhaps, upgrading to 1.6.0 fixes this problem...

@Caolan, any thought on this?
Comment 5 Aron Budea 2017-01-18 20:34:50 UTC Comment hidden (bibisection)
Comment 6 Aron Budea 2017-01-18 20:36:03 UTC
Sure enough, this is the source of the second slowdown:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=1098921996c81a4d6dc917bbc16d5f834ebf6728
"test pre 1.4.0 hunspell"
Comment 7 MM 2017-01-20 09:39:52 UTC
Seems a known issue: https://github.com/hunspell/hunspell/issues/406
Comment 8 Caolán McNamara 2017-01-23 21:40:11 UTC
I've added a few more things to upstream hunspell which give us better cachegrind figures as well, so just need to integrate the latest hunspell to see if that makes a difference
Comment 9 Commit Notification 2017-01-24 09:36:32 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

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

Related: tdf#105426 upgrade to hunspell-1.6.0

It will be available in 5.4.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 10 Telesto 2017-01-31 19:32:31 UTC
Quite some progress, its workable now. With LibO 5.3.0.2 I notice a delay of 3-4 seconds with CPU spikes of 25%. Now it's acceptable with 1-2 sec delay(a accompanied with CPU spikes 10-12%). However not like LibO5.0.0.5 (instantly opening with 1-2% CPU)

Version: 5.4.0.0.alpha0+
Build ID: 2670ca3fc597decae78499d1397539668eb84e5e
CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-01-31_05:32:46
Locale: nl-NL (nl_NL); Calc: CL
Comment 11 MM 2017-02-04 20:56:36 UTC
(In reply to Telesto from comment #10)
> However not like LibO5.0.0.5 (instantly opening with 1-2% CPU)

Well, if I read the report on the hunspell site correctly, they can't/won't fix it  right now. It would take a lot of time (too much) to rewrite. Maybe it's getting better with hunspell v2. So hope for the best.
Comment 12 Caolán McNamara 2017-02-10 17:24:29 UTC
to be sure here, the language for spell checking is Dutch right ?
Comment 13 Caolán McNamara 2017-02-12 17:52:06 UTC
*cough*, we're building hunspell unoptimized in the release builds, hence the main part of the problem
Comment 14 Commit Notification 2017-02-12 21:13:45 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

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

Resolves: tdf#105426 helpful to actually let the compiler optimize hunspell

It will be available in 5.4.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 15 Caolán McNamara 2017-02-12 21:29:35 UTC
While there are some performance drops in hunspell itself from 1.3.3 to < 1.6.0, the major issue is we lost passing compiler optimization flags to hunspell. Testing 1.3.3 against 1.6.0 with optimization flags restored I get 230ms (1.3.3) vs 215ms (1.6.0) for attempting to fetch suggestions of Holloasdasdasdasd with nl_NL dictionary as opposed to > 1100ms with 1.6.0 without the optimization flags.

backport to 5-3 in gerrit
Comment 16 Commit Notification 2017-02-13 08:23:17 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=53b186d85894c2c41afc025bda459db5cc6ef452&h=libreoffice-5-3

Resolves: tdf#105426 upgrade to hunspell-1.6.0

It will be available in 5.3.1.

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 17 Caolán McNamara 2017-02-24 11:46:40 UTC
*** Bug 106173 has been marked as a duplicate of this bug. ***
Comment 18 Adolfo Jayme 2017-03-26 01:13:52 UTC
*** Bug 101987 has been marked as a duplicate of this bug. ***