Uh oh!
There was an error while loading. Please reload this page.
GH-3451. Add a JMH benchmark for variants - #3452
Conversation
steveloughran
commented
Mar 19, 2026
Still thinking of what else can be done here...suggestions welcome. Probably a real write to the localfs and read back in |
steveloughran
commented
Mar 23, 2026
I'll add a "deep" option too, for consistency with the iceberg pr |
| private static int count() { | ||
| int c = counter++; | ||
| if (c >= 512) { | ||
| c = 0; |
There was a problem hiding this comment.
only resets the local copy, counter keeps growing?
There was a problem hiding this comment.
good point. will fix.
* deser to recurse down * include uuid and bigdecimal * reset counter on benchmark setup
iterations of class code and #of rows are the same for easy compare of overheads.
Using the same structure as the iceberg tests do
steveloughran
commented
Mar 30, 2026
There's now a new benchmark which writes a file using the same simple schema as I'm doing in iceberg apache/iceberg#15629 , and tries to do a projection on it. Review by the copilot Setup: 1M rows, 4-field nested variant (idstr, varid, varcategory, col4), querying varcategory only. SingleShotTime, 15 iterations, @fork(0). Raw Results Speedup/Penalty vs readAllRecords Baseline
Recommendation Always detect file layout in ReadSupport.init() and apply the lean projection only when the file was written with a shredded schema. For unshredded files, use the full file schema or no projection.If you have a query with a pushdown predicate that wants to look inside a variant, creating a MessageType schema referring to the shredded values is counterproductive unless you know that the variant is shedded. That can be determined by looking at the schema and use `.containsField("typed_value") to see if the target variant has any nested values. @OverridepublicReadContextinit(InitContextcontext) {
MessageTypefileSchema = context.getFileSchema();
GroupTypenested = fileSchema.getType("nested").asGroupType();
if (nested.containsField("typed_value")) {
returnnewReadContext(VARCATEGORY_PROJECTION);
}
// Unshredded file: projection designed for typed columns provides no benefit and// causes schema mismatch overhead — fall back to the full file schema.returnnewReadContext(fileSchema);
} |
steveloughran
commented
Mar 31, 2026
build failures are all because java11 javadoc is extra-fussy than the versions either side of it. |
steveloughran
commented
Apr 2, 2026
Flame graph profiles so you can compare what is using CPU time when working with variants Variant rebuild is expensive, I've got a minor (and will keep package private) tweak to VariantBuilder to allow VariantStringConverter to add a Binary as a string to the variant without converting it to a string en-route, which would save a lot of needless string creation. Variant.getFieldAtIndex() is pretty expensive too. |
steveloughran
commented
Apr 8, 2026
Slides. Reading the PR will make the notion of file vs lean schema clearer. |
* Move under variant package to access private members * add "variant" group to run.sh * new benchmark VariantConverterBenchmark
f5416d7 to
d75278aCompare
Fokko
left a comment
There was a problem hiding this comment.
This looks great to me, thanks @steveloughran 🙌
steveloughran
commented
Apr 21, 2026
thanks @Fokko! Can you do the merge? |
steveloughran
commented
Apr 22, 2026
just doing some feature creep here
|
* UUIDs in projection benchmark. * col4 var column now a long string and named as such. * builder and converter benchmarks use @OperationsPerInvocation rather than internal iterators.
latest numbers before adding uuid read (but with that long column) after adding UUID variant field. points to note
|
steveloughran
commented
Apr 23, 2026
No further changes planned...now it's time for people to look at those numbers and think of improvements. Looking forward! |
nssalian
commented
Apr 23, 2026
@steveloughran Let's keep the benchmark code here and move the changes to #3481 (I've already pulled some of the changes there). It's great to verify here, but since the original intent was to add JMH benchmarks, let's scope this to that and get the improvements in another focused PR. |
steveloughran
commented
Apr 24, 2026
@nssalian will do. |
including pulling a benchmark from VariantConverters. Pull the warmup/measurement times to a shared constant. If someone thinks the numbers should be bigger: one place to change.
Uh oh!
There was an error while loading. Please reload this page.
Fokko
commented
May 11, 2026
Thanks @steveloughran for working on this, and thanks @nssalian and @xiaoxuandev for the review 🚀 |
steveloughran
commented
May 12, 2026
@Fokko thanks for merging this! |
Rationale for this change
There's no benchmark for variant IO and so there's no knowledge of any problems which exist now, or any way to detect regressions.
What changes are included in this PR?
VariantBuilderBenchmarkto measure builder cost.VariantConverterBenchmarkshows a 20% reduction in time to convert a marshalled string to a java string within a builder. This codepath is used when reconstructing partially shredded variants.Are these changes tested?
Apart from a minor change in VariantConverter/VariantBuilder, this is all benchmark
See https://steveloughran.github.io/benchmarking-variants/ for the writeup and the interactive benchmark results of Iceberg and Parquet benchmarks.
Are there any user-facing changes?
No
Closes#3451