Skip to content

HttpRequest that survives past async functions #1036

@uNetworkingAB

Description

@uNetworkingAB

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions