pvary commented on code in PR #16747:
URL: https://github.com/apache/iceberg/pull/16747#discussion_r3389658120


##########
core/src/jmh/java/org/apache/iceberg/mumbling/PFOREncodingBenchmark.java:
##########
@@ -0,0 +1,212 @@
+/*
+ * 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.iceberg.mumbling;
+
+import java.nio.ByteBuffer;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+import me.lemire.integercompression.FastPFOR128;
+import me.lemire.integercompression.IntWrapper;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.Threads;
+import org.openjdk.jmh.annotations.Timeout;
+import org.openjdk.jmh.annotations.Warmup;
+import org.openjdk.jmh.infra.Blackhole;
+
+/**
+ * A benchmark that evaluates the performance of {@link PFOREncoding} and 
compares it with
+ * JavaFastPFOR.
+ *
+ * <p>Two data shapes are exercised:
+ *
+ * <ul>
+ *   <li><b>Descriptor</b>: 256 values in {@code [0, 31]} with 5% full-range 
outliers, typical for
+ *       Mumbling bitmap descriptor arrays.
+ *   <li><b>Uniform byte</b>: 256 values drawn uniformly from {@code [0, 
255]}, the worst case for
+ *       PFOR (no compression benefit; exercises the fallback path).
+ * </ul>
+ *
+ * <p>To run this benchmark: <code>
+ *   ./gradlew :iceberg-core:jmh
+ *       -PjmhIncludeRegex=PFOREncodingBenchmark
+ *       -PjmhOutputPath=benchmark/pfor-encoding-benchmark.txt
+ * </code>
+ */
+@Fork(1)
+@State(Scope.Benchmark)
+@Warmup(iterations = 3)
+@Measurement(iterations = 5)
+@BenchmarkMode(Mode.Throughput)
+@Timeout(time = 5, timeUnit = TimeUnit.MINUTES)
+public class PFOREncodingBenchmark {
+
+  // Iceberg PFOR input arrays
+  private int[] descriptorValues;
+  private int[] uniformValues;
+
+  // Pre-encoded buffers for decode benchmarks
+  private ByteBuffer descriptorEncoded;
+  private ByteBuffer uniformEncoded;
+
+  // Reusable encode buffer (avoids allocation in the encode hot path)
+  private ByteBuffer encodeBuffer;
+
+  // Reusable decode output (avoids allocation in the decode hot path)
+  private int[] decodeOutput;
+
+  // JavaFastPFOR compressed arrays (pre-encoded for decode benchmarks)
+  private int[] descriptorFastPFOREncoded;
+  private int[] uniformFastPFOREncoded;
+
+  // Reusable output buffers for JavaFastPFOR (avoids allocation in hot path)
+  private int[] fastPFOROutputBuffer;
+
+  @Setup
+  public void setupBenchmark() {
+    Random random = new Random(1938745);
+
+    // 256-value descriptor-like data: mostly [0,31] with ~5% [0,255] outliers
+    descriptorValues = PFORRandomData.exceptions(random, 256, 0.5f);

Review Comment:
   0.05?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to