Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading large database takes way too long after commit 5.7--2022-08-01--8389254 #9041

Closed
2 tasks done
amaxi99 opened this issue Aug 11, 2022 · 3 comments · Fixed by #9045
Closed
2 tasks done

Loading large database takes way too long after commit 5.7--2022-08-01--8389254 #9041

amaxi99 opened this issue Aug 11, 2022 · 3 comments · Fixed by #9045
Labels
bug Confirmed bugs or reports that are very likely to be bugs type: performance

Comments

@amaxi99
Copy link

amaxi99 commented Aug 11, 2022

JabRef version

Latest development branch build (please note build date below)

Operating system

Windows

Details on version and operating system

Windows 11 21H2

Checked with the latest development build

  • I made a backup of my libraries before testing the latest development version.
  • I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

Opening a large database with 15.000 entries (22MB file size) takes about 3 minutes in current development versions. In versions before August 1 it took about 4 s to open the same file (until version JabRef 5.7--2022-08-01--8389254).

Appendix

...

Log File
Paste an excerpt of your log file here
@amaxi99 amaxi99 changed the title Loading large database takes way to long in recent development versions Loading large database takes way too long in recent development versions Aug 11, 2022
@ThiloteE ThiloteE added the bug Confirmed bugs or reports that are very likely to be bugs label Aug 11, 2022
@ThiloteE ThiloteE changed the title Loading large database takes way too long in recent development versions Loading large database takes way too long after commit 5.7--2022-08-01--8389254 Aug 11, 2022
@ThiloteE
Copy link
Member

meta-issue: #8906

@Siedlerchr
Copy link
Member

confirmed. Guess the root issue is this method which is executed for each entry

private void updateVisibleFields() {
visibleFields.clear();
Set<Field> allFields = new TreeSet<>(Comparator.comparing(Field::getName));
for (BibEntry e : getEntries()) {
allFields.addAll(e.getFields());
}
visibleFields.addAll(allFields.stream().filter(field -> !FieldFactory.isInternalField(field))
.filter(field -> StringUtil.isNotBlank(field.getName()))
.collect(Collectors.toSet()));
}

and is costly
It was introduced by the AutomaticFieldEditor

@HoussemNasri
Copy link
Member

I profiled the app and I can confirm that updateVisibleFields is responsible for the performance downgrade. While working on the automatic field editor, I made the false assumption that loading a library would use BibDatabase#insertEntries once, which is why updateVisibleFields was called when inserting entries, but the actual implementation inserts an entry as soon as it is parsed.

The good news is that updateVisibleFields is not even required. The automatic field editor dialog was designed to automatically update its list of visible fields whenever a new field is added, but due to numerous bugs that popped up, we now only do so when the dialog is opened.

I suggest that we go back to the old implementation. We'll lose the ability to observe changes in visible fields, but since it affects the performance I think it is worthwhile. The fix can be as easy as copy-pasting the BibDatabase class state before updateVisibleFields was introduced.

https://github.com/JabRef/jabref/blob/be4a7c55c669dae4279bea6562a6c9795adada37/src/main/java/org/jabref/model/database/BibDatabase.java

Siedlerchr added a commit that referenced this issue Aug 11, 2022
Revert bibdatabasemode to previous state

Fixes #9041
Siedlerchr added a commit that referenced this issue Aug 21, 2022
Revert bibdatabasemode to previous state

Fixes #9041
@koppor koppor moved this to Done in Prioritization Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs type: performance
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants