Skip to content

perf(arrow/csv): reserve record builders for chunked reads - #1198

Merged
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:perf/csv-reader-reserve
Aug 14, 2026
Merged

perf(arrow/csv): reserve record builders for chunked reads#1198
zeroshade merged 1 commit into
apache:mainfrom
fallintoplace:perf/csv-reader-reserve

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

  • Reserve the configured chunk capacity once before reading each chunked batch.
  • Keep schema inference working by reserving after the first row initializes the builder.
  • Leave the single-row and ReadAll paths unchanged.

Benchmark

On an Apple M1 Pro, BenchmarkRead/rows=1000_cols=100_chunks=10 improved locally from a median of about 36.4 ms to 25.6 ms.

  • B/op: about 24.2 MB -> 17.4 MB
  • allocs/op: about 163k -> 113k

The gain is chunk-size dependent. Very small batches are already close to the builders’ minimum capacity.

Tests

  • PARQUET_TEST_DATA=... go test ./arrow/csv -run ^Test\n* PARQUET_TEST_DATA=... go test -race ./arrow/csv -run ^Test\n* Full package test run passed with the local Parquet test data checkout, excluding the CSV example that needs a separate Arrow CSV fixture.

@fallintoplace
fallintoplace force-pushed the perf/csv-reader-reserve branch from fd6a8b6 to b047a9d Compare August 14, 2026 16:55
@fallintoplace
fallintoplace marked this pull request as ready for review August 14, 2026 16:57
@zeroshade
zeroshade merged commit 258cb20 into apache:main Aug 14, 2026
23 checks passed
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.

2 participants