Bug 38028 - Libo 3.4 release: Calc document EDITING slow (~100% CPU) compared to 3.3.2 (FILESAVE already slow in 3.3.2))
Summary: Libo 3.4 release: Calc document EDITING slow (~100% CPU) compared to 3.3.2 (F...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.4.0 release
Hardware: x86 (IA32) Windows (All)
: highest major
Assignee: Kohei Yoshida
URL:
Whiteboard: target:3.5 target:3.4.2
Keywords: perf
Depends on:
Blocks:
 
Reported: 2011-06-07 03:03 UTC by mondane.woodworker
Modified: 2015-12-15 11:40 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet which makes LibO 3.4 release take ~100% CPU (183.27 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-06-07 03:03 UTC, mondane.woodworker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mondane.woodworker 2011-06-07 03:03:35 UTC
Created attachment 47655 [details]
Spreadsheet which makes LibO 3.4 release take ~100% CPU

I have a Calc document which runs fine in 3.3.2 (only saving is very slow). In 3.4 release though, the document makes Calc use 100% CPU so I can't work with it.

Had to revert to 3.3.2 just for this sheet.

I attached the sheet to this bugreport.

Summary:

- sheet makes 3.4 release Calc take ~100% CPU

Issue already in 3.3.2:
- loading takes a while (every sheet is calculated quickly)
- changing data on sheet 'Invoer' and saving takes a while (several seconds).

example changing data: 
- go to 'Invoer' line 916 and fill in this value in D916: '11:00' (without single quotes). 
- save the file, this takes at least longer than one wants to wait


Used 3.3.2:
-----------
LibreOffice 3.3.2 
OOO330m19 (Build:202)
tag libreoffice-3.3.2.2


Used 3.4:
---------
LibreOffice 3.4.0 
OOO340m1 (Build:12)
Comment 1 Andras Timar 2011-06-09 01:56:50 UTC
Confirmed, saving is quite slow on 3.3.2, but on 3.4.0 it is even slower. The progress bar is at 0% for most of the time, then one block appears, then after several long seconds the save completes within a few seconds. Kohei, can you please check this?
Comment 2 mondane.woodworker 2011-06-09 02:27:42 UTC
(In reply to comment #1)
> Confirmed, saving is quite slow on 3.3.2, but on 3.4.0 it is even slower. The
> progress bar is at 0% for most of the time, then one block appears, then after
> several long seconds the save completes within a few seconds. Kohei, can you
> please check this?

Thanks for confirming the slow saving, but did you also noticed the increase in CPU usage just by having this document opened in 3.4? That's the real issue witholding me from upgrading to 3.4.
Comment 3 Kohei Yoshida 2011-06-09 06:30:36 UTC
I'll take a look.
Comment 4 Rainer Bielefeld Retired 2011-06-10 02:58:18 UTC
RC2 is bit by bit identical with release version, so separate items in the version picker are useless. Changes have been discussed with Michael Meeks.
Comment 5 Kohei Yoshida 2011-06-14 13:20:54 UTC
There may be several bottlenecks in this, but for one, ScTable::SetOptimalHeight() got a low slower, and ScDocument::IdleCalcTextWidth() got slower as well.  But those don't account for all the slowness that has resulted in 3.4.
Comment 6 Kohei Yoshida 2011-06-14 14:15:33 UTC
The document contains tons of matrices in the formulas, and they get calculated when the sheet becomes visible (to display correct results in the cells).  The new matrix calculation code may be being a bottleneck there...

ScTabView::InterpretVisible() takes several seconds to complete after the document gets loaded, and it makes numerous indirect calls to ScInterpreter::ScEqual()...
Comment 7 Kohei Yoshida 2011-06-15 06:36:35 UTC
Ok. I'm now pretty confident that this has been caused by a single bottleneck, the creation of ScMatrix instances.  I've refactored this class to support different storage backends (filled and sparse), and that somehow degraded its instantiation performance.  All of these methods I've listed are affected by that either directly or indirectly.

The fix must be done in the mdds library itself, which is my next step.
Comment 8 Markus Mohrhard 2011-07-01 15:50:11 UTC
similar bug(seems to be related): https://bugs.freedesktop.org/show_bug.cgi?id=38721
Comment 9 Kohei Yoshida 2011-07-11 21:18:34 UTC
Ok. I think I've reduced the load time down to the 3.3 level.  I'll keep it open until I update the mdds to the latest (not yet released) version which contains the performance enhancement.  I'd like to take care of Bug 38721 as well (if I can).
Comment 10 mondane.woodworker 2011-07-12 01:30:11 UTC
(In reply to comment #9)
> Ok. I think I've reduced the load time down to the 3.3 level.  I'll keep it
> open until I update the mdds to the latest (not yet released) version which
> contains the performance enhancement.  I'd like to take care of Bug 38721 as
> well (if I can).

When those levels are met, will you make a new ticket to even further improve the loading (and saving) times for sheets with matrix calculations?
Comment 11 Kohei Yoshida 2011-07-12 04:45:48 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > Ok. I think I've reduced the load time down to the 3.3 level.  I'll keep it
> > open until I update the mdds to the latest (not yet released) version which
> > contains the performance enhancement.  I'd like to take care of Bug 38721 as
> > well (if I can).
> 
> When those levels are met, will you make a new ticket to even further improve
> the loading (and saving) times for sheets with matrix calculations?

Sure.  I'm generally interested in performance enhancement with the matrix code.
Comment 12 Kohei Yoshida 2011-07-12 04:52:48 UTC
(In reply to comment #11)

> > When those levels are met, will you make a new ticket to even further improve
> > the loading (and saving) times for sheets with matrix calculations?
> 
> Sure.  I'm generally interested in performance enhancement with the matrix
> code.

But so far the instantiation performance is pretty much as fast as it could be.  So, I'm not opening a new bug.  But if there are existing bug reports in this area I'm interested.
Comment 13 Kohei Yoshida 2011-07-13 09:26:48 UTC
The saving time on my machine is

18.5819 sec (3.3 build)
32.1564 sec (original 3.4 build)
11.4205 sec (3.4 build after the mdds matrix perf enhancement)

So, the saving time is actually now shorter than 3.3. :-)
Comment 14 Kohei Yoshida 2011-07-13 09:30:20 UTC
(In reply to comment #10)

> When those levels are met, will you make a new ticket to even further improve
> the loading (and saving) times for sheets with matrix calculations?

Ah.  Now I got your question.  The original description indeed includes slow loading of the document.  But since that's not a regression from 3.3, it should be filed as a separate perf enhancement bug, I think.

Also, when I said "load time" in Comment 9 I meant "save time" or run-time speed (especially during re-calc and sheet switching).  The load performance is still comparable to 3.3's (not slower, but not necessarily faster).
Comment 15 Kohei Yoshida 2011-07-13 09:39:02 UTC
(In reply to comment #14)

> The load performance is
> still comparable to 3.3's (not slower, but not necessarily faster).

For the record, load time performance comparison:

6.57746 sec (3.3 build)
2.46167 sec (original 3.4 build)
2.46522 sec (3.4 build with mdds enhancement)

So, the load time is in fact faster with 3.4 even without the mdds enhancement.  My mdds enhancement seems to make little difference there.
Comment 16 Kohei Yoshida 2011-07-13 09:55:37 UTC
Nevermind my 3.3 build was a debug build.  Here is the real number:

Save
6.02166 sec (3.3 build)
32.1564 sec (original 3.4 build)
11.4205 sec (3.4 build with mdds enhancement)

Load
2.0081 sec (3.3 build)
2.46167 sec (original 3.4 build)
2.46522 sec (3.4 build with mdds enhancement)

So, 3.4 is still a tad slower than 3.3 even with my enhancement.  But I hope it's acceptable.
Comment 17 mondane.woodworker 2011-07-13 23:57:26 UTC
(In reply to comment #16)
> Nevermind my 3.3 build was a debug build.  Here is the real number:
> 
> Save
> 6.02166 sec (3.3 build)
> 32.1564 sec (original 3.4 build)
> 11.4205 sec (3.4 build with mdds enhancement)
> 
> Load
> 2.0081 sec (3.3 build)
> 2.46167 sec (original 3.4 build)
> 2.46522 sec (3.4 build with mdds enhancement)
> 
> So, 3.4 is still a tad slower than 3.3 even with my enhancement.  But I hope
> it's acceptable.

I'll decide if I file a enhancement ticket when I got the chance myself to test the mdds enhancement. Is it certain those changes will be in 3.4.2 ?
Comment 18 Kohei Yoshida 2011-07-14 05:29:49 UTC
(In reply to comment #17)

> I'll decide if I file a enhancement ticket when I got the chance myself to test
> the mdds enhancement. Is it certain those changes will be in 3.4.2 ?

It's not for certain yet.  The change is still in review for 3.4.2.  But it is certain that it will be in 3.4.3 when it gets out.
Comment 19 Markus Mohrhard 2011-07-22 11:23:43 UTC
will be in 3.4.2
Comment 20 Robinson Tryon (qubit) 2015-12-15 11:40:48 UTC
Migrating Whiteboard tags to Keywords: (perf)
[NinjaEdit]