NVIDIA / NVIDIA/cudf

[FEA] Optimize variant extraction kernels by packing optional<size_type>/op_status return values into a single 64-bit int

Open
#23,656 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Is your feature request related to a problem? Please describe.**

Several `__device__` helpers in `cpp/src/io/parquet/experimental/variant_extract.cu` (e.g. `find_key_in_metadata`, defined in `variant_extract.cu` on line 234) return `cuda::std::pair, op_status>`. `cuda::std::optional` uses 8 bytes to hold a 4-byte payload plus a 1-bit validity flag, and pairing it with a 1-byte op_status adds further padding. In a register-pressure-sensitive device kernel that runs per-row over potentially large batches, there is a potential that this representation of data could result in worse occupancy.

**Describe the solution you'd like**

Investigate whether encoding `(value, valid, op_status)` into a single packed 64-bit integer would reduce register usage and improve occupancy for these kernels.

So encode would be:
```
val | (op_status << 33) | (valid << 32)
```
And decode would be:
```
val = packed & 0xFFFFFFFF;
valid = (packed >> 32) & 0x1;
op_status = (packed >> 33) & 0xFF;
```

We would apply this consistently across all the different functions that have this potential issue (`find_key_in_metadata`, `locate_object_field`, `locate_array_element`, `resolve_path`, etc.)

**Describe alternatives you've considered**

We could leave the current optimal/pair-based encoding as-is, depending on whether these functions show a register occupancy bottleneck when profiled.

**Additional context**

Raised during review of https://github.com/NVIDIA/cudf/pull/23560. The comment where this is addressed is https://github.com/NVIDIA/cudf/pull/23560#discussion_r3774329203.

Contributor guide

Open the contributing guide

Research direction

Start in cpp/src/io/parquet/experimental/variant_extract.cu, reading find_key_in_metadata, locate_object_field, locate_array_element, and resolve_path. Profile the relevant device kernels to determine whether the current pair-based return representation creates register or occupancy pressure. Done means applying the packed representation consistently if profiling shows a benefit, or documenting that the current encoding should remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.