Pre-size LIST results during materialization#343
Open
skuirrels wants to merge 1 commit into
Open
Conversation
skuirrels
marked this pull request as ready for review
July 21, 2026 09:14
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #343 +/- ##
===========================================
- Coverage 87.59% 87.53% -0.06%
===========================================
Files 77 77
Lines 3143 3154 +11
Branches 466 469 +3
===========================================
+ Hits 2753 2761 +8
- Misses 276 278 +2
- Partials 114 115 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request optimizes LIST/ARRAY materialization in the DuckDB.NET data reader by pre-sizing List<T> instances using DuckDB’s known list length, reducing allocations and repeated reflection overhead during reads.
Changes:
- Adds a regression test asserting
List<int>results are created with initial capacity equal to the list length. - Introduces a cached, reader-local factory path for
List<T>to constructnew List<T>(capacity)during list materialization. - Preserves the existing reflection-based fallback for non-
List<T>collection targets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| DuckDB.NET.Test/DuckDBDataReaderListTests.cs | Adds a test verifying list capacity is pre-sized during materialization. |
| DuckDB.NET.Data/DataChunk/Reader/ListVectorDataReader.cs | Implements cached List<T> factory creation and uses DuckDB-provided length as initial capacity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
LIST values are materialized into an empty
List<T>and grown as each item is added. That creates avoidable backing-array allocations and repeats reflective construction for every row.Solution
Create normal
List<T>results through a reader-local generic factory and pass DuckDB's known list length as the initial capacity. Custom collection targets keep the existing fallback.Benchmark
100,000 rows with a 16-item
List<int>, median of 7 runs after warmup:Tests