nodejs / nodejs/performance

Blob.text and Blob.arraybuffer are 10x+ slower on 20.x

Open
#118 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
399
Forks
11
Avg merge
29m
Merged PRs (30d)
1

Description

The blob/blob.js benchmark is taking hours: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1402/console

This probably didn't take so long in the past, there is this PR that changed the Blob's behavior a lot: https://github.com/nodejs/node/pull/45258/

From what I saw, the problem is in the JS->C++ transitions, for each piece of data it crosses JS->C++.

Furthermore, the text function expects arraybuffer and then calls decode, when we could just decode the data as soon as we get it from the C++ instead of keeping everything in memory and then discarding it.

I can do some optimizations on the JS side but I think this could be largely improved if we do the heavy operations on C++, I have no idea how to handle the asynchronous code on C++, so I accept some hints or if anyone wants to try work on this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the blob/blob.js benchmark and compare its current behavior with the Blob changes in PR #45258. Trace the JS-to-C++ transitions used by text and arraybuffer, then rerun the benchmark; done means the benchmark no longer takes hours and the Blob operations show a substantial performance improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.