Add a stack-only Appender writer for high-throughput inserts#345
Open
skuirrels wants to merge 2 commits into
Open
Add a stack-only Appender writer for high-throughput inserts#345skuirrels wants to merge 2 commits into
skuirrels wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## Appender-Perf #345 +/- ##
================================================
Coverage ? 87.46%
================================================
Files ? 78
Lines ? 3256
Branches ? 471
================================================
Hits ? 2848
Misses ? 296
Partials ? 112 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
skuirrels
marked this pull request as ready for review
July 21, 2026 18:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CreateRow()returns an independentIDuckDBAppenderRow, which means allocating a row object for every insert. The callback-basedAppendRow()added in #336 can reuse its row, but the interface reference can still be retained outside the callback.Timestamp conversion was also making a native call for every value in the mixed-row workload.
Solution
Add
AppendRowScoped<TState>(), which passes a stack-onlyDuckDBAppenderRowWriterby reference. The writer cannot be boxed or stored on the managed heap, so the Appender can safely reuse its internal row state.The new path keeps the existing validation, vector writers, chunk lifecycle, automatic
EndRow(), and fault handling.CreateRow()is unchanged and still returns independent row objects.The two APIs intentionally have different contracts:
CreateRow()returns a retainable row, whileAppendRowScoped()owns the complete row lifetime. I have left deprecation out of this PR so it stays focused on the faster API. If we want to steer callers away fromCreateRow(), either you or I can follow up with a separate PR once the preferred migration path is agreed.Benchmarks
10,000 precomputed mixed-type rows inside a transaction, rolled back after each invocation:
CreateRow().EndRow()AppendRowScoped()Repeated scoped runs measured between 78.55 and 81.28 ns/row.
Tests
Added coverage for mixed and null values, chunk boundaries, callback and preparation failures, incomplete rows, existing
CreateRow()behaviour, and timestamp precision/offset edge cases.