NVIDIA / NVIDIA/cudf

[FEA] Unify `cudf::structs::detail::flatten_nested_columns` and `cudf::experimental::decompose_structs` to improve performance for structs comparison

Open
#13,032 3 comments 0 reactions 0 assignees View on GitHub
0 - Backlog libcudf Performance proposal
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

For comparing structs column, both the legacy row comparators and the new experimental row comparators rely on struct flattening procedures. Each of them have their own flattening mechanism: `cudf::structs::detail::flatten_nested_columns` and `cudf::experimental::decompose_structs`. The difference between them are:
* `cudf::structs::detail::flatten_nested_columns` replaces the input structs column with an optional column generated by materializing the input null mask.
* `cudf::experimental::decompose_structs` doesn't materialize any new column. Instead, it replaces the input structs column with a modified version of it, which only has either zero or one child at the innermost level.

Although these APIs produce different output, these APIs do very similar job:
* Both extract the input structs column into a table of children columns, which are much simpler than the input structs column to be compared on device code.
* Both replace the input by a new column, and this new column is mainly used for checking nulls.

The issue of each from these approaches are:
* `cudf::structs::detail::flatten_nested_columns` needs to materialize null mask of the input column into a real column.
* `cudf::experimental::decompose_structs` still has a nested structs column in the output. Although that column only has zero or one child at the innermost level, it still causes performance degradation if its nested level is very high.

As such, we can unify the two approaches, taking the pros of both while eliminating the cons. The new flattening API should:
* Avoid materializing new columns, and
* Avoid output columns having more than one nested level.

This seems to be very straightforward with modifying the existing `cudf::experimental::decompose_structs` API.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.