[C++] Allocate input buffers with sufficient capacity for SIMDJSON padding
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: https://github.com/apache/arrow/pull/51038#discussion_r4069610985
Component(s)
C++
Wait for #51038 to be merged before working on this, if someone wants to contribute.
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.
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.
My following comment on a previous PR might also be relevant: https://github.com/apache/arrow/pull/50945#discussion_r3978794379
simdjson::padded_input will provide a (possibly) copy-free version, but it is not yet in a released version:
https://github.com/simdjson/simdjson/commit/85cadf4074b78c7dfa7dabe89bef373b84cf0ba6
@pitrou Updated the title and desc, is this fine now?
Ah, this reframing makes my previous comment mostly obsolete, as it is about allocating sufficiently large buffer sizes in the first place
simdjson::padded_inputwill 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.