mapbox / mapbox/node-fontnik

Optimize passing protobuf message back from threadpool

Open
#145 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue jira-sync-complete
Dominant language
C++
Stars
248
Forks
67
PR merge metrics
No merged PRs in 30d

Description

The `AfterRange` function currently calls `Nan::CopyBuffer` which creates a copy of the entire protobuf string before passing the back to JS.

We can optimize this by using the signature of `Nan::NewBuffer` that will take ownership of the string rather than copying it, to allow zero-copy passing of data from C++ to JS.

This method can be described at https://github.com/mapbox/node-cpp-skel/issues/69

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 at the AfterRange function and review its current Nan::CopyBuffer call, then read the linked node-cpp-skel issue for the ownership-based Nan::NewBuffer approach. Done means protobuf data is passed from the threadpool to JavaScript without copying the entire string.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, node.js
Domain
backend, performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.