L. C. Hsieh created SPARK-57024:
-----------------------------------

             Summary: Use bulk fill APIs to materialize RLE runs in Parquet 
vectorized reader
                 Key: SPARK-57024
                 URL: https://issues.apache.org/jira/browse/SPARK-57024
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 4.3.0
            Reporter: L. C. Hsieh


`VectorizedRleValuesReader` materializes RLE runs of nulls and definition
levels with degenerate per-element loops:

  // VectorizedRleValuesReader.java
  for (int k = 0; k < runLen; k++) {
    nulls.putNull(valueOff + k);
  }
  for (int k = 0; k < runLen; k++) {
    defLevels.putInt(levelIdx + k, runValue);
  }

`WritableColumnVector` already exposes the bulk equivalents
`putNulls(rowId, count)` and `putInts(rowId, count, value)`. Switching the
callers to these bulk APIs lets the implementations use intrinsics — but
the bulk implementations themselves were also degenerate byte-by-byte
loops, so the win only materializes once both sides are fixed:

  - `OnHeapColumnVector.putNulls` -> `Arrays.fill(byte[], ..., (byte) 1)`
  - `OnHeapColumnVector.putInts(rowId, count, value)`
        -> `Arrays.fill(int[], ..., value)`
  - `OffHeapColumnVector.putNulls` -> `Platform.setMemory(addr, (byte) 1, 
count)`

`Arrays.fill` is a JIT intrinsic backed by `_jbyte_fill` / `_jint_fill`
stubs, and `Unsafe.setMemory` lowers to a native memset; both are
significantly faster than the unrolled-by-JIT byte/int loops they replace
for run lengths above a handful of elements.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to