perf: improve StringArray GetString decoding#334
Merged
CurtHagenlocher merged 1 commit intoapache:mainfrom Apr 27, 2026
Merged
Conversation
CurtHagenlocher
approved these changes
Apr 27, 2026
Contributor
CurtHagenlocher
left a comment
There was a problem hiding this comment.
Thanks! Can you please resolve the merge conflict?
Decode strings directly from the offsets and values buffers instead of routing through GetBytes, avoiding duplicate bounds/null/offset work on a common read path. BenchmarkDotNet (StringArrayGetStringBenchmark, Count=1024): LegacyGetString 23.50 us / 48.08 KB; GetString 17.79 us / 48.08 KB; LegacyGetStringFromSlice 22.89 us / 48.00 KB; GetStringFromSlice 17.67 us / 48.00 KB.
e8296e2 to
f7d6733
Compare
Contributor
Author
done. |
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.
Summary
StringArray.GetStringpreviously routed throughGetBytes, which repeated bounds/null/offset work before decoding the returned byte span. This PR decodes directly from the array's offsets and value buffer while preserving the materialized-string fast path.Benchmark
BenchmarkDotNet,
StringArrayGetStringBenchmark, Count=1024:GetStringGetStringFromSliceValidation
dotnet format Apache.Arrow.sln --include src/Apache.Arrow/Arrays/StringArray.cs test/Apache.Arrow.Tests/StringArrayTests.cs test/Apache.Arrow.Benchmarks/StringArrayGetStringBenchmark.cs --no-restoredotnet test test/Apache.Arrow.Tests/Apache.Arrow.Tests.csproj -c Release --filter "FullyQualifiedName~Apache.Arrow.Tests.StringArrayTests"dotnet build Apache.Arrow.sln -c Release