Skip to content

Conversation

@djinn
Copy link

@djinn djinn commented Dec 22, 2025

  • Default string allocation size is set to 48 instead of 32
  • free_token is general Javascript deallocation, json_free_token creates a special case with reduced evaluation for JSON objects

* free_token is general Javascript deallocation, json_free_token creates a special case with reduced evaluation
@bnoordhuis
Copy link
Contributor

Can you share some before/after performance numbers? I note there are some unrelated changes in your PR.

@djinn
Copy link
Author

djinn commented Dec 23, 2025

The focus of this is specifically JSON parsing -

Thus I base my work off kraken-1.0/json-parse-financial. I modified the benchmark to run 100x to magnify the impact which is only marginally visible in original.

Screenshot 2025-12-23 at 21 22 36 Screenshot 2025-12-23 at 21 27 20

@djinn
Copy link
Author

djinn commented Dec 23, 2025

The performance data is in "Instruments" format

@djinn
Copy link
Author

djinn commented Dec 23, 2025

I have cleaned up the mix ups with other pieces of code

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM module some style issues, thanks for the PR!

quickjs.c Outdated
Comment on lines 21464 to 21466
if (p >= s->buf_end) {
goto end_of_input;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (p >= s->buf_end) {
goto end_of_input;
}
if (p >= s->buf_end)
goto end_of_input;

quickjs.c Outdated
Comment on lines 20350 to 20358
case TOK_NUMBER:
JS_FreeValue(s->ctx, token->u.num.val);
break;
case TOK_STRING:
JS_FreeValue(s->ctx, token->u.str.str);
break;
case TOK_IDENT:
JS_FreeAtom(s->ctx, token->u.ident.atom);
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
case TOK_NUMBER:
JS_FreeValue(s->ctx, token->u.num.val);
break;
case TOK_STRING:
JS_FreeValue(s->ctx, token->u.str.str);
break;
case TOK_IDENT:
JS_FreeAtom(s->ctx, token->u.ident.atom);
break;
case TOK_NUMBER:
JS_FreeValue(s->ctx, token->u.num.val);
break;
case TOK_STRING:
JS_FreeValue(s->ctx, token->u.str.str);
break;
case TOK_IDENT:
JS_FreeAtom(s->ctx, token->u.ident.atom);
break;

Copy link
Author

@djinn djinn left a comment

Choose a reason for hiding this comment

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

Updated according to convention

Copy link
Author

@djinn djinn left a comment

Choose a reason for hiding this comment

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

Corrected indentation

Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants