Dict: gather dictionary values straight into a VarBinBuilder - #9098
Dict: gather dictionary values straight into a VarBinBuilder#9098robert3005 wants to merge 4 commits into
Conversation
91142df to
c82aa58
Compare
Merging this PR will improve performance by 10.35%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
c82aa58 to
e3cd801
Compare
| /// | ||
| /// This is a handful of enum discriminant checks over the array's buffer handles, so it stays | ||
| /// outside the per-row loop and costs nothing measurable on the host-resident path. | ||
| fn varbin_fast_path_is_host(codes: &PrimitiveArray, values: &VarBinViewArray) -> bool { |
There was a problem hiding this comment.
we don't care about this check, it's guarded elsewhere
| /// | ||
| /// A code pointing at a null dictionary entry produces a null row, matching what | ||
| /// [`take_canonical`] derives from [`Validity::take`](crate::validity::Validity::take). | ||
| fn dict_validity<C: IntegerPType>( |
There was a problem hiding this comment.
this is just the validity of the array
Appending a string dictionary to a builder went through `take_canonical`, which first materializes the values at full logical length — allocating and re-reading a views buffer proportional to the row count. The dictionary is usually far smaller than the column, so resolving each code against it in place skips that intermediate and leaves one `memcpy` per row. The fast path indexes the codes and the dictionary's views and data buffers as host slices, so `varbin_fast_path_is_host` gates it on residency; a device-resident dictionary still takes the canonical route, where a device kernel can serve it. Signed-off-by: Robert Kruszewski <robert@spiraldb.com> Signed-off-by: Robert Kruszewski <github@robertk.io>
ef964a6 to
bc69d12
Compare
| /// than the column, so resolving each code against it in place skips that intermediate entirely | ||
| /// and leaves one `memcpy` per row as the only work. | ||
| /// | ||
| /// The caller must have checked [`varbin_fast_path_is_host`]; this function indexes the backing |
There was a problem hiding this comment.
does this still exist? Without asserting this we would panic for arrays with device buffers below
Materialize dictionary values straight into VarBinBuilder instead of copying