← Back to Pull requests

Backport #25122: [FEA] Replace Ambiguous char-span with `mutable_string_view` #25597

Merged
paul-aiyedun merged 16 files (254 lines) on Dec 01, 2026 17:42 UTC
View on GitHub
paul-aiyedun paul-aiyedun commented on Dec 01, 2026 02:13 UTC
Author

Description


Backport of https://github.com/NVIDIA/cudf/pull/25122. Required for backporting https://github.com/NVIDIA/cudf/pull/25421 and https://github.com/NVIDIA/cudf/pull/25384.

Checklist


  • I am familiar with the Contributing Guidelines.

  • New or existing tests cover these changes.

  • The documentation is up to date with these changes.
  • Diff: 254 lines (+209 / -45) across 16 files Reviewer: vyasr Review duration: 929m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.65) × (1 − Review Confidence (0.69)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 254 lines diff across 16 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.58 · 4 substantive comment(s)
    0.58
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    69%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.332
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    5 items
    paul-aiyedun paul-aiyedun commented on code on Dec 01, 2026 02:24 UTC
    Code Review
    cpp/include/cudf/column/column_device_view_base.cuh:1
    @@ -862,7 +862,7 @@ class alignas(16) mutable_column_device_view_core : public detail::column_device
        * @param value The value to assign
        */
       template <typename T,
    -            CUDF_ENABLE_IF(cuda::std::same_as<cuda::std::remove_cv_t<T>, cuda::std::span<char>>)>
    +            CUDF_ENABLE_IF(cuda::std::same_as<cuda::std::remove_cv_t<T>, mutable_string_view>)>

    Conflict resolution was required here. The main branch has

    template <typename T>
      requires(cuda::std::same_as<cuda::std::remove_cv_t<T>, mutable_string_view>)
    

    paul-aiyedun paul-aiyedun commented on code on Dec 01, 2026 02:25 UTC
    Code Review
    cpp/include/cudf/column/column_device_view_base.cuh:1
    @@ -777,20 +777,20 @@ class alignas(16) mutable_column_device_view_core : public detail::column_device
        *
        * The column offset is applied. The element must be valid, and mutations must stay
        * within the existing string's byte range.
    -   * @tparam T `cuda::std::span<char>`
    +   * @tparam T `mutable_string_view`
        * @param element_index Position of the desired string element
        * @return A mutable view of the string's preallocated character storage
        */
       template <typename T,
    -            CUDF_ENABLE_IF(cuda::std::same_as<cuda::std::remove_cv_t<T>, cuda::std::span<char>>)>
    +            CUDF_ENABLE_IF(cuda::std::same_as<cuda::std::remove_cv_t<T>, mutable_string_view>)>

    Conflict resolution was required here. The main branch has

    template <cudf::concepts::mutable_string_view T>
    

    coderabbitai[bot] coderabbitai[bot] commented on Dec 01, 2026 02:28 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    <a href="https://app.coderabbit.ai/change-stack/NVIDIA/cudf/pull/25597?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Summary</strong></summary>
    <dl>
    <dd>
    <br>

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    New Features
    Added a mutable string view for working with existing device-backed string data, with access to its character buffer and byte length.
    String transforms can now write into preallocated output buffers using the mutable view, including URL component outputs.
    Added support for copying strings into preallocated output buffers, with coverage for empty and multibyte strings.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->
    The PR adds cudf::mutable_string_view and replaces cuda::std::span<char> in mutable string output paths. It updates device access, JIT reflection, URL transform examples, and transform tests. It also adds a copy fragment and an LTO test for preallocated string offsets.

    Changes: Mutable String Output

    |Layer / File(s)|Summary|
    |:---|:---|
    |Mutable string view contract <br> cpp/include/cudf/strings/mutable_string_view.hpp, cpp/include/cudf/types.hpp, cpp/include/cudf/utilities/concepts.hpp, cpp/include/cudf/strings/string_view.hpp, cpp/src/strings/strings_column_view.cpp|Adds the non-owning mutable_string_view type, its concept, and its forward declaration. Makes UNKNOWN_STRING_LENGTH public and checks that the mutable and immutable view types have equal size.|
    |Device and JIT output handling <br> cpp/include/cudf/column/column_device_view_base.cuh, cpp/src/jit/column_accessor.cuh, cpp/src/jit/reflect.cpp, cpp/CMakeLists.txt, cpp/include/cudf/transform.hpp|Device access and JIT reflection use mutable_string_view for mutable string outputs. Fragment precompilation and transform documentation use the same type.|
    |URL transform example <br> cpp/examples/string_transforms/url_logs/fragments.cu, cpp/examples/string_transforms/url_logs/transforms.cpp|URL component-writing functions accept mutable_string_view output buffers. Parsing and component-copy behavior remain unchanged.|
    |Transform integration and LTO validation <br> cpp/tests/CMakeLists.txt, cpp/tests/transform/fragments/copy_string.cu, cpp/tests/transform/integration/unary_transform_test.cpp, cpp/tests/transform/transform_lto_test.cpp|Adds a string-copy fragment and an LTO test with preallocated offsets. Existing transform UDF output parameters change to mutable_string_view.|

    <!-- change_assessment_start -->
    Estimated code review effort: 3 (Moderate) | ~20 minutes

    <!-- change_assessment_commit:"05ec027b0a19b0d3c7cde67741c6fcc35e628f99" -->
    <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
    Change: Refactor
    <!-- change_assessment_end -->

    Suggested reviewers: lamarrr

    </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>05ec0</code></summary>
    <dl>
    <dd>
    <br>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to 05ec0
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"05ec027b0a19b0d3c7cde67741c6fcc35e628f99","coveredCommitId":"05ec027b0a19b0d3c7cde67741c6fcc35e628f99","kind":"reviewed"} -->

    This change swaps the ambiguous character-span type for a clearer mutable string view in preallocated string outputs for transforms. The removed span type was only present in unreleased development code, so no released user code is affected. No concrete defect remains. Apply the category and breaking labels the label check asks for before merging.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Security architecture risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>05ec0</code></summary>
    <dl>
    <dd>
    <br>

    <!-- architecture_review_start -->
    <!-- architecture_review_label

    Security Architecture Review

    Security architecture risk: 🔵 Low · up to 05ec0
    -->

    Applications that use preallocated string outputs need to update their transform functions and rebuild compiled fragments for this release. The change keeps writes in the existing output storage, but it also changes how the byte count is represented for very large individual outputs.

    Retained concerns

  • Trivial · architecture · observed: The replacement is not source-compatible with span-based UDF signatures. Bundled fragments move to the new type together, but independently supplied fragments must be rebuilt against the matching contract for upgrade or rollback. The existing LTO path links supplied binaries under the same transform symbol; rejection of a stale binary before execution was not established.

  • Trivial · security · inferred: The new accessor narrows the difference between adjacent offsets to a signed 32-bit byte count. If an individual row larger than that range reaches the accessor, a UDF can receive a byte count that does not describe the allocated row, undermining its ability to bound writes correctly. The inspected path accepts 64-bit offsets, but whether the column factory rejects oversized individual rows before launch remains unverified.
  • View findings in the submitted review

    <details>
    <summary><strong>Security review details</strong></summary>
    <dl>
    <dd>
    <br>

    Security Blast Radius

  • _inferred_ — The changed write path is reachable by callers that select preallocated string offsets or directly use the mutable device accessor. The type replacement does not itself grant the UDF access to a new allocation: both versions derive the output pointer from the same character buffer and row offset.
  • Trust Boundaries and Controls

  • _observed_ — The LTO boundary already accepts caller-supplied device code. The public contract requires ABI-conforming code, and the inspected path links that code with the transform kernel before launch. The new view is a data contract, not a sandbox or a write-boundary enforcement mechanism.
  • Hardening Proposals

  • _proposed_ — Make the per-row byte-count limit explicit and enforce it before dispatch, or preserve a byte-count type wide enough for every accepted row. Document the fragment rebuild requirement for both upgrade and rollback.
  • </dd>
    </dl>
    </details>
    <!-- architecture_review_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
    <dl>
    <dd>
    <br>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Title check | !Passed | The title names the main change: the backport of #25122, which replaces ambiguous cuda::std::span<char> uses with cudf::mutable_string_view. The changeset adds mutable_string_view.hpp, updates column_… |
    | Description check | !Passed | The description states that the PR backports upstream #25122, and it names the dependent PRs #25421 and #25384. This relates to the changeset, which replaces span<char> with mutable_string_view across… |
    | Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
    | Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |

    <details>
    <summary><strong>Full details: Title check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The title names the main change: the backport of #25122, which replaces ambiguous cuda::std::span&lt;char&gt; uses with cudf::mutable_string_view. The changeset adds mutable_string_view.hpp, updates column_device_view_base.cuh, the JIT reflection, the transform fragments, and the examples to use it. The title is specific and accurate, and it identifies the upstream PR.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Description check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The description states that the PR backports upstream #25122, and it names the dependent PRs #25421 and #25384. This relates to the changeset, which replaces span&lt;char&gt; with mutable_string_view across the codebase. The description is brief but relevant.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary><strong>Finishing Touches</strong></summary>
    <dl>
    <dd>
    <br>

    <details open>
    <summary><strong>Generate unit tests (beta)</strong></summary>
    <dl>
    <dd>
    <br>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>

    <!-- finishing_touch_suggestion:fix_ci -->
    <details open>
    <summary><strong>Fix failing CI checks</strong></summary>
    <dl>
    <dd>
    <br>

  • <!-- {"checkboxId": "6d21cfe8-ec3f-40e2-9222-b8318b64d3b0", "radioGroupId": "fix-ci-output-choice-group-unknown_comment_id"} --> Create a new PR
  • </dd>
    </dl>
    </details>
    </dd>
    </dl>
    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->

    paul-aiyedun paul-aiyedun commented on Dec 01, 2026 02:35 UTC
    Author

    pre-commit.ci run

    Reviewers
    Assignees
    paul-aiyedun paul-aiyedun
    Labels
    risk: low confidence: 69.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 64.7% (MEDIUM) · Higher = larger blast radius
    64.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 69.2% · Lower = rushed or shallow review
    69.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.9% · Safe to merge
    19.9%
    Repository