Skip to content

53 increase csv ingest speed - #54

Merged
kenwenzel merged 2 commits into
mainfrom
53-increase-csv-ingest-speed
Sep 1, 2026
Merged

53 increase csv ingest speed#54
kenwenzel merged 2 commits into
mainfrom
53-increase-csv-ingest-speed

Conversation

@wmehling

@wmehling wmehling commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Increased CSV Ingest from ~400k Tokens/s to ~ 800k Tokens/s

Depends on #51 / Builds on branch, so review #52 first

The optimization was split into three commits so each idea remains independently reviewable, benchmarkable, and revertible:

  1. Column-major row groups: CSV rows are collected in bounded groups of 1,000 and emitted column by column. Creates consecutive tuples with the same item/property/context. Throughput increased from the baseline 391.7k/502.7k tuples/s to **528.0k/561.1k tuples/**s in two independent runs.

  2. Prefix and lock reuse: The LevelDB batch writer reuses the resolved prefix and lock for consecutive tuples with the same identity. Throughput increased further to 602.9k/635.9k tuples/s.

  3. Bounded parser/storage overlap: One task parses CSV row groups while the request thread stores them through a bounded two-group queue. Final endpoint throughput reached 851.9k tuples/s in Run A and 694.7k tuples/s in Run B.

The existing row-major parse() API and read path remain unchanged; only the optimized ingestion route uses column-major ordering within each bounded group.

@wmehling wmehling linked an issue Jul 17, 2026 that may be closed by this pull request

@kenwenzel kenwenzel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CsvIngestionPipeline could in general also be used by other formats and there be generalized. Furthermore, a lock-free communication can be faster especially for smaller batch sizes.

}

IExtendedIterator<List<KvinTuple>> groups = parser.parseRowGroupBatches(rowsPerGroup);
BlockingQueue<Object> queue = new ArrayBlockingQueue<>(queueCapacity);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slower than using a CircularBuffer and Thread.onSpinWait() that allows to lock-free send data between too threads.

@kenwenzel

kenwenzel commented Aug 26, 2026

Copy link
Copy Markdown
Member

@wmehling Do you want to rebase this to main or should I do?

@wmehling

wmehling commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

I'll rebase and clean it up a bit so it is ready for review

@wmehling
wmehling force-pushed the 53-increase-csv-ingest-speed branch from bcf3fe6 to 75c8ba4 Compare August 27, 2026 10:49
@kenwenzel

Copy link
Copy Markdown
Member

@wmehling This does currently not include the multi-threading support for parsing and loading the data in parallel. Is this intended?

@wmehling

wmehling commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Yes, I wanted to reduce the size of the PR and only include the methods that speed up, but that are also robust. The other implementation of the multi-threading was not as reliable.

So for now this is the base, which achieved around +23% Speed up with your ideas.

I will invest some tokens to see, if we can find a fast, but also reliable and simple implementation for the multi-threading and see if that brings enough speed up to justify the complexity that comes with it. I'll keep you posted @kenwenzel once I have reviewed it / happy with it. Will probably be next week though

@kenwenzel
kenwenzel merged commit 4ce4460 into main Sep 1, 2026
1 check passed
@kenwenzel

Copy link
Copy Markdown
Member

@wmehling We have also experimented with several multi-threading approaches for RDF4J. The fastest is a lock-free circular buffer as implemented here:
https://github.com/eclipse-rdf4j/rdf4j/blob/5278473fc663e3c49ddf2c1d3b3fb19149a8e131/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java#L120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase CSV Ingest speed

2 participants