GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — deps,src: update simdjson and trim its includes by lemire · Pull Request #66620 · nodejs/node

deps,src: update simdjson and trim its includes #66620

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.

Sign up for GitHub

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
lemire wants to merge 2 commits into nodejs:main from lemire:deps-simdjson-5.0.3
+84,954 −11,617
Closed

deps,src: update simdjson and trim its includes #66620

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
117885a
deps: update simdjson to 5.0.3
lemire Oct 9, 2026
2b17b43
src: stop including simdjson.h from env.h
lemire Oct 6, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
src: stop including simdjson.h from env.h
env.h includes inspector_profiler.h, which included simdjson.h for
the types of two virtual methods and a parser member. As a result,
about 155 files in src/ parsed the amalgamated simdjson header,
which is over 10 MB.

Keep simdjson out of inspector_profiler.h: the profile connections
now say which field of `result` holds the profile, and
WriteProfile() takes the profile as raw JSON. The parser becomes a
local variable, so its buffers are no longer kept alive for the
lifetime of the Environment.

Also drop the unused include from node_task_runner.h, and let the
config file reader rewind its document instead of parsing the whole
file a second time with a second parser.

Now only the eight files that use simdjson include it. On an Apple
M-series machine, a clean rebuild of the src/ objects takes about
15% less CPU time (376 s to 320 s) and 19% less wall time at -j14.

Signed-off-by: Daniel Lemire <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@lemire
lemire committed Oct 9, 2026
commit 2b17b43eeba4484d43afaa1d5e3f951f006c5df6

There are no files selected for viewing

80 changes: 32 additions & 48 deletions 80 src/inspector_profiler.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#include <cinttypes>
#include <limits>
#include <optional>
#include <sstream>
#include "simdjson.h"
#include "simdutf.h"

namespace node {
Expand Down Expand Up @@ -109,6 +111,28 @@ bool StringViewToUTF8(const v8_inspector::StringView& source,
return *utf8_length == result_len;
}

// Return the raw JSON of the profile object in `result`: either the
// `field` member of `result` or, if `field` is nullptr, `result` itself.
static std::optional<std::string_view> GetProfile(
simdjson::ondemand::object* result, const char* field, const char* type) {
simdjson::ondemand::object profile_object;
if (field == nullptr) {
profile_object = *result;
} else if ((*result)[field].get_object().get(profile_object)) {
fprintf(
stderr, "'%s' from %s profile result is not an Object\n", field, type);
return std::nullopt;
}
std::string_view profile_raw;
if (profile_object.raw_json().get(profile_raw)) {
fprintf(stderr,
"Cannot get raw string of the 'profile' field from %s profile\n",
type);
return std::nullopt;
}
return profile_raw;
}

void V8ProfilerConnection::V8ProfilerSessionDelegate::SendMessageToFrontend(
const v8_inspector::StringView& message) {
Environment* env = connection_->env();
Expand All @@ -134,9 +158,10 @@ void V8ProfilerConnection::V8ProfilerSessionDelegate::SendMessageToFrontend(
return;
}

simdjson::ondemand::parser json_parser;
simdjson::ondemand::document parsed;
simdjson::ondemand::object response;
if (connection_->json_parser_
if (json_parser
.iterate(
message_utf8.data(), message_utf8_length, message_utf8.size())
.get(parsed) ||
Expand Down Expand Up @@ -184,7 +209,10 @@ void V8ProfilerConnection::V8ProfilerSessionDelegate::SendMessageToFrontend(
return;
}

connection_->WriteProfile(&result);
auto profile = GetProfile(&result, connection_->profile_field(), type);
if (profile.has_value()) {
connection_->WriteProfile(*profile);
}
connection_->RemoveProfileId(id);
}

Expand Down Expand Up @@ -214,32 +242,7 @@ std::string V8CoverageConnection::GetFilename() const {
env()->thread_id());
}

std::optional<std::string_view> V8ProfilerConnection::GetProfile(
simdjson::ondemand::object* result) {
simdjson::ondemand::object profile_object;
if ((*result)["profile"].get_object().get(profile_object)) {
fprintf(
stderr, "'profile' from %s profile result is not an Object\n", type());
return std::nullopt;
}
std::string_view profile_raw;
if (profile_object.raw_json().get(profile_raw)) {
fprintf(stderr,
"Cannot get raw string of the 'profile' field from %s profile\n",
type());
return std::nullopt;
}
return profile_raw;
}

void V8ProfilerConnection::WriteProfile(simdjson::ondemand::object* result) {
// Generate the profile output from the subclass.
auto profile_opt = GetProfile(result);
if (!profile_opt.has_value()) {
return;
}
std::string_view profile = profile_opt.value();

void V8ProfilerConnection::WriteProfile(std::string_view profile) {
// Create the directory if necessary.
std::string directory = GetDirectory();
DCHECK(!directory.empty());
Expand All @@ -254,7 +257,7 @@ void V8ProfilerConnection::WriteProfile(simdjson::ondemand::object* result) {
WriteResult(env_, path.c_str(), profile);
}

void V8CoverageConnection::WriteProfile(simdjson::ondemand::object* result) {
void V8CoverageConnection::WriteProfile(std::string_view profile) {
Isolate* isolate = env_->isolate();
HandleScope handle_scope(isolate);

Expand All @@ -271,13 +274,6 @@ void V8CoverageConnection::WriteProfile(simdjson::ondemand::object* result) {
Local<Context> context = env_->context();
Context::Scope context_scope(context);

// Generate the profile output from the subclass.
auto profile_opt = GetProfile(result);
if (!profile_opt.has_value()) {
return;
}
std::string_view profile = profile_opt.value();

// append source-map cache information to coverage object:
Local<Value> source_map_cache_v;
{
Expand Down Expand Up @@ -349,18 +345,6 @@ void V8CoverageConnection::WriteProfile(simdjson::ondemand::object* result) {
}
}

std::optional<std::string_view> V8CoverageConnection::GetProfile(
simdjson::ondemand::object* result) {
std::string_view profile_raw;
if (result->raw_json().get(profile_raw)) {
fprintf(stderr,
"Cannot get raw string of the 'profile' field from %s profile\n",
type());
return std::nullopt;
}
return profile_raw;
}

std::string V8CoverageConnection::GetDirectory() const {
return env()->coverage_directory();
}
Expand Down
19 changes: 8 additions & 11 deletions 19 src/inspector_profiler.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
#error("This header can only be used when inspector is enabled")
#endif

#include <optional>
#include <string_view>
#include <unordered_set>
#include "inspector_agent.h"
#include "simdjson.h"

namespace node {
// Forward declaration to break recursive dependency chain with src/env.h.
Expand Down Expand Up @@ -59,11 +58,11 @@ class V8ProfilerConnection {
virtual std::string GetDirectory() const = 0;
// Return the filename the profile should be written as.
virtual std::string GetFilename() const = 0;
// Return the profile object parsed from `message.result`,
// which will be then written as a JSON.
virtual std::optional<std::string_view> GetProfile(
simdjson::ondemand::object* result);
virtual void WriteProfile(simdjson::ondemand::object* result);
// Return the field of `message.result` that holds the profile object,
// or nullptr if `message.result` is itself the profile object.
virtual const char* profile_field() const { return "profile"; }
// Write the profile, given as raw JSON.
virtual void WriteProfile(std::string_view profile);

bool HasProfileId(uint64_t id) const { return profile_ids_.contains(id); }

Expand All @@ -76,7 +75,6 @@ class V8ProfilerConnection {
std::unordered_set<uint64_t> profile_ids_;

protected:
simdjson::ondemand::parser json_parser_;
Environment* env_ = nullptr;
};

Expand All @@ -92,9 +90,8 @@ class V8CoverageConnection : public V8ProfilerConnection {

std::string GetDirectory() const override;
std::string GetFilename() const override;
std::optional<std::string_view> GetProfile(
simdjson::ondemand::object* result) override;
void WriteProfile(simdjson::ondemand::object* result) override;
const char* profile_field() const override { return nullptr; }
void WriteProfile(std::string_view profile) override;
void WriteSourceMapCache();
void TakeCoverage();
void StopCoverage();
Expand Down
14 changes: 4 additions & 10 deletions 14 src/node_config_file.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -573,19 +573,13 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
return ParseResult::InvalidContent;
}

simdjson::ondemand::parser config_parser;
simdjson::ondemand::document config_document;
if (config_parser.iterate(file_content).get(config_document)) {
FPrintF(stderr, "Can't parse %s\n", config_path.data());
return ParseResult::InvalidContent;
}

simdjson::ondemand::object config_object;
if (config_document.get_object().get(config_object)) {
// Walk the document again, this time to parse the configuration.
document.rewind();
if (document.get_object().get(main_object)) {
return ParseResult::InvalidContent;
}

return ParseConfigObject(&config_object, config_path, true);
return ParseConfigObject(&main_object, config_path, true);
}

std::string ConfigReader::GetNodeOptions() {
Expand Down
1 change: 1 addition & 0 deletions 1 src/node_task_runner.cc
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "node_task_runner.h"
#include "simdjson.h"
#include "util-inl.h"

#include <regex> // NOLINT(build/c++11)
Expand Down
1 change: 0 additions & 1 deletion 1 src/node_task_runner.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node_internals.h"
#include "simdjson.h"
#include "spawn_sync.h"
#include "uv.h"

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.