DEVOURED
Same buffers, same instructions, same hardware. Where Is the JVM Tax?
Semyon Sinchenko's benchmarks show modern Java running vectorized arithmetic kernels over Apache Arrow buffers delivers performance comparable to native arrow-rs, challenging the "JVM tax" narrative for analytical workloads.
What: Semyon Sinchenko conducted toy benchmarks comparing Java implementations of simple vectorized arithmetic kernels (addInt32, mulFloat64) over Apache Arrow buffers using MemorySegment and JDK Vector API against native arrow-rs. Running on a ThinkPad with Intel i5, the results for MulFloat64 showed similar performance, often within 10-25% of each other, suggesting no inherent "JVM tax" for raw compute on columnar memory.
Why it matters: This experiment pushes back against a common generalization in big data, clarifying that perceived performance penalties often stem from specific architectural choices (like Spark's scheduler or object-per-value data planes) rather than an intrinsic limitation of the JVM itself, especially with modern Java features and columnar memory layouts.
Takeaway: When designing high-performance data pipelines in Java, prioritize columnar memory layouts (like Apache Arrow) and leverage modern JVM features (like MemorySegment and Vector API) to avoid common "JVM tax" pitfalls.
Deep dive
- Semyon Sinchenko benchmarked Java vs. native performance for simple vectorized arithmetic kernels over Apache Arrow buffers.
- The Java implementation used the official Apache Arrow Java SDK (16.1.0), JDK 25.0.3-temurin,
java.lang.foreign.MemorySegment, and the JDK Vector API. - The native reference used
arrow-rs(56) and the Criterion benchmark harness. - The hardware was a 13th Gen Intel Core i5-1335U.
- For
MulFloat64, Java and nativearrow-rsshowed "roughly the same performance class," with ratios typically between 1.13x and 1.25x in favor of native or Java depending on dataset size. - Sinchenko attributes performance differences to cache effects, memory bandwidth, and CPU behavior rather than an inherent "JVM tax."
- The
AddInt32benchmark showed a larger gap favoring Java, which Sinchenko attributes to a semantic mismatch (Java's wrapping arithmetic vs.arrow-rs's checked arithmetic preventing vectorization). - He argues that the "JVM tax" phrase often misattributes overheads from frameworks like Spark (scheduler, shuffle, spill) or object-per-value data models to the JVM itself.
- The benchmark specifically uses Apache Arrow to ensure a columnar memory layout, avoiding the "object layout tax" or "GC-visible object graph tax."
- Sinchenko highlights JVM benefits like dynamic code loading, cross-platform portability (e.g., Xeon to Graviton), automatic CPU dispatch, memory safety, and a unified operational surface for metrics and debugging.
- The experiment is intentionally narrow, not addressing complexities like Decimals, Strings, Nested types, Hash aggregation/joins, Parquet I/O, or end-to-end query execution.
Decoder
- JVM Tax: A pejorative term implying an inherent performance penalty associated with running code on the Java Virtual Machine compared to native execution.
- Apache Arrow: A language-agnostic columnar memory format for in-memory data processing, designed for high-performance analytical workloads.
- MemorySegment: A Java API from
java.lang.foreignfor accessing contiguous regions of memory outside the Java heap, enabling efficient interaction with native memory. - JDK Vector API: A Java API for performing vectorized computations (SIMD instructions) on arrays of primitive types, improving performance for data-parallel operations.
- JMH (Java Microbenchmark Harness): A Java tool for building, running, and analyzing nano/micro/milli/macro benchmarks written in Java.
- arrow-rs: The official Rust implementation of Apache Arrow.
- Columnar memory layout: A data storage arrangement where all values for a single column are stored contiguously, optimizing for analytical queries.
Original article
Full article content is not available for inline reading.
Explore all 62 articles in today's digest
Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi