uNetworking / uNetworking/uWebSockets.js

HttpRequest that survives past async functions

Open
#1,036 32 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

big stuff enhancement
Dominant language
C++
Stars
9.2k
Forks
625
Avg merge
6h 7m
Merged PRs (30d)
13

Description

There are ways to easily support more abstract interfaces such as the fetch one, without any significant perf. loss in fast path.

Request is stack allocated and is only valid for the "sync" callback. Adding a call, Request.keep() that would dynamically allocate it and make it "keepable" could be automatically done for callbacks that do not return a Response.

This means, in the fast path, there is no overhead, while in the slow async path, you can still easily "keep" the Request for as long as you need as a slow path.

The benefit here is obvious: wrappers that implement more abstract interfaces do not need to:

  • Loop over all headers
  • Create JavaScript string for all headers
  • Hand over this object regardless if it will be kept or not

This is really bad for fast path performance

Internally, all that is neeed is adding 2 functions: getMemory, setMemory so that keep() calls malloc, getMemory, memcpy, setMemory on the Request and drop calls free

Contributor guide

No contributing guide indexed for this repository

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

No files or tests are named in the issue. Start by tracing the Request lifetime and the sync versus async callback entry points, then examine how Request.keep(), getMemory, setMemory, and drop would interact. Done means an async callback can retain the Request while the fast path avoids the proposed allocation and header conversion overhead.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.