Bug 158167 - Calc: Move selected row and scroll sheet extremely slow with CPU in local debug build
Summary: Calc: Move selected row and scroll sheet extremely slow with CPU in local deb...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: high normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: notBibisectable, regression
Depends on:
Blocks: Cell-Management
  Show dependency treegraph
 
Reported: 2023-11-10 15:28 UTC by Timur
Modified: 2024-01-31 15:56 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Video (192.30 KB, video/x-matroska)
2023-11-14 11:09 UTC, Timur
Details
Windows Performance Analyzer output (143.00 KB, image/png)
2024-01-17 00:53 UTC, Matt K
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2023-11-10 15:28:06 UTC
In Calc: mark row by clicking on row header, move mouse right/outside, press move row. Cannot move selected row in 24.2. 
This is a common feature in Calc and, if not some local issue, a recent regression, so I set High.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c32bf48b7446808ffc47472021ec32cb7c70eea7
CPU threads: 16; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Julien Nabet 2023-11-10 20:05:04 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.

I didn't notice anything specific on console.
Comment 2 BogdanB 2023-11-11 06:47:13 UTC
I tried to bibisect, but I don't kwow how to test it:
- click on row header 2 (for example)
- move cursor on the cell area of row 2
- drag & drop that row down --> the row data is moving down

I missed something?
Comment 3 Timur 2023-11-11 08:37:28 UTC
My build was fresh, like 1 day old, and yesterday bisect was older.
So we need 24.2 repo update to see if reproducible.
Comment 4 BogdanB 2023-11-11 22:14:16 UTC
I build LibreOffice with latest updates from master, and no problem with Calc.
Are my steps wrong? (see comment 2)

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 64ccc089c1e6bf82ef10a0dd4768fdff83af55b5
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 5 Timur 2023-11-14 11:09:30 UTC Comment hidden (obsolete)
Comment 6 BogdanB 2023-11-14 20:07:21 UTC
(In reply to Timur from comment #5)
> Created attachment 190825 [details]
> Video
> 
> This should be obvious, if reproducible.

Exactly, but I don't reproduce

with
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: d646341e5ddc625d9cf69777b4be174aebb43700
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: x11
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

nor with
Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: d646341e5ddc625d9cf69777b4be174aebb43700
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 7 Timur 2023-11-21 11:06:19 UTC
So, this is not in bibisect build, just local debug build.
Comment 8 BogdanB 2023-11-21 20:00:15 UTC
I updated today the bibisect repo, was downloading new updates, but still don't repro.
Comment 9 Stéphane Guillou (stragu) 2023-11-22 09:06:19 UTC
(In reply to Timur from comment #0)
> [...] Cannot move selected row in 24.2. [...]
> Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
> Build ID: c32bf48b7446808ffc47472021ec32cb7c70eea7
I checked out the bibisect repo at c32bf48b7446808ffc47472021ec32cb7c70eea7 and could not reproduce.

No repro either in a recent daily build:

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: baecfd21797310bb15ab98ca3962445d99e397db
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

I did however notice a small delay in displaying the icon that denotes moving a row, so if I drag quickly then stop moving, the move is not effective when releasing (no target row highlighted, no arrows on the icon). But that's obviously something different to what you show in the video.

Now, I tested in a debug build and I can reproduce. Feels like a perf issue: if I keep the mouse button pressed for a long time it eventually changes icon and highlights the target row. Release, wait, and data is moved.
Even just row selection is sluggish. I have to wait 3 seconds before the selection changes to another row.

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3aca2d9776a871f15009a1aa70628ba3a03ee147
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same issue with gen VCL plugin.
Columns don't have the same issue.
Comment 10 Aron Budea 2023-11-26 09:12:57 UTC
I'd think this is related to switching to 16k columns, so the amount of data to move is 16x as it used to be before, and a debug build is obviously not optimized for performance.

I can't tell whether this needs improvement or could be further improved.
Comment 11 ady 2023-11-26 14:46:05 UTC
(In reply to Aron Budea from comment #10)
> I'd think this is related to switching to 16k columns

If that's the case, the behavior should be already noticed in LO 7.4, when the 16384 columns were introduced. ATM this is reported against LO 24.2. Timur?
Comment 12 Timur 2023-11-27 08:30:22 UTC
I see no difference with 16k option or without 16k: 1st time I move row after loading, it lags 5-6 secs, but later I cannot move it at all.
Comment 13 ady 2023-11-27 16:20:43 UTC
(In reply to Timur from comment #12)
> I see no difference with 16k option or without 16k: 1st time I move row
> after loading, it lags 5-6 secs, but later I cannot move it at all.

My intention was for someone to test with older versions, before and after the official/default introduction of 16k rows in LO 7.4.

I wasn't aware that the 2nd (consecutive) move was behaving differently/worse than the 1st; maybe I missed that detail from prior comments.

Now my test...


Since the introduction of 16384 columns in LO 7.4, there seems to be some (minor?) additional lag when moving a row (in comparison to LO 7.3), but the lag is _much_ more notable in LO 24.2.

Additionally, until LO 7.6, while moving the selected row/area (dragging the mouse but before releasing the button) we can see an edge/border indicating the destination area of the move. In contrast, in LO 24.2, such border over the to-be-destination area (either an entire row or any other selected area/cell) is not seen (although my 24.2 alpha is several weeks old ATM, so YMMV).

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c0c8cffd3541e3cd616c96791b04e7ebf2b2ed03
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (es_AR); UI: en-US
Calc: CL threaded
Comment 14 Matt K 2024-01-17 00:53:58 UTC
Created attachment 192006 [details]
Windows Performance Analyzer output

I took a perf trace under Windows using the Windows Performance Recorder UI tool with CPU Usage collection selected.  I've attached the output which shows the code is spending at least 15 seconds (3 intervals of almost 5 seconds each) doing sclo.dll!ScColContainer::resize which just calls "reserve" on a std::vector container.  I don't know why moving a row has anything to do with resizing columns, but maybe someone more familiar with the code can determine the problem.
Comment 15 Buovjaga 2024-01-31 06:37:51 UTC
(In reply to Matt K from comment #14)
> Created attachment 192006 [details]
> Windows Performance Analyzer output
> 
> I took a perf trace under Windows using the Windows Performance Recorder UI
> tool with CPU Usage collection selected.  I've attached the output which
> shows the code is spending at least 15 seconds (3 intervals of almost 5
> seconds each) doing sclo.dll!ScColContainer::resize which just calls
> "reserve" on a std::vector container.  I don't know why moving a row has
> anything to do with resizing columns, but maybe someone more familiar with
> the code can determine the problem.

That sounds exactly like the bibisect result I got for bug 159131, so can Timur or others still repro after Noel's fix? Noel does say in the fixing commit: "I'm not sure why the above commit causes trouble on Windows, but not Linux"
Comment 16 Timur 2024-01-31 11:11:33 UTC
This was very slow for me in GTK and now it less slow, like 2 secs, which is accepratable for debug build, but I am not sure if good for a normal use, should be checked in a release.
That bisected commit is from 7.5 but with installed LO 7.5.9 I see no delay, even those 2 secs.
Comment 17 Matt K 2024-01-31 14:43:12 UTC
I also repro about a 2 sec delay on Windows with the fix on a debug build, which is better than the 10+ sec delay that was there before.
Comment 18 ady 2024-01-31 15:07:53 UTC
An aside comment (but maybe not _that_ aside)...

FWIW, there was some performance issue that received some kind of patch and was later reverted, and applied again with some modification, only to be later reverted again [1]. This back and forth is around versions 7.4 to 7.6 and master (during 24.2 dev), so the _specific_ version/build that is tested for this report tdf#158167 might be relevant (with or without that patch applied/reverted).

The only reason I mention this here is because we are talking about performance under certain circumstances. The original reasons that triggered each of the lags/crashes and the respective patches might not be related to each other at all, but the possible delays (or improvements) in each test case might be wrongly attributed to some assumed proposed solution while in fact the resulting behavior might be a consequence of something else, unrelated.

IOW, seeing delays/lags in one version but not in the other, or in both (7.6.x vs 24.2.dev) while testing the reported behavior might be related to diverse factors, including the inclusion of a patch that was later reverted (twice) during the relevant development cycle.

Whether the (reverted) patch is actually of any influence for the reported behavior in this tdf#158167, I have no idea.

[1]: <https://bugs.documentfoundation.org/show_bug.cgi?id=157042#c32>
Comment 19 Timur 2024-01-31 15:56:07 UTC
That 10 sec looked Major, now 2 sec seems High-Normal.