Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2837,6 +2837,9 @@ function(build_simdjson)

prepare_fetchcontent()

# Keep simdjson's threading configuration consistent with Arrow's,
# which is required for Emscripten where Arrow threading is disabled.
set(SIMDJSON_ENABLE_THREADS ${ARROW_ENABLE_THREADING})
Comment thread
Reranko05 marked this conversation as resolved.
Comment on lines +2840 to +2842

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.

https://github.com/simdjson/simdjson/blob/master/doc/iterate_many.md

Thread support is only active if thread supported is detected in which case the macro SIMDJSON_THREADS_ENABLED is set. You can also manually pass SIMDJSON_THREADS_ENABLED=1 flag to the library. Otherwise the library runs in single-thread mode.

Note the code section for this auto-detection:

// Is threading enabled?
#if defined(_REENTRANT) || defined(_MT)
#ifndef SIMDJSON_THREADS_ENABLED
#define SIMDJSON_THREADS_ENABLED
#endif
#endif

So even if we do not set the cmake option SIMDJSON_ENABLE_THREADS, we can still get threading enabled

# simdjson enables precompiled headers unconditionally.
# Recompiling simdjson.cpp against it produces differing artifacts
# Disable precompiled headers to avoid reproducible build failures.
Expand Down
13 changes: 2 additions & 11 deletions cpp/src/arrow/json/chunker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ namespace arrow {
namespace json {
namespace {

// XXX We could try to SIMD-accelerate this routine but it's called only
// once per chunk and also will presumably examine a minimal amount of bytes.
int64_t ConsumeWhitespace(std::string_view view) {
const auto ws_count = view.find_first_not_of(" \t\r\n");
if (ws_count == std::string_view::npos) {
return view.size();
}
return static_cast<int64_t>(ws_count);
}

// A BoundaryFinder implementation that assumes JSON objects can contain raw newlines,
// and uses the structural indexes computed by simdjson to delimit them.
class ParsingBoundaryFinder : public BoundaryFinder {
Expand Down Expand Up @@ -151,7 +141,8 @@ class ParsingBoundaryFinder : public BoundaryFinder {
if (consumed_length > 0) {
// If we found at least one document, also consume its trailing whitespace
// to avoid stray bytes at the end of the stream.
consumed_length += ConsumeWhitespace(input.substr(consumed_length));
consumed_length += internal::ConsumeJsonWhitespace(input.substr(consumed_length),
/*trailing=*/false);
}
return consumed_length;
}
Expand Down
Loading
Loading