Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
184fd84
GH-3511: Add JMH encoding benchmarks and fix parquet-benchmarks shade…
iemejia Apr 19, 2026
bbf36c7
GH-3511: Isolate setup cost and benchmark full dictionary paths
iemejia Apr 20, 2026
1710b3b
GH-3511: Tighten dictionary benchmarks and reduce setup coupling
iemejia Apr 20, 2026
04bce6a
Add JMH CompressionBenchmark for isolated codec throughput measurement
iemejia May 10, 2026
440c38c
Fine-tune JMH benchmarks for targeted per-branch measurement
iemejia May 13, 2026
bf599cd
GH-3522: Add batch read APIs to ValuesReader hierarchy (from par13)
iemejia May 13, 2026
17e20bd
Override readIntegers() in RLE ValuesReader to delegate to batch deco…
iemejia May 13, 2026
33478f4
Add ValuesReader-level and batch RLE decode benchmarks
iemejia May 13, 2026
5294294
Add PLAIN decoding benchmark for all numeric types (INT32/INT64/FLOAT…
iemejia May 13, 2026
ecb854e
Add batch decode benchmarks to ByteStreamSplitDecodingBenchmark
iemejia May 13, 2026
1072d58
Add BOOLEAN encoding characterization benchmark (V1 PLAIN vs V2 RLE)
iemejia May 13, 2026
ae8d22a
Add batch decode benchmarks to BooleanEncodingBenchmark (V1 PLAIN + V…
iemejia May 13, 2026
dcd9812
Add dictionary encoding benchmark for LONG, FLOAT, DOUBLE, and FLBA t…
iemejia May 13, 2026
598f470
Expand FLBA benchmark: add DELTA_BYTE_ARRAY, BSS, DICTIONARY encode+d…
iemejia May 13, 2026
dbb3562
Add LZ4_RAW to file-level benchmark @Param codec lists
iemejia May 13, 2026
67ef35b
Add batch encode benchmarks for BOOLEAN writeBooleans() API
iemejia May 13, 2026
cb0ba5b
Add batch encode benchmarks for PLAIN numeric encoding (INT32/INT64/F…
iemejia May 13, 2026
7f08762
Add FLBA PLAIN batch encode/decode benchmarks (encodePlainBatch, deco…
iemejia May 13, 2026
af56526
Add BROTLI to CompressionBenchmark codec parameter list
iemejia May 13, 2026
5cd1b29
Add BROTLI direct bypass in DirectCodecFactory using jbrotli JNI
iemejia May 13, 2026
c55905c
Use bulk ByteBuffer view reads in BSS batch decode for all numeric types
iemejia May 13, 2026
957d909
Optimize BOOLEAN decoding: direct bit extraction and batch readBoolea…
iemejia May 13, 2026
f36eac3
Use lookup table for boolean batch decode (PLAIN + RLE PACKED)
iemejia May 13, 2026
6503314
Optimize BOOLEAN encoding: batch writeBooleans() with direct byte pac…
iemejia May 13, 2026
7449f7c
Optimize PLAIN encoding: batch writeIntegers/writeLongs/writeFloats/w…
iemejia May 13, 2026
e8e256d
Add batch read/write APIs for fixed-length byte arrays
iemejia May 13, 2026
165bf49
Optimize FLBA BSS encoding: batched scatter replacing per-byte stream…
iemejia May 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions parquet-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,50 @@
</dependency>
</dependencies>

<profiles>
<!-- PARQUET-1975 Do not add brotli-codec for ARM64 architectures -->
<profile>
<id>non-aarch64</id>
<activation>
<os>
<arch>!aarch64</arch>
</os>
</activation>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<name>Jitpack.io repository</name>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.rdblue</groupId>
<artifactId>brotli-codec</artifactId>
<version>${brotli-codec.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</path>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>org.openjdk.jmh.generators.BenchmarkProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -112,6 +151,12 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/BenchmarkList</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/CompilerHints</resource>
</transformer>
</transformers>
<artifactSet>
<includes>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.parquet.benchmarks;

import java.io.IOException;
import org.apache.parquet.column.page.DictionaryPage;
import org.apache.parquet.column.values.dictionary.DictionaryValuesWriter;

/**
* Shared helpers for encode/decode micro-benchmarks.
*/
final class BenchmarkEncodingUtils {

private BenchmarkEncodingUtils() {}

/**
* Container for the two artefacts produced by a dictionary-encoded page:
* the encoded dictionary indices ({@link #dictData}) and the dictionary
* page itself ({@link #dictPage}). The dictionary page may be {@code null}
* if the writer fell back to plain encoding (for example, when the
* dictionary exceeded its configured maximum size).
*/
static final class EncodedDictionary {
final byte[] dictData;
final DictionaryPage dictPage;

EncodedDictionary(byte[] dictData, DictionaryPage dictPage) {
this.dictData = dictData;
this.dictPage = dictPage;
}

boolean fellBackToPlain() {
return dictPage == null;
}
}

/**
* Drains a {@link DictionaryValuesWriter} into an {@link EncodedDictionary}.
*
* <p>The writer's data bytes (the RLE-encoded indices) and the dictionary
* page are returned separately so both pieces can be measured or fed to a
* decoder symmetrically. The dictionary page buffer is copied so it remains
* valid after the writer's allocator is released.
*
* <p>The writer is closed via {@code toDictPageAndClose()}; callers must not
* call {@link DictionaryValuesWriter#close()} again afterwards.
*/
static EncodedDictionary drainDictionary(DictionaryValuesWriter writer) throws IOException {
byte[] dictData = writer.getBytes().toByteArray();
DictionaryPage rawPage = writer.toDictPageAndClose();
DictionaryPage dictPage = rawPage == null ? null : rawPage.copy();
return new EncodedDictionary(dictData, dictPage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.parquet.benchmarks;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeUnit;
import org.apache.parquet.bytes.ByteBufferInputStream;
import org.apache.parquet.bytes.HeapByteBufferAllocator;
import org.apache.parquet.column.Dictionary;
import org.apache.parquet.column.Encoding;
import org.apache.parquet.column.page.DictionaryPage;
import org.apache.parquet.column.values.ValuesWriter;
import org.apache.parquet.column.values.deltalengthbytearray.DeltaLengthByteArrayValuesReader;
import org.apache.parquet.column.values.deltalengthbytearray.DeltaLengthByteArrayValuesWriter;
import org.apache.parquet.column.values.deltastrings.DeltaByteArrayReader;
import org.apache.parquet.column.values.deltastrings.DeltaByteArrayWriter;
import org.apache.parquet.column.values.dictionary.DictionaryValuesReader;
import org.apache.parquet.column.values.dictionary.DictionaryValuesWriter;
import org.apache.parquet.column.values.dictionary.PlainValuesDictionary;
import org.apache.parquet.column.values.plain.BinaryPlainValuesReader;
import org.apache.parquet.column.values.plain.PlainValuesWriter;
import org.apache.parquet.io.api.Binary;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OperationsPerInvocation;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

/**
* Encoding-level and decoding-level micro-benchmarks for BINARY values.
* Compares PLAIN, DELTA_BYTE_ARRAY, DELTA_LENGTH_BYTE_ARRAY, and DICTIONARY encodings
* across different string lengths and cardinality patterns.
*
* <p>Each benchmark invocation processes {@value #VALUE_COUNT} values. Throughput is
* reported per-value using {@link OperationsPerInvocation}.
*
* <p>The dictionary encode/decode benchmarks intentionally measure the full path:
* the encoder produces both the RLE-encoded indices and a {@link DictionaryPage};
* the decoder consumes the indices through a {@link DictionaryValuesReader} backed
* by the same dictionary. If the dictionary exceeds {@link #MAX_DICT_BYTE_SIZE}
* (which can happen for high-cardinality, long-string parameter combinations) the
* writer falls back to plain encoding and dictionary decoding for that combination
* is skipped.
*/
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Fork(1)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 1)
@State(Scope.Thread)
public class BinaryEncodingBenchmark {

static final int VALUE_COUNT = 100_000;
private static final int INIT_SLAB_SIZE = 64 * 1024;
private static final int PAGE_SIZE = 4 * 1024 * 1024;
private static final int MAX_DICT_BYTE_SIZE = 4 * 1024 * 1024;

@Param({"10", "100", "1000"})
public int stringLength;

/** LOW = 100 distinct values; HIGH = all unique. */
@Param({"LOW", "HIGH"})
public String cardinality;

private Binary[] data;
private byte[] plainEncoded;
private byte[] deltaLengthEncoded;
private byte[] deltaStringsEncoded;
private byte[] dictEncoded;
private DictionaryPage dictPage;
private Dictionary binaryDictionary;
private boolean dictionaryAvailable;

@Setup(Level.Trial)
public void setup() throws IOException {
int distinct = "LOW".equals(cardinality) ? TestDataFactory.LOW_CARDINALITY_DISTINCT : 0;
data = TestDataFactory.generateBinaryData(VALUE_COUNT, stringLength, distinct, TestDataFactory.DEFAULT_SEED);

// Pre-encode data for decode benchmarks
plainEncoded = encodeBinaryWith(newPlainWriter());
deltaLengthEncoded = encodeBinaryWith(newDeltaLengthWriter());
deltaStringsEncoded = encodeBinaryWith(newDeltaStringsWriter());

DictionaryValuesWriter.PlainBinaryDictionaryValuesWriter dictWriter = newDictWriter();
for (Binary v : data) {
dictWriter.writeBytes(v);
}
BenchmarkEncodingUtils.EncodedDictionary encoded = BenchmarkEncodingUtils.drainDictionary(dictWriter);
dictEncoded = encoded.dictData;
dictPage = encoded.dictPage;
dictionaryAvailable = !encoded.fellBackToPlain();
if (dictionaryAvailable) {
binaryDictionary = new PlainValuesDictionary.PlainBinaryDictionary(dictPage);
}
}

private byte[] encodeBinaryWith(ValuesWriter writer) throws IOException {
for (Binary v : data) {
writer.writeBytes(v);
}
byte[] bytes = writer.getBytes().toByteArray();
writer.close();
return bytes;
}

private BenchmarkEncodingUtils.EncodedDictionary encodeDictionaryWith(
DictionaryValuesWriter.PlainBinaryDictionaryValuesWriter writer) throws IOException {
for (Binary v : data) {
writer.writeBytes(v);
}
return BenchmarkEncodingUtils.drainDictionary(writer);
}

// ---- Writer factories ----

private static PlainValuesWriter newPlainWriter() {
return new PlainValuesWriter(INIT_SLAB_SIZE, PAGE_SIZE, new HeapByteBufferAllocator());
}

private static DeltaLengthByteArrayValuesWriter newDeltaLengthWriter() {
return new DeltaLengthByteArrayValuesWriter(INIT_SLAB_SIZE, PAGE_SIZE, new HeapByteBufferAllocator());
}

private static DeltaByteArrayWriter newDeltaStringsWriter() {
return new DeltaByteArrayWriter(INIT_SLAB_SIZE, PAGE_SIZE, new HeapByteBufferAllocator());
}

private static DictionaryValuesWriter.PlainBinaryDictionaryValuesWriter newDictWriter() {
return new DictionaryValuesWriter.PlainBinaryDictionaryValuesWriter(
MAX_DICT_BYTE_SIZE, Encoding.PLAIN_DICTIONARY, Encoding.PLAIN, new HeapByteBufferAllocator());
}

// ---- Encode benchmarks ----

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public byte[] encodePlain() throws IOException {
return encodeBinaryWith(newPlainWriter());
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public byte[] encodeDeltaLengthByteArray() throws IOException {
return encodeBinaryWith(newDeltaLengthWriter());
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public byte[] encodeDeltaByteArray() throws IOException {
return encodeBinaryWith(newDeltaStringsWriter());
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know of this trick until i saw your PR; adopted in #3452 earlier today

public void encodeDictionary(Blackhole bh) throws IOException {
BenchmarkEncodingUtils.EncodedDictionary encoded = encodeDictionaryWith(newDictWriter());
bh.consume(encoded.dictData);
bh.consume(encoded.dictPage);
}

// ---- Decode benchmarks ----

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public void decodePlain(Blackhole bh) throws IOException {
BinaryPlainValuesReader reader = new BinaryPlainValuesReader();
reader.initFromPage(VALUE_COUNT, ByteBufferInputStream.wrap(ByteBuffer.wrap(plainEncoded)));
for (int i = 0; i < VALUE_COUNT; i++) {
bh.consume(reader.readBytes());
}
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public void decodeDeltaLengthByteArray(Blackhole bh) throws IOException {
DeltaLengthByteArrayValuesReader reader = new DeltaLengthByteArrayValuesReader();
reader.initFromPage(VALUE_COUNT, ByteBufferInputStream.wrap(ByteBuffer.wrap(deltaLengthEncoded)));
for (int i = 0; i < VALUE_COUNT; i++) {
bh.consume(reader.readBytes());
}
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public void decodeDeltaByteArray(Blackhole bh) throws IOException {
DeltaByteArrayReader reader = new DeltaByteArrayReader();
reader.initFromPage(VALUE_COUNT, ByteBufferInputStream.wrap(ByteBuffer.wrap(deltaStringsEncoded)));
for (int i = 0; i < VALUE_COUNT; i++) {
bh.consume(reader.readBytes());
}
}

@Benchmark
@OperationsPerInvocation(VALUE_COUNT)
public void decodeDictionary(Blackhole bh) throws IOException {
if (!dictionaryAvailable) {
// Dictionary fell back to plain encoding (e.g. high-cardinality long strings
// exceeding MAX_DICT_BYTE_SIZE). Skip to keep the benchmark meaningful.
return;
}
DictionaryValuesReader reader = new DictionaryValuesReader(binaryDictionary);
reader.initFromPage(VALUE_COUNT, ByteBufferInputStream.wrap(ByteBuffer.wrap(dictEncoded)));
for (int i = 0; i < VALUE_COUNT; i++) {
bh.consume(reader.readBytes());
}
}
}
Loading
Loading