Skip to content

Parsing time is dominated by makeJSONObject (in the wrapper) #5

@lemire

Description

@lemire

At the C++ level, isValid and parse do exactly the same work. This is obvious from the code in this wrapper:

bool simdjson::isValid(std::string_view p) {
  ParsedJson pj = build_parsed_json(p);
  return pj.isValid();
}

Versus

Napi::Object simdjson::parse(Napi::Env env, std::string_view p) {
  ParsedJson pj = build_parsed_json(p);
  if (!pj.isValid()) {
    Napi::Error::New(env, "Invalid JSON Exception").ThrowAsJavaScriptException();
  }
  ParsedJson::iterator pjh(pj);
  return simdjson::makeJSONObject(env, pjh).As<Napi::Object>();
}

However, in simdjson_nodejs, parse is at least 20x slower than isValid. This indicates that the running time is entirely dependent on makeJSONObject.

This function is written in a sensible manner but it is nevertheless quite slow. Evidently, this defeats the purpose of the fast parsing.

I would say it is a priority to fix this performance issue. It seems that there would be different valid ways to go about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededhigh priorityhigh priority problemsperformance issuePerformance of project is being affected

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions