Skip to content

src: use simdjson - #59308

Closed
himself65 wants to merge 1 commit into
nodejs:mainfrom
himself65:himself65/2025/07/31/simdjson
Closed

src: use simdjson#59308
himself65 wants to merge 1 commit into
nodejs:mainfrom
himself65:himself65/2025/07/31/simdjson

Conversation

@himself65

@himself65himself65 commented Aug 1, 2025

Copy link
Copy Markdown
Member

Fixes: #59288

@nodejs-github-botnodejs-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
himself65force-pushed the himself65/2025/07/31/simdjson branch from 3b64484 to 31ca9ccCompareAugust 1, 2025 04:44
@codecov

codecovBot commented Aug 1, 2025

Copy link
Copy Markdown

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 linesPatch %Lines
src/json_parser.cc79.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 linesCoverage Δ
src/json_parser.h100.00% <ø> (ø)
src/json_parser.cc74.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
himself65force-pushed the himself65/2025/07/31/simdjson branch from 5d360b4 to 7830986CompareAugust 1, 2025 09:29
@himself65
himself65force-pushed the himself65/2025/07/31/simdjson branch from 7830986 to 111b1c2CompareAugust 1, 2025 09:30
Comment threadsrc/json_parser.cc
json_content_.size());

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

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.

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 freeto 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-ciPRs 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

@himself65@joyeecheung@nodejs-github-bot