Skip to content

Make shared string builders fallible end-to-end with try_* APIs#23223

Open
kosiew wants to merge 10 commits into
apache:mainfrom
kosiew:refactor-byte-accounting-05-22688
Open

Make shared string builders fallible end-to-end with try_* APIs#23223
kosiew wants to merge 10 commits into
apache:mainfrom
kosiew:refactor-byte-accounting-05-22688

Conversation

@kosiew

@kosiew kosiew commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

This change moves the shared string builder infrastructure to fallible try_* APIs so overflow conditions can be propagated as DataFusionError instead of requiring panic-based handling. This provides a consistent error propagation path for downstream UDF migrations while preserving the existing infallible APIs as compatibility wrappers where appropriate.

This PR is preparatory work for migrating downstream string UDFs onto fallible append/write APIs end-to-end. The follow-up work will cover direct row emitters such as chr, uuid, initcap, and substr; helper-driven writers such as overlay, reverse, and translate; the larger split_part migration, including its index-normalization helpers; and output-amplifying functions such as repeat, lpad, and rpad, where oversized output must return DataFusionError rather than panic.

What changes are included in this PR?

  • Add shared helpers for validating StringView length, offset, and buffer index values against Arrow's i32::MAX limits.

  • Introduce fallible try_* methods throughout BulkNullStringArrayBuilder:

    • try_append_value
    • try_append_placeholder
    • try_append_with
    • try_append_byte_map
  • Keep the existing infallible append_* methods as compatibility shims that delegate to the corresponding try_* methods and panic on overflow.

  • Convert GenericStringArrayBuilder::append_with to reuse the fallible implementation instead of duplicating logic.

  • Refactor StringViewArrayBuilder to:

    • validate long-view metadata through shared helpers,
    • add fallible try_append_with and try_append_byte_map,
    • improve spill-path error handling and rollback so intermediate state is restored on failure.
  • Add shared test-only utilities (FailingBulkNullStringArrayBuilder and FailingStringWriter) to support overflow propagation tests in this and downstream modules.

  • Prepare shared string builder APIs for follow-up UDF migrations covering direct append call sites, helper-driven row writers, split_part index handling, and output-amplifying functions such as repeat, lpad, and rpad.

Are these changes tested?

Yes.

This PR adds the following tests:

  • bulk_try_append_methods
  • string_view_builder_try_append_with_and_byte_map_success_path
  • string_view_builder_rejects_long_view_part_overflow
  • failing_bulk_builder_propagates_try_append_errors

It also continues to exercise existing string builder tests.

Are there any user-facing changes?

No user-facing behavior is intended. This is shared internal infrastructure that enables downstream code to propagate overflow errors through fallible APIs while preserving the existing infallible compatibility methods.

LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.

kosiew added 5 commits June 28, 2026 17:37
- Enhanced BulkNullStringArrayBuilder to implement a fallible `try_*` contract.
- Introduced compatibility wrappers for infallible methods.
- Added new methods to StringViewArrayBuilder:
- `try_append_byte_map`
- `try_append_with`
- Implemented fallible long-view part validation and error capture with rollback for the writer.
- Included test-only failing bulk builder and added success + overflow tests to ensure robustness.
- Reused actual conversion error in `write_str` and `write_char`
- Simplified rollback error path in `try_append_with`
- Moved failing test helper types into the tests module
- Deduplicated failing test error via `failing_overflow()`
…for improved test reuse

- Moved FailingStringWriter and FailingBulkNullStringArrayBuilder to allow for downstream crate module tests to reuse them via `crate::strings::FailingBulkNullStringArrayBuilder`.
- Updated visibility to `#[cfg(test)] pub(crate)` in `datafusion/functions/src/strings.rs`.
@github-actions github-actions Bot added the functions Changes to functions implementation label Jun 28, 2026
kosiew added 2 commits June 28, 2026 21:14
- Removed `append_byte_map` and `append_with` from `GenericStringArrayBuilder`
- Removed `append_byte_map` and `append_with` from `StringViewArrayBuilder`
- Retained trait default methods on `BulkNullStringArrayBuilder`
- Updated documentation to fix broken `Self::...` links
@kosiew
kosiew marked this pull request as ready for review June 28, 2026 13:40
@kosiew
kosiew requested a review from alamb July 7, 2026 08:17
@kosiew

kosiew commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@alamb
PTAL
This is a continuation from #23074

@alamb

alamb commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Have we ever seen StringView overflow errors? I think to get them we would need to have individual Strings that are larger than 2GB (overflow an i32)

I thought a far more common issue was to overflow a String/Utf8 array (where the total length of all strings in a single Array can't be over 2GB)

Basically I wonder if it is worth the extra code complexity for a case that doesn't really happen

@alamb

alamb commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

My concern with a refactor like this is that it doesn't slow down performance of the string functions. Can we run the relevant string function benchmarks?

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @kosiew -- I took a brief look and the basic idea looks good (remove the infallable methods) but it seems pretty complicated to me

I would like to know:

  1. Does this change have any performance implications (aka let's run some benchmarks)
  2. Can we make it simpler (or maybe break the PR down into smaller parts)? The delayed error handling for StringWriter seems to be one of the more complicated parts

Perhaps @Omega359 or @neilconway can help review this as I think they wrote a good portion of the initial code

Comment thread datafusion/functions/src/strings.rs Outdated
}

fn try_string_view_part(field: &str, value: usize) -> Result<u32> {
// StringView stores these fields as u32, but Arrow limits lengths,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is unlikely buffer indices will ever overflow a i32 -- that would mean there are 2 billion buffers (not values)

However, I see this is already checked below

/// `None` while the row fits inline; becomes `Some(start)` (offset of
/// the row's first byte in `in_progress`) at first spill.
spill_cursor: Option<usize>,
error: Option<DataFusionError>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this need delayed error handling? It seems like the code would be a lot simpler if the error was returned immediately

If we do need delayed reporting, can we please add a comment about why ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delayed error is needed because the existing StringWriter API has infallible write_str / write_char methods, and try_append_with accepts a closure using that writer.
Once a write overflows, the writer has no Result channel to return through immediately, so it records the first error and try_append_with returns it after the closure finishes, rolling back in_progress to old_len.

Added comment.

Comment thread datafusion/functions/src/strings.rs Outdated
let offset = try_string_view_part("offset", start)?;
let buffer_index =
try_string_view_part("buffer count", self.completed.len())?;
self.views.push(Self::make_long_view_checked(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to me that this is called make_long_view_checked but doesn't seem to return an error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it to make_long_view_from_checked_parts

}

impl StringViewWriter<'_> {
#[inline]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please document in comments what this method is doing (likewise for write_spilled_bytes)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment

kosiew added 2 commits July 8, 2026 17:22
…nd and add BulkNullStringArrayBuilder override

- Restored the fast infallible `GenericStringArrayBuilder::append_with` function.
- Added `BulkNullStringArrayBuilder` override to allow generic hot calls to avoid the `try_append_with` wrapper.
- Kept the existing `try_append_with` method for fallible and rollback-safe operations.
- Removed restored panic fast path in GenericStringArrayBuilder::append_with
- Eliminated trait override that leveraged the removed panic fast path
- Optimized try_append_with:
- Removed rollback branch
- Validates offset using try_offset
- Returns DataFusionError
- Documentation updates to advise discarding builder after an error
@Omega359

Omega359 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

I'll try and take a look at this tomorrow.

@kosiew
kosiew marked this pull request as draft July 8, 2026 13:37
@kosiew

kosiew commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

benchmark results from
cargo bench -p datafusion-functions --bench lower

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query                                                               ┃                    baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ lower_all_values_are_ascii_ 1024                                    │ 0.00 / 0.00 ±0.00 / 0.00 ms │       0.00 / 0.00 ±0.00 / 0.00 ms │  1.02x slower │
│ lower_all_values_are_ascii_ 4096                                    │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │     no change │
│ lower_all_values_are_ascii_ 8192                                    │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10    │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │  1.05x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12    │ 0.10 / 0.10 ±0.00 / 0.10 ms │       0.10 / 0.10 ±0.00 / 0.11 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64    │ 0.09 / 0.09 ±0.00 / 0.10 ms │       0.10 / 0.10 ±0.00 / 0.10 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_2  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │  1.06x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_3  │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_4  │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_5  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_6  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │  1.04x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_7  │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 10_8  │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_2  │ 0.10 / 0.10 ±0.00 / 0.10 ms │       0.10 / 0.10 ±0.00 / 0.10 ms │ +1.01x faster │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_3  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_4  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_5  │ 0.09 / 0.09 ±0.00 / 0.10 ms │       0.09 / 0.09 ±0.00 / 0.10 ms │ +1.04x faster │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_6  │ 0.09 / 0.10 ±0.00 / 0.10 ms │       0.09 / 0.09 ±0.00 / 0.10 ms │ +1.04x faster │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_7  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 12_8  │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_2  │ 0.09 / 0.09 ±0.00 / 0.10 ms │       0.10 / 0.10 ±0.00 / 0.11 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_3  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_4  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_5  │ 0.09 / 0.09 ±0.00 / 0.09 ms │       0.09 / 0.09 ±0.00 / 0.10 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_6  │ 0.09 / 0.09 ±0.00 / 0.09 ms │       0.09 / 0.09 ±0.00 / 0.09 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_7  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 4096, str_len_ 64_8  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10    │ 0.15 / 0.15 ±0.00 / 0.16 ms │       0.16 / 0.16 ±0.00 / 0.16 ms │  1.03x slower │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12    │ 0.22 / 0.22 ±0.00 / 0.23 ms │       0.22 / 0.22 ±0.00 / 0.23 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64    │ 0.21 / 0.21 ±0.00 / 0.21 ms │       0.21 / 0.21 ±0.00 / 0.22 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_2  │ 0.15 / 0.15 ±0.00 / 0.16 ms │       0.16 / 0.16 ±0.00 / 0.16 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_3  │ 0.05 / 0.05 ±0.00 / 0.05 ms │       0.05 / 0.05 ±0.00 / 0.05 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_4  │ 0.05 / 0.05 ±0.00 / 0.05 ms │       0.05 / 0.05 ±0.00 / 0.05 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_5  │ 0.14 / 0.14 ±0.00 / 0.15 ms │       0.14 / 0.14 ±0.00 / 0.15 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_6  │ 0.14 / 0.14 ±0.00 / 0.15 ms │       0.14 / 0.14 ±0.00 / 0.15 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_7  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 10_8  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_2  │ 0.22 / 0.22 ±0.00 / 0.23 ms │       0.22 / 0.22 ±0.00 / 0.23 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_3  │ 0.11 / 0.12 ±0.00 / 0.12 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_4  │ 0.12 / 0.12 ±0.00 / 0.12 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_5  │ 0.21 / 0.21 ±0.00 / 0.22 ms │       0.20 / 0.20 ±0.00 / 0.21 ms │ +1.03x faster │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_6  │ 0.21 / 0.21 ±0.00 / 0.21 ms │       0.20 / 0.20 ±0.00 / 0.21 ms │ +1.03x faster │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_7  │ 0.12 / 0.12 ±0.00 / 0.13 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 12_8  │ 0.12 / 0.12 ±0.00 / 0.12 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_2  │ 0.21 / 0.21 ±0.00 / 0.22 ms │       0.21 / 0.21 ±0.00 / 0.23 ms │  1.02x slower │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_3  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.08 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_4  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_5  │ 0.20 / 0.20 ±0.00 / 0.20 ms │       0.19 / 0.20 ±0.00 / 0.20 ms │ +1.02x faster │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_6  │ 0.20 / 0.20 ±0.00 / 0.21 ms │       0.19 / 0.20 ±0.00 / 0.20 ms │ +1.02x faster │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_7  │ 0.08 / 0.08 ±0.00 / 0.10 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │     no change │
│ lower_all_values_are_ascii_string_views_ size_ 8192, str_len_ 64_8  │ 0.08 / 0.08 ±0.00 / 0.08 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │     no change │
│ lower_sliced_ascii_ parent=65536, slice=128, str_len=32             │ 0.00 / 0.00 ±0.00 / 0.00 ms │       0.00 / 0.00 ±0.00 / 0.00 ms │ +1.01x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len    │ 0.23 / 0.23 ±0.00 / 0.24 ms │       0.24 / 0.24 ±0.00 / 0.24 ms │  1.02x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_2  │ 0.24 / 0.24 ±0.00 / 0.25 ms │       0.24 / 0.24 ±0.00 / 0.25 ms │ +1.01x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_3  │ 0.24 / 0.24 ±0.00 / 0.25 ms │       0.24 / 0.24 ±0.00 / 0.24 ms │ +1.03x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_4  │ 0.24 / 0.24 ±0.00 / 0.25 ms │       0.24 / 0.24 ±0.00 / 0.25 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_5  │ 0.23 / 0.23 ±0.00 / 0.24 ms │       0.24 / 0.24 ±0.00 / 0.24 ms │  1.02x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_6  │ 0.24 / 0.24 ±0.00 / 0.24 ms │       0.23 / 0.23 ±0.00 / 0.24 ms │ +1.01x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_7  │ 0.22 / 0.22 ±0.00 / 0.22 ms │       0.22 / 0.22 ±0.00 / 0.23 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_8  │ 0.22 / 0.22 ±0.00 / 0.23 ms │       0.21 / 0.21 ±0.00 / 0.22 ms │ +1.04x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_9  │ 0.23 / 0.23 ±0.00 / 0.23 ms │       0.23 / 0.23 ±0.00 / 0.23 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_10 │ 0.22 / 0.22 ±0.00 / 0.22 ms │       0.22 / 0.22 ±0.00 / 0.23 ms │  1.01x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_11 │ 0.22 / 0.22 ±0.00 / 0.22 ms │       0.22 / 0.22 ±0.00 / 0.22 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 4096, str_len_12 │ 0.22 / 0.22 ±0.00 / 0.23 ms │       0.21 / 0.21 ±0.00 / 0.21 ms │ +1.04x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len    │ 0.48 / 0.48 ±0.00 / 0.49 ms │       0.47 / 0.47 ±0.00 / 0.48 ms │ +1.01x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_2  │ 0.47 / 0.47 ±0.00 / 0.48 ms │       0.47 / 0.47 ±0.00 / 0.50 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_3  │ 0.47 / 0.47 ±0.00 / 0.47 ms │       0.46 / 0.47 ±0.00 / 0.47 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_4  │ 0.48 / 0.48 ±0.00 / 0.49 ms │       0.47 / 0.47 ±0.00 / 0.47 ms │ +1.02x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_5  │ 0.47 / 0.47 ±0.00 / 0.48 ms │       0.48 / 0.48 ±0.00 / 0.48 ms │  1.02x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_6  │ 0.46 / 0.46 ±0.00 / 0.47 ms │       0.47 / 0.47 ±0.00 / 0.48 ms │  1.02x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_7  │ 0.43 / 0.44 ±0.02 / 0.61 ms │       0.44 / 0.44 ±0.00 / 0.45 ms │  1.01x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_8  │ 0.44 / 0.44 ±0.00 / 0.44 ms │       0.44 / 0.44 ±0.00 / 0.45 ms │  1.01x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_9  │ 0.45 / 0.45 ±0.00 / 0.46 ms │       0.44 / 0.44 ±0.00 / 0.44 ms │ +1.02x faster │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_10 │ 0.43 / 0.43 ±0.00 / 0.44 ms │       0.44 / 0.44 ±0.00 / 0.44 ms │     no change │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_11 │ 0.43 / 0.44 ±0.00 / 0.44 ms │       0.44 / 0.44 ±0.00 / 0.45 ms │  1.02x slower │
│ lower_some_values_are_nonascii_string_views_ size_ 8192, str_len_12 │ 0.44 / 0.44 ±0.00 / 0.45 ms │       0.45 / 0.45 ±0.00 / 0.45 ms │     no change │
│ lower_the_first_value_is_nonascii_ 1024                             │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │  1.01x slower │
│ lower_the_first_value_is_nonascii_ 4096                             │ 0.12 / 0.12 ±0.00 / 0.12 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │     no change │
│ lower_the_first_value_is_nonascii_ 8192                             │ 0.24 / 0.24 ±0.00 / 0.24 ms │       0.24 / 0.24 ±0.00 / 0.24 ms │     no change │
│ lower_the_middle_value_is_nonascii_ 1024                            │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ lower_the_middle_value_is_nonascii_ 4096                            │ 0.12 / 0.13 ±0.02 / 0.22 ms │       0.12 / 0.12 ±0.00 / 0.12 ms │ +1.06x faster │
│ lower_the_middle_value_is_nonascii_ 8192                            │ 0.24 / 0.24 ±0.00 / 0.24 ms │       0.24 / 0.24 ±0.00 / 0.24 ms │     no change │
└─────────────────────────────────────────────────────────────────────┴─────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Benchmark Summary                                ┃         ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ Total Time (baseline)                            │ 13.86ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 13.85ms │
│ Average Time (baseline)                          │  0.17ms │
│ Average Time (refactor-byte-accounting-05-22688) │  0.17ms │
│ Queries Faster                                   │      17 │
│ Queries Slower                                   │      20 │
│ Queries with No Change                           │      45 │
│ Queries with Failure                             │       0 │
└──────────────────────────────────────────────────┴─────────┘

cargo bench -p datafusion-functions --bench upper

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query                        ┃                    baseline ┃ refactor-byte-accounting-05-22688 ┃       Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ upper_all_values_are_ascii   │ 0.00 / 0.00 ±0.00 / 0.00 ms │       0.00 / 0.00 ±0.00 / 0.00 ms │ 1.02x slower │
│ upper_all_values_are_ascii_2 │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │    no change │
│ upper_all_values_are_ascii_3 │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │    no change │
└──────────────────────────────┴─────────────────────────────┴───────────────────────────────────┴──────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Benchmark Summary                                ┃        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│ Total Time (baseline)                            │ 0.02ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 0.02ms │
│ Average Time (baseline)                          │ 0.01ms │
│ Average Time (refactor-byte-accounting-05-22688) │ 0.01ms │
│ Queries Faster                                   │      0 │
│ Queries Slower                                   │      1 │
│ Queries with No Change                           │      2 │
│ Queries with Failure                             │      0 │
└──────────────────────────────────────────────────┴────────┘

cargo bench -p datafusion-functions --bench reverse

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query                                                 ┃                          baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ reverse_StringArray_ascii_str_len_8                   │       0.08 / 0.08 ±0.00 / 0.08 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │ +1.02x faster │
│ reverse_StringArray_ascii_str_len_32                  │       0.11 / 0.11 ±0.00 / 0.11 ms │       0.11 / 0.11 ±0.00 / 0.11 ms │     no change │
│ reverse_StringArray_ascii_str_len_128                 │       0.15 / 0.15 ±0.00 / 0.16 ms │       0.15 / 0.15 ±0.00 / 0.15 ms │     no change │
│ reverse_StringArray_ascii_str_len_4096                │       3.66 / 3.67 ±0.01 / 3.73 ms │       3.67 / 3.69 ±0.01 / 3.78 ms │     no change │
│ reverse_StringArray_utf8_density_0.8_str_len_8        │       0.44 / 0.45 ±0.00 / 0.46 ms │       0.45 / 0.45 ±0.00 / 0.47 ms │     no change │
│ reverse_StringArray_utf8_density_0.8_str_len_32       │       1.39 / 1.40 ±0.00 / 1.42 ms │       1.39 / 1.40 ±0.00 / 1.42 ms │     no change │
│ reverse_StringArray_utf8_density_0.8_str_len_128      │       5.09 / 5.15 ±0.02 / 5.20 ms │       5.08 / 5.13 ±0.02 / 5.21 ms │     no change │
│ reverse_StringArray_utf8_density_0.8_str_len_4096     │ 162.65 / 165.97 ±9.51 / 233.21 ms │ 162.48 / 163.16 ±0.48 / 166.16 ms │ +1.02x faster │
│ reverse_StringViewArray_ascii_str_len_8               │       0.07 / 0.07 ±0.00 / 0.08 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ reverse_StringViewArray_ascii_str_len_32              │       0.11 / 0.11 ±0.00 / 0.11 ms │       0.11 / 0.11 ±0.00 / 0.11 ms │ +1.02x faster │
│ reverse_StringViewArray_ascii_str_len_128             │       0.14 / 0.14 ±0.00 / 0.14 ms │       0.14 / 0.14 ±0.00 / 0.14 ms │     no change │
│ reverse_StringViewArray_ascii_str_len_4096            │       2.78 / 2.80 ±0.02 / 2.94 ms │       2.78 / 2.79 ±0.02 / 2.93 ms │     no change │
│ reverse_StringViewArray_utf8_density_0.8_str_len_8    │       0.45 / 0.46 ±0.02 / 0.58 ms │       0.46 / 0.46 ±0.00 / 0.47 ms │     no change │
│ reverse_StringViewArray_utf8_density_0.8_str_len_32   │       1.39 / 1.40 ±0.00 / 1.42 ms │       1.40 / 1.40 ±0.00 / 1.43 ms │     no change │
│ reverse_StringViewArray_utf8_density_0.8_str_len_128  │       5.07 / 5.08 ±0.01 / 5.12 ms │       5.05 / 5.07 ±0.01 / 5.15 ms │     no change │
│ reverse_StringViewArray_utf8_density_0.8_str_len_4096 │ 160.80 / 161.50 ±0.48 / 164.92 ms │ 160.42 / 161.19 ±0.48 / 163.97 ms │     no change │
└───────────────────────────────────────────────────────┴───────────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                                ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (baseline)                            │ 348.55ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 345.42ms │
│ Average Time (baseline)                          │  21.78ms │
│ Average Time (refactor-byte-accounting-05-22688) │  21.59ms │
│ Queries Faster                                   │        3 │
│ Queries Slower                                   │        0 │
│ Queries with No Change                           │       13 │
│ Queries with Failure                             │        0 │
└──────────────────────────────────────────────────┴──────────┘

cargo bench -p datafusion-functions --bench translate

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query                    ┃                       baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ array_from_to            │    0.92 / 0.92 ±0.00 / 0.92 ms │       0.90 / 0.91 ±0.00 / 0.91 ms │ +1.01x faster │
│ array_from_to            │    3.74 / 3.75 ±0.01 / 3.76 ms │       3.67 / 3.68 ±0.00 / 3.69 ms │ +1.02x faster │
│ array_from_to            │    0.13 / 0.13 ±0.00 / 0.13 ms │       0.12 / 0.12 ±0.00 / 0.13 ms │ +1.02x faster │
│ array_from_to            │    0.53 / 0.53 ±0.00 / 0.53 ms │       0.54 / 0.54 ±0.00 / 0.55 ms │  1.03x slower │
│ array_from_to            │    0.03 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │  1.10x slower │
│ array_from_to            │    0.17 / 0.17 ±0.00 / 0.17 ms │       0.18 / 0.19 ±0.00 / 0.19 ms │  1.10x slower │
│ array_from_to            │    0.02 / 0.02 ±0.00 / 0.02 ms │       0.02 / 0.02 ±0.00 / 0.03 ms │  1.27x slower │
│ array_from_to            │    0.08 / 0.08 ±0.00 / 0.08 ms │       0.10 / 0.10 ±0.00 / 0.10 ms │  1.25x slower │
│ array_from_to_non_ascii  │    6.62 / 6.64 ±0.01 / 6.65 ms │       6.54 / 6.55 ±0.01 / 6.57 ms │ +1.01x faster │
│ array_from_to_non_ascii  │ 26.40 / 26.59 ±0.10 / 26.74 ms │    26.12 / 26.24 ±0.09 / 26.39 ms │ +1.01x faster │
│ array_from_to_non_ascii  │    0.85 / 0.85 ±0.00 / 0.85 ms │       0.84 / 0.85 ±0.00 / 0.85 ms │     no change │
│ array_from_to_non_ascii  │    3.43 / 3.43 ±0.01 / 3.47 ms │       3.38 / 3.39 ±0.01 / 3.40 ms │ +1.01x faster │
│ array_from_to_non_ascii  │    0.23 / 0.23 ±0.00 / 0.23 ms │       0.23 / 0.23 ±0.00 / 0.23 ms │     no change │
│ array_from_to_non_ascii  │    0.96 / 0.96 ±0.00 / 0.96 ms │       0.95 / 0.96 ±0.00 / 0.96 ms │     no change │
│ array_from_to_non_ascii  │    0.08 / 0.08 ±0.00 / 0.08 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │     no change │
│ array_from_to_non_ascii  │    0.34 / 0.34 ±0.00 / 0.34 ms │       0.34 / 0.34 ±0.00 / 0.34 ms │     no change │
│ scalar_from_to           │    0.42 / 0.42 ±0.00 / 0.42 ms │       0.42 / 0.42 ±0.00 / 0.42 ms │     no change │
│ scalar_from_to           │    1.70 / 1.70 ±0.00 / 1.70 ms │       1.70 / 1.70 ±0.01 / 1.74 ms │     no change │
│ scalar_from_to           │    0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │     no change │
│ scalar_from_to           │    0.25 / 0.25 ±0.00 / 0.25 ms │       0.25 / 0.25 ±0.00 / 0.25 ms │     no change │
│ scalar_from_to           │    0.02 / 0.02 ±0.00 / 0.02 ms │       0.02 / 0.02 ±0.00 / 0.02 ms │     no change │
│ scalar_from_to           │    0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ scalar_from_to           │    0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │     no change │
│ scalar_from_to           │    0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
└──────────────────────────┴────────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
┃ Benchmark Summary                                ┃         ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
│ Total Time (baseline)                            │ 47.31ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 46.80ms │
│ Average Time (baseline)                          │  1.97ms │
│ Average Time (refactor-byte-accounting-05-22688) │  1.95ms │
│ Queries Faster                                   │       6 │
│ Queries Slower                                   │       5 │
│ Queries with No Change                           │      13 │
│ Queries with Failure                             │       0 │
└──────────────────────────────────────────────────┴─────────┘

cargo bench -p datafusion-functions --bench replace

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query                        ┃                    baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ replace_string               │ 0.05 / 0.05 ±0.00 / 0.05 ms │       0.05 / 0.05 ±0.00 / 0.05 ms │ +1.02x faster │
│ replace_string               │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │ +1.04x faster │
│ replace_string               │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ replace_string               │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ replace_string               │ 0.23 / 0.23 ±0.00 / 0.23 ms │       0.23 / 0.23 ±0.00 / 0.23 ms │     no change │
│ replace_string               │ 0.28 / 0.28 ±0.00 / 0.29 ms │       0.27 / 0.28 ±0.00 / 0.28 ms │ +1.02x faster │
│ replace_string               │ 0.11 / 0.11 ±0.00 / 0.11 ms │       0.11 / 0.11 ±0.01 / 0.14 ms │  1.02x slower │
│ replace_string               │ 0.13 / 0.13 ±0.00 / 0.13 ms │       0.13 / 0.13 ±0.00 / 0.13 ms │     no change │
│ replace_string_ascii_single  │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │     no change │
│ replace_string_ascii_single  │ 0.01 / 0.01 ±0.00 / 0.01 ms │       0.01 / 0.01 ±0.00 / 0.01 ms │ +1.01x faster │
│ replace_string_ascii_single  │ 0.02 / 0.02 ±0.00 / 0.02 ms │       0.02 / 0.02 ±0.00 / 0.02 ms │     no change │
│ replace_string_ascii_single  │ 0.02 / 0.02 ±0.00 / 0.02 ms │       0.02 / 0.02 ±0.00 / 0.02 ms │     no change │
│ replace_string_ascii_single  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ replace_string_ascii_single  │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │     no change │
│ replace_string_ascii_single  │ 0.07 / 0.07 ±0.00 / 0.07 ms │       0.07 / 0.07 ±0.00 / 0.07 ms │     no change │
│ replace_string_ascii_single  │ 0.08 / 0.08 ±0.00 / 0.08 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │     no change │
│ replace_string_view          │ 0.05 / 0.05 ±0.00 / 0.05 ms │       0.05 / 0.05 ±0.00 / 0.05 ms │ +1.03x faster │
│ replace_string_view          │ 0.06 / 0.06 ±0.00 / 0.06 ms │       0.06 / 0.06 ±0.00 / 0.06 ms │ +1.02x faster │
│ replace_string_view          │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ replace_string_view          │ 0.03 / 0.03 ±0.00 / 0.04 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ replace_string_view          │ 0.23 / 0.23 ±0.00 / 0.23 ms │       0.23 / 0.23 ±0.00 / 0.24 ms │     no change │
│ replace_string_view          │ 0.28 / 0.28 ±0.00 / 0.29 ms │       0.28 / 0.28 ±0.00 / 0.28 ms │     no change │
│ replace_string_view          │ 0.11 / 0.11 ±0.00 / 0.11 ms │       0.11 / 0.11 ±0.00 / 0.11 ms │     no change │
│ replace_string_view          │ 0.13 / 0.13 ±0.00 / 0.13 ms │       0.13 / 0.13 ±0.00 / 0.13 ms │     no change │
└──────────────────────────────┴─────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Benchmark Summary                                ┃        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│ Total Time (baseline)                            │ 2.16ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 2.15ms │
│ Average Time (baseline)                          │ 0.09ms │
│ Average Time (refactor-byte-accounting-05-22688) │ 0.09ms │
│ Queries Faster                                   │      6 │
│ Queries Slower                                   │      1 │
│ Queries with No Change                           │     17 │
│ Queries with Failure                             │      0 │
└──────────────────────────────────────────────────┴────────┘

cargo bench -p datafusion-functions --bench concat

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query  ┃                    baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ 1024   │ 0.02 / 0.02 ±0.00 / 0.02 ms │       0.02 / 0.02 ±0.00 / 0.02 ms │  1.04x slower │
│ 1024   │ 0.04 / 0.04 ±0.00 / 0.04 ms │       0.04 / 0.04 ±0.00 / 0.04 ms │  1.02x slower │
│ 4096   │ 0.08 / 0.08 ±0.00 / 0.09 ms │       0.08 / 0.08 ±0.00 / 0.08 ms │  1.03x slower │
│ 4096   │ 0.17 / 0.17 ±0.00 / 0.17 ms │       0.17 / 0.17 ±0.02 / 0.28 ms │  1.04x slower │
│ 8192   │ 0.16 / 0.16 ±0.00 / 0.16 ms │       0.16 / 0.16 ±0.00 / 0.16 ms │  1.03x slower │
│ 8192   │ 0.34 / 0.37 ±0.06 / 0.60 ms │       0.34 / 0.35 ±0.00 / 0.35 ms │ +1.07x faster │
│ scalar │ 0.00 / 0.00 ±0.00 / 0.00 ms │       0.00 / 0.00 ±0.00 / 0.00 ms │  1.02x slower │
└────────┴─────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Benchmark Summary                                ┃        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│ Total Time (baseline)                            │ 0.83ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 0.82ms │
│ Average Time (baseline)                          │ 0.12ms │
│ Average Time (refactor-byte-accounting-05-22688) │ 0.12ms │
│ Queries Faster                                   │      1 │
│ Queries Slower                                   │      6 │
│ Queries with No Change                           │      0 │
│ Queries with Failure                             │      0 │
└──────────────────────────────────────────────────┴────────┘

cargo bench -p datafusion-functions --bench concat_ws

Comparing baseline and refactor-byte-accounting-05-22688
--------------------
Benchmark criterion
--------------------
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query  ┃                    baseline ┃ refactor-byte-accounting-05-22688 ┃        Change ┃
┡━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ 1024   │ 0.03 / 0.03 ±0.00 / 0.03 ms │       0.03 / 0.03 ±0.00 / 0.03 ms │     no change │
│ 4096   │ 0.11 / 0.11 ±0.00 / 0.11 ms │       0.10 / 0.11 ±0.00 / 0.11 ms │ +1.01x faster │
│ 8192   │ 0.21 / 0.21 ±0.00 / 0.22 ms │       0.21 / 0.21 ±0.00 / 0.22 ms │     no change │
│ scalar │ 0.00 / 0.00 ±0.00 / 0.00 ms │       0.00 / 0.00 ±0.00 / 0.00 ms │     no change │
└────────┴─────────────────────────────┴───────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┓
┃ Benchmark Summary                                ┃        ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━┩
│ Total Time (baseline)                            │ 0.35ms │
│ Total Time (refactor-byte-accounting-05-22688)   │ 0.35ms │
│ Average Time (baseline)                          │ 0.09ms │
│ Average Time (refactor-byte-accounting-05-22688) │ 0.09ms │
│ Queries Faster                                   │      1 │
│ Queries Slower                                   │      0 │
│ Queries with No Change                           │      3 │
│ Queries with Failure                             │      0 │
└──────────────────────────────────────────────────┴────────┘

@Omega359

Omega359 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

│ array_from_to │ 0.02 / 0.02 ±0.00 / 0.02 ms │ 0.02 / 0.02 ±0.00 / 0.03 ms │ 1.27x slower │
│ array_from_to │ 0.08 / 0.08 ±0.00 / 0.08 ms │ 0.10 / 0.10 ±0.00 / 0.10 ms │ 1.25x slower │

hmm.

- Clarified `try_string_view_part` buffer-index guard
- Enhanced documentation for `StringView` overflow
- Renamed `make_long_view_checked` to `make_long_view_from_checked_parts`
- Added comments for delayed `StringViewWriter` error handling
- Documented `fail` method
- Documented `write_spilled_bytes` method
@kosiew

kosiew commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Have we ever seen StringView overflow errors?

I agree these StringView overflows are much less common than normal Utf8 offset overflow. For StringView, the practical cases are huge individual/incrementally-written values or invalid long-view parts; total array bytes can be split across buffers, so this is not the common “total Utf8 array >2GB” case.

I think keeping fallible StringView paths is reasonable because the shared BulkNullStringArrayBuilder contract is being made fallible end-to-end.
Without this, downstream UDF migrations using try_append_with / try_append_byte_map would still need local special cases for StringView, or would retain panic paths from the old expect calls.

@kosiew
kosiew marked this pull request as ready for review July 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants