Bug 146454 - Calc: setDataArray with the strings is very slow in 7.3.0.1
Summary: Calc: setDataArray with the strings is very slow in 7.3.0.1
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.3.0.1 rc
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.4.0 target:7.3.0.2 target:7.2.6
Keywords: bibisected, bisected, regression
Depends on:
Blocks: Performance
  Show dependency treegraph
 
Reported: 2021-12-28 13:44 UTC by Kamil Landa
Modified: 2023-10-13 11:49 UTC (History)
2 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 Kamil Landa 2021-12-28 13:44:20 UTC
Only run this macro, it opens new Calc file and puts the strings to the 100k rows in column A. It is very slow in 7.3.0.1. 

Sub SlowSetDataArray
	const c=100000
	dim oDoc as object, oSheet as object, i&, data(c), oRange as object
	oDoc=StarDesktop.LoadComponentFromUrl("private:factory/scalc", "_Blank", 0, array()) 'new file
	oSheet=oDoc.Sheets(0)
	for i=0 to c
		data(i)=array(CStr(i)) 'speed tragedy, about 40 seconds; but in 7.2.4.1 it is OK, about 1 second
		'data(i)=array(i) 'fast, OK, about 1 second
	next i
	oRange=oSheet.getCellRangeByPosition(0, 0, 0, c)
	oRange.setDataArray(data)
End Sub


bugged:
Version: 7.3.0.1 (x64) / LibreOffice Community
Build ID: 840fe2f57ae5ad80d62bfa6e25550cb10ddabd1d
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: cs-CZ
Calc: CL


OK in:
Version: 7.2.4.1 (x64) / LibreOffice Community
Build ID: 27d75539669ac387bb498e35313b970b7fe9c4f9
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: cs-CZ
Calc: CL
Comment 1 Xisco Faulí 2021-12-28 15:08:22 UTC
Regression introduced by:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=b9e2c5d2a36fbd189c20448cadf4212edf02914d

author	Andreas Heinisch <andreas.heinisch@yahoo.de>	2021-11-04 11:50:51 +0100
committer	Eike Rathke <erack@redhat.com>	2021-11-08 23:04:54 +0100
commit b9e2c5d2a36fbd189c20448cadf4212edf02914d (patch)
tree 17bc34c956f818beb3cfbcba764f53fcd119511f
parent 140b90d30b30bddfda44b81e26284807807ab518 (diff)
tdf#142033 - Handle embedded newline set via SetDataArray

Bisected with: bibisect-linux64-7.3

Adding Cc: to Andreas Heinisch
Comment 2 Andreas Heinisch 2021-12-28 16:47:00 UTC
I have a fix in mind and will test it later. Maybe my idea works for targeting the performance issue here.
Comment 3 Andreas Heinisch 2021-12-29 21:44:37 UTC
Proposed patch: https://gerrit.libreoffice.org/c/core/+/127660

If I add a check for a multiline string, the time goes down from 220 to 5 seconds for the setDataArray function using plain strings in 7.4.0.0.alpha0+. However, in 7.2.3.2 (x64) the setDataArray call takes 1 second.

So there is still something which slows down the performance of the setDataArray function outside of this change.
Comment 4 Commit Notification 2022-01-12 16:19:28 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2d11710df6d81c03007d136667a443e09cc70eed

tdf#146454 - Check for multiline string in setDataArray

It will be available in 7.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Xisco Faulí 2022-01-12 17:32:04 UTC
i do confirm the issue is fixed in

Version: 7.4.0.0.alpha0+ / LibreOffice Community
Build ID: 2d11710df6d81c03007d136667a443e09cc70eed
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

now it takes 6 seconds, before the fix, it takes 1 min 27 seconds
Comment 6 Commit Notification 2022-01-12 17:34:07 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/b1e2d386afc3174d79a11fcfe365bf3a51f0caef

tdf#146454 - Check for multiline string in setDataArray

It will be available in 7.3.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2022-01-13 08:49:02 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/5ee413d78cfc1cbfbe7c05f0c21c40ffb32f572a

tdf#146454 - Check for multiline string in setDataArray

It will be available in 7.2.6.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Kamil Landa 2022-01-19 13:33:53 UTC
I confirm the fix in

Version: 7.3.0.2 (x64) / LibreOffice Community
Build ID: f1c9017ac60ecca268da7b1cf147b10e244b9b21
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: cs-CZ
Calc: CL

In my computer about 2 seconds. I tried the milion rows and 15sec in 7.2.3.2 also in 7.2.4.1 and also in 7.3.0.2.