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

MemoryOverflowModel transactional disk sync performs very poorly #2998

Open
abrokenjester opened this issue Apr 15, 2021 · 6 comments
Open
Assignees
Labels
Milestone

Comments

@abrokenjester
Copy link
Contributor

abrokenjester commented Apr 15, 2021

In the MemoryOverflowModel used by the native store to handle data upload transactions, a big performance penalty has been observed whenever the model triggers syncing data to disk. On the mailinglist, Arjohn Kampman provided this analysis:

The reason that syncing the data to disk when the overflow is triggered takes so long is also related to a call to dataset(). When overflowToDisk() calls disk.addAll(memory), this triggers a call to SailSourceModel.add(s,p,o,c...) for each statement. This method then calls both contain(s,p,o,c...) and sink().approve(s,p,o.c) for for each statement. The latter call starts a new transaction and updates the txn-status file, but the contains() call then commits the transaction for the previous statement via a call to dataset(), again updating the txn-status file. So for every cached statement, rdf4j does two I/O calls. On a spinning disk with a an average write time of 10 ms, this limits the overflow process to at most 50 statements per second.

We should look into fixing this. Possible fixes include somehow eliminating one of the mentioned txn-update calls. A more drastic fix might be looking at using a disk sync that is not transactional: we currently use separate native store as the "backup", which has overhead. Something like MapDB or Ehcache for persistence might give better performance.

@daltontc
Copy link

daltontc commented May 3, 2023

@abrokenjester Is this still on your guys' radar? I am seeing some pretty poor performance when loading in very large files with conn.add(File, Resource...) and a lot of it is being stuck in the MemoryOverflowModel:
image

@hmottestad
Copy link
Contributor

hmottestad commented May 3, 2023

You should be able to bypass it if you start a transaction with the NONE isolation level. As long as you don't need transaction isolation.

@abrokenjester abrokenjester added the help wanted we could use your help in fixing this issue label May 3, 2023
@abrokenjester
Copy link
Contributor Author

It's kind of dropped off the radar a bit to be honest. @hmottestad 's suggestion to disable txn isolation for bulk uploads is a good workaround, but for fixing the underlying issue, we could use some fresh perspectives or an extra pair of hands.

@daltontc
Copy link

daltontc commented May 15, 2023

I'd be interested in potentially contributing a bit more to the project, but would definitely need to familiarize myself more with the codebase.

EDIT: removed message and made bug

@kenwenzel
Copy link
Contributor

kenwenzel commented May 16, 2023

@abrokenjester As far as I can see contains(s,p,o,c...) is only used for tracking the size of the SailSourceModel and may be omitted. The challenge is then that add(...) and remove(...) return a boolean value to indicate that a statement is actually added or removed.
But in the specific case investigated here the return value is not used by ChangeSet - neither here https://github.com/eclipse/rdf4j/blob/39a07105167201124c75bb9decc9749a143cc7e7/core/sail/base/src/main/java/org/eclipse/rdf4j/sail/base/Changeset.java#L418 nor here https://github.com/eclipse/rdf4j/blob/39a07105167201124c75bb9decc9749a143cc7e7/core/sail/base/src/main/java/org/eclipse/rdf4j/sail/base/Changeset.java#L449

@kenwenzel
Copy link
Contributor

see also #4557

One of the main reasons for the bad performance is that MemoryOverflowModel switches too late to a disk-based model.

hmottestad added a commit that referenced this issue May 9, 2024
@hmottestad hmottestad added this to the 5.0.0 milestone May 9, 2024
@hmottestad hmottestad self-assigned this May 9, 2024
@hmottestad hmottestad removed the help wanted we could use your help in fixing this issue label May 9, 2024
hmottestad added a commit that referenced this issue May 17, 2024
hmottestad added a commit that referenced this issue May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Project Progress
📋 Backlog
Development

No branches or pull requests

4 participants