Skip to content

src: use simdjson #59308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

himself65
Copy link
Member

@himself65 himself65 commented Aug 1, 2025

Fixes: #59288

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Aug 1, 2025
@himself65 himself65 force-pushed the himself65/2025/07/31/simdjson branch from 3b64484 to 31ca9cc Compare August 1, 2025 04:44
@himself65 himself65 requested a review from joyeecheung August 1, 2025 05:13
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 79.74684% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.97%. Comparing base (91dadf2) to head (111b1c2).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/json_parser.cc 79.74% 4 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #59308      +/-   ##
==========================================
- Coverage   90.00%   89.97%   -0.03%     
==========================================
  Files         649      649              
  Lines      192180   192192      +12     
  Branches    37659    37684      +25     
==========================================
- Hits       172970   172933      -37     
+ Misses      11830    11829       -1     
- Partials     7380     7430      +50     
Files with missing lines Coverage Δ
src/json_parser.h 100.00% <ø> (ø)
src/json_parser.cc 74.75% <79.74%> (-5.25%) ⬇️

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@himself65 himself65 force-pushed the himself65/2025/07/31/simdjson branch from 5d360b4 to 7830986 Compare August 1, 2025 09:29
@himself65 himself65 force-pushed the himself65/2025/07/31/simdjson branch from 7830986 to 111b1c2 Compare August 1, 2025 09:30
json_content_.size());

simdjson::ondemand::document document;
simdjson::error_code error = parser_.iterate(json_view).get(document);
Copy link
Member

Choose a reason for hiding this comment

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

Actually reading this I realized that if we are moving towards simdjson, it's better to just use simdjson directly in the callsite instead of shimming JSONParser over it, because simdjson does not really support random access, unlike the current JSON parser interface. As a result trying to shim it is bound to lead to repetitive parsing like what's happening here. The correct way to handle fields of unknown order is to just iterate over the fields and handle them for different specific key values on an ad-hoc basis, as suggested by the simdjson documentation: https://github.com/simdjson/simdjson/blob/master/doc/basics.md#using-the-parsed-json

For example, for SEA, this would be the recommended way to parse the document according to the simdjson documentaiton: #59323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use simdjson in JSONParser
3 participants