Skip to content

perf(capabilities): reduce http request overhead#127

Open
paullegranddc wants to merge 2 commits intobengl/native-spansfrom
paullgdc/native-spans
Open

perf(capabilities): reduce http request overhead#127
paullegranddc wants to merge 2 commits intobengl/native-spansfrom
paullgdc/native-spans

Conversation

@paullegranddc
Copy link
Copy Markdown

This is done in multiple ways:

  • Do not copy the request body or headers. These are passed to JS as
    pointers into the WASM memory. If they become detached during the
    request, it is retried
  • Allow separating the request from the async local storage
    in order to no instrument it
  • Enabled agent rates header, reducing agent response size if unchanged
  • More efficient response header parsing, reducing copies

This is done in multiple ways:

* Do not copy the request body or headers. These are passed to JS as
    pointers into the WASM memory. If they become detached during the
    request, it is retried
* Allow separating the request from the async local storage
    in order to no instrument it
* Enabled agent rates header, reducing agent response size if unchanged
* More efficient response header parsing, reducing copies
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ece00f03a0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

resolve([
res.statusCode,
res.rawHeaders,
new Uint8Array(body.buffer),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve Buffer bounds when returning response body

Buffer.concat(chunks) can return a pooled Buffer whose byteOffset/byteLength cover only part of its underlying ArrayBuffer; constructing new Uint8Array(body.buffer) exposes the entire backing store instead of just the response bytes. In those cases the Rust side receives extra stale bytes (and potentially unrelated memory), corrupting HTTP response payloads for small responses. Return a view that respects the buffer slice (e.g., with offset/length) before passing it across WASM.

Useful? React with 👍 / 👎.

Comment on lines +118 to +119
HeaderName::from_bytes(key.as_bytes()).unwrap(),
HeaderValue::from_maybe_shared(Bytes::from(val)).unwrap(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Replace header parsing unwraps with fallible handling

Response header parsing now calls unwrap() on both HeaderName::from_bytes(...) and HeaderValue::from_maybe_shared(...); any non-conformant upstream header (invalid token/value bytes) will panic this request path instead of returning an HttpError. This is a regression from the previous non-panicking behavior and can crash or trap the WASM execution when talking to unexpected or malformed HTTP servers.

Useful? React with 👍 / 👎.

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.

1 participant