Bug 379443 - Slowdown when loading citation with many authors
Summary: Slowdown when loading citation with many authors
Status: RESOLVED FIXED
Alias: None
Product: KBibTeX
Classification: Applications
Component: General (show other bugs)
Version: 0.4.1
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Thomas Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-02 17:59 UTC by Louis Moureaux
Modified: 2021-01-09 20:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.10


Attachments
Citation with many authors (45.37 KB, text/x-bibtex)
2017-05-02 17:59 UTC, Louis Moureaux
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Louis Moureaux 2017-05-02 17:59:15 UTC
Created attachment 105313 [details]
Citation with many authors

The attached file loads fine, but KBibTeX crashes when clicking on the citation. I suspect this is because of the very long authors list.
Comment 1 Thomas Fischer 2017-05-04 21:02:25 UTC
According to the bug report parameters, you are using version 0.4.1, which is very old and no longer supported. Please contact your distribution's package maintainer for KBibTeX and ask for an upgrade.

The provided file (attachment 105313 [details]) loads with the latest stable version (0.6.2), but it becomes very slow, creating the impression that it has crashed. This is due to the inefficient design on how the list of authors in the "edit element" window is created; an issue which needs to be addressed.
Comment 2 Justin Zobel 2020-12-17 05:28:29 UTC
Thank you for the crash report.

As it has been a while since this was reported, can you please test and confirm if this issue is still occurring or if this bug report can be marked as resolved.

I have set the bug status to "needsinfo" pending your response, please change back to "reported" or "resolved/worksforme" when you respond, thank you.
Comment 3 Louis Moureaux 2020-12-17 11:05:29 UTC
The slowdown is still trivially reproducible by loading the provided citation in kbibtex 0.9.2 and navigating to the Authors tab in the editor. I assume this is why the bug didn't get closed after the first answer, so I switch it back to CONFIRMED.
Comment 4 Thomas Fischer 2020-12-23 22:39:22 UTC
(In reply to m_louis30 from comment #3)
> The slowdown is still trivially reproducible by loading the provided
> citation in kbibtex 0.9.2 and navigating to the Authors tab in the editor. I
> assume this is why the bug didn't get closed after the first answer, so I
> switch it back to CONFIRMED.

The problem is due to the inefficient management of widgets used to edit the list of authors. The problem is not noticable for shorter lists (let's say 10), but with 3100 authors, like the provided example, it becomes a problem.

I have refactored the code to avoid creating and tearing down author list widgets. This saves some time, but there is still some noticable delay.
Please check if the provided commit (in my personal KBibTeX clone repository) fixes your problem (or at least mitigates it).

https://invent.kde.org/thomasfischer/kbibtex/commit/fc1154b6d217d8dffdd3462822af500f2670f4a2
Comment 5 Thomas Fischer 2020-12-29 20:34:18 UTC
Minor update, force-pushed:
https://invent.kde.org/thomasfischer/kbibtex/commit/d080674e4679bdb556d0075d7c7bee6c4513cfc8
Comment 6 Louis Moureaux 2020-12-29 21:15:16 UTC
Thank you Thomas for taking care of this issue!

I tested master and the latest version of your patch (d080674e), and there is indeed a noticeable improvement. The slowdown is much more reasonable now. (These LHC papers with thousands of authors are quite extreme, so performance issues aren't fully unexpected.)
Comment 7 Thomas Fischer 2020-12-30 19:09:01 UTC
Git commit 6f76692736d33e3d68984ade57ea0810bd685e58 by Thomas Fischer.
Committed on 30/12/2020 at 19:07.
Pushed by thomasfischer into branch 'kbibtex/0.10'.

Reuse existing FieldLineEdit widgets instead of re-creating them

A problem apparent with bibliographic entries with many co-authors is that
initializing the list of authors in the 'Edit Element' dialog takes long time.
One contributing factor is that a considerable number of QWidget classes get
created, initialized, and later destroyed, only to be created again under
certain conditions.

This commit tries to re-use existing widgets (FieldLineEdit) as far as possible,
by simply setting a new value to them. Superfluous widgets get destroyed and
new widgets get only created if necessary.

Loading entries with many authors is now faster, although not all performance
issues are resolved.
FIXED-IN: 0.10

M  +9    -2    src/gui/element/elementwidgets.cpp
M  +26   -8    src/gui/field/fieldlistedit.cpp

https://invent.kde.org/office/kbibtex/commit/6f76692736d33e3d68984ade57ea0810bd685e58
Comment 8 Thomas Fischer 2021-01-09 20:19:09 UTC
Git commit 4b90599f4bb911393679a2e67828e97367502f74 by Thomas Fischer.
Committed on 30/12/2020 at 19:09.
Pushed by thomasfischer into branch 'master'.

Reuse existing FieldLineEdit widgets instead of re-creating them

A problem apparent with bibliographic entries with many co-authors is that
initializing the list of authors in the 'Edit Element' dialog takes long time.
One contributing factor is that a considerable number of QWidget classes get
created, initialized, and later destroyed, only to be created again under
certain conditions.

This commit tries to re-use existing widgets (FieldLineEdit) as far as possible,
by simply setting a new value to them. Superfluous widgets get destroyed and
new widgets get only created if necessary.

Loading entries with many authors is now faster, although not all performance
issues are resolved.

Cherry-picked from branch 'kbibtex/0.10', commit 6f76692736d33e3d68984ade57e.

M  +9    -2    src/gui/element/elementwidgets.cpp
M  +26   -8    src/gui/field/fieldlistedit.cpp

https://invent.kde.org/office/kbibtex/commit/4b90599f4bb911393679a2e67828e97367502f74