Skip to content

[C++] Allocate input buffers with sufficient capacity for SIMDJSON padding #51463

Open

Description

@Reranko05

Describe the enhancement requested

Parse currently creates a simdjson::padded_string when the input buffer does not have enough capacity for SIMDJSON's required padding. This requires copying the input buffer.

simdjson::padded_string padded_json(reinterpret_cast<const char*>(json->data()),
                                    json->size());
return parse(padded_json);

Investigate whether we can allocate input buffers with enough capacity initially so that this copy can be avoided.

Context: #51038 (comment)

Component(s)

C++

Activity

  1. Reranko05 commented on Sep 22, 2026

    @Reranko05
    CollaboratorAuthor

    Wait for #51038 to be merged before working on this, if someone wants to contribute.

  2. pitrou commented on Sep 23, 2026

    @pitrou
    Member

    I don't think this frames the question correctly. If there is not enough padding in the buffer capacity, then we must copy.

    The question is whether we can ensure that we allocate the buffer with enough padding initially, to avoid having to copy later.

  3. pitrou commented on Sep 23, 2026

    @pitrou
    Member

    A related question is what happens statistically in real usage. For example, take some real-world JSONL file(s), and determine whether most buffers have enough padding when reading it from Arrow, or not.

  4. taepper commented on Sep 23, 2026

    @taepper
    Contributor

    My following comment on a previous PR might also be relevant:
    #50945 (comment)

    simdjson::padded_input will provide a (possibly) copy-free version, but it is not yet in a released version:

    simdjson/simdjson@85cadf4

  5. changed the title [-][C++] Avoid copying input buffer when SIMDJSON padding is unavailable[/-] [+][C++] Allocate input buffers with sufficient capacity for SIMDJSON padding[/+] on Sep 23, 2026
  6. Reranko05 commented on Sep 23, 2026

    @Reranko05
    CollaboratorAuthor

    @pitrou Updated the title and desc, is this fine now?

  7. taepper commented on Sep 23, 2026

    @taepper
    Contributor

    Ah, this reframing makes my previous comment mostly obsolete, as it is about allocating sufficiently large buffer sizes in the first place

  8. pitrou commented on Sep 23, 2026

    @pitrou
    Member

    simdjson::padded_input will provide a (possibly) copy-free version, but it is not yet in a released version:

    I wonder how that will interact with AdressSanitizer or Valgrind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions