Skip to content
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

perf(encoding/yaml) Don't allocate buffers unnecessarily #2967

Merged
merged 6 commits into from
Dec 5, 2022

Conversation

cscheid
Copy link
Contributor

@cscheid cscheid commented Dec 1, 2022

isBinary is called for every object that is encoded in yaml. Currently, it works by attempting to read from every object inside a generic try {} catch {} block, but that incurs allocation of a Buffer object and at least two Uint8Arrays in buf.readFromSync before the exception is thrown. In workloads that are heavy in yaml serialization this adds up.

Over at https://quarto.org, the PR I'm submitting by itself improves our total running time by 10% by simply checking the types more conservatively ahead of attempting to read from the buffer.

@cscheid cscheid requested a review from kt3k as a code owner December 1, 2022 01:35
@CLAassistant
Copy link

CLAassistant commented Dec 1, 2022

CLA assistant check
All committers have signed the CLA.

cscheid added a commit to quarto-dev/quarto-cli that referenced this pull request Dec 1, 2022
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM if the CI passes.

@cjihrig cjihrig merged commit b6dba51 into denoland:main Dec 5, 2022
cscheid added a commit to quarto-dev/quarto-cli that referenced this pull request Dec 14, 2022
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.

None yet

3 participants