Skip to content

GH-50654: [C++] Support simdjson without exceptions - #50672

Merged
kou merged 1 commit into
apache:mainfrom
Reranko05:gh-50654-excep-off
Jul 30, 2026
Merged

GH-50654: [C++] Support simdjson without exceptions#50672
kou merged 1 commit into
apache:mainfrom
Reranko05:gh-50654-excep-off

Conversation

@Reranko05

@Reranko05Reranko05 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

This change enables building Arrow with SIMDJSON_EXCEPTIONS=0 by updating the JSON object parser to use simdjson's non-throwing API.

What changes are included?

  • Enable SIMDJSON_EXCEPTIONS=0 for the bundled simdjson dependency.
  • Replace uses of simdjson_result::value() in ObjectParser with the non-throwing get() API.
  • Preserve existing error handling by returning Arrow Status values on simdjson errors.

Are these changes tested?

Yes.

Fixes: #50654

@Reranko05
Reranko05 requested a review from pitrou as a code ownerJuly 28, 2026 03:38
CopilotAI review requested due to automatic review settings July 28, 2026 03:38

CopilotAI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Reranko05 commented Jul 28, 2026

Copy link
Copy Markdown
CollaboratorAuthor

@kou@rok Could you review this when you have time? Thanks!

Comment threadcpp/src/arrow/json/object_parser.cc Outdated
@github-actionsgithub-actionsBot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Jul 28, 2026
CopilotAI review requested due to automatic review settings July 28, 2026 06:40

CopilotAI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actionsgithub-actionsBot added awaiting change review Awaiting change review awaiting changes Awaiting changes and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jul 28, 2026
@Reranko05
Reranko05 requested a review from kouJuly 28, 2026 07:15
Comment threadcpp/src/arrow/json/object_parser.cc Outdated
kou
kou approved these changes Jul 28, 2026

@koukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

CopilotAI review requested due to automatic review settings July 28, 2026 08:41

CopilotAI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actionsgithub-actionsBot added awaiting change review Awaiting change review awaiting merge Awaiting merge and removed awaiting changes Awaiting changes awaiting change review Awaiting change review labels Jul 28, 2026
@Reranko05
Reranko05 requested a review from kouJuly 28, 2026 09:24
Comment on lines +74 to +79
std::string_view str;
if (auto error = std::move(str_result).get(str)) {
return Status::Invalid("Error getting string for key '", key,
"': ", simdjson::error_message(error));
}
return std::string(str);

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.

#50653 adds

template <typename SimdjsonValueType>
Result<SimdjsonValueType> GetJsonAs(sj::value& value) {

that already returns arrow::Results instead of error codes. This might simplify these type-casts

@Reranko05Reranko05Jul 28, 2026

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

Thanks for the suggestions! I opened #50693 to track this cleanup after #50672 is merged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, #50653 is merged now :)

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

I wanted to write after this PR is merged. Referenced the wrong PR. Fixed it.

Comment on lines 90 to +115
@@ -102,7 +106,13 @@ class ObjectParser::Impl {
"': (code=", static_cast<int>(str_result.error()), ")");
}

map.emplace(std::string(key), std::string(str_result.value()));
std::string_view str;
if (auto error = std::move(str_result).get(str)) {
return Status::Invalid("Error getting value for key '", std::string(key),
"': ", simdjson::error_message(error));
}

map.emplace(std::string(key), std::string(str));

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.

auto field has type simdjson_result<sj::field>. If we first resolve this to a sj::field, we do not need duplicated value checks for the unescaped_key and value.

Also, first asserting the value (L110), then type-checking the value (L98), is cleaner IMO. (It also works the other way around because simdjson provides overloads for many methods on its result type)

Note that for asserting the value and type-checking the value#50653 adds helper methods we might want to reuse

Comment on lines +145 to +149
bool value;
if (auto error = std::move(bool_result).get(value)) {
return Status::Invalid("Error getting bool for key '", key,
"': ", simdjson::error_message(error));
}

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.

#50653 adds

template <typename SimdjsonValueType>
Result<SimdjsonValueType> GetJsonAs(sj::value& value) {

that already returns arrow::Results instead of error codes. This might simplify these type-casts

@kou
kou merged commit bb0cf77 into apache:mainJul 30, 2026
60 of 64 checks passed
@koukou removed the awaiting merge Awaiting merge label Jul 30, 2026
@kou

kou commented Jul 30, 2026

Copy link
Copy Markdown
Member

We should rebase on main before we merge this... This broke our CI...

@taepper

Copy link
Copy Markdown
Contributor

We should rebase on main before we merge this... This broke our CI...

See #50732

pitrou pushed a commit that referenced this pull request Jul 30, 2026
### Rationale for this change
The simdjson API has a throwing and non-throwing subset. #50672 activated a compiler flag that disables the throwing subset of the API, which broke some CI builds.
### What changes are included in this PR?
This changes `json_write_internal.cc` and `from_string.cc` to use the non-throwing simdjson api
### Are these changes tested?
Yes
### Are there any user-facing changes?
No
* GitHub Issue: #50730
Authored-by: Alexander Taepper <alexander.taepper@gmail.com>
Signed-off-by: Antoine Pitrou <antoine@python.org>
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit bb0cf77.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++] Turn off exceptions in simdjson

6 participants

@Reranko05@kou@taepper@rok@pitrou