Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch core http to okhttp #10069

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: switch core http to okhttp #10069

wants to merge 1 commit into from

Conversation

edusperoni
Copy link
Contributor

WIP. Will fill details later.

Notes:

  • needs to use the alpha version of the runtime (fixes to kotlin/jvm methods)
  • need to wrap okhttp in an async task so we can process the body in the background
  • ideally be more lazy with the http processing
  • adapt the devtools agent to recieve okhttp results

other than doing some body decoding in the main thread, this implementation already covers all of the current API + cancellation. Ideeally we should have the web spec AbortController ready for this

@cla-bot cla-bot bot added the cla: yes label Oct 27, 2022
raw: result.raw,
toArrayBuffer: () => Uint8Array.from(result.raw.toByteArray()).buffer,
raw: raw,
toArrayBuffer: () => Uint8Array.from(raw.toByteArray()).buffer,
Copy link
Contributor

Choose a reason for hiding this comment

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

Uint8Array.from iterates over each element of the source array and copies it to the new array.

If you use pass a java.nio.ByteBuffer as the argument it'll create the TypedArray from a pointer (O(1) performance and no extra memory allocation).

Creating a buffer from 1MB of data takes about ~700ms, wrapping it in a java.nio.ByteBuffer takes only 3ms

toArrayBuffer: () => {
    const arr = raw.toByteArray();
    const bb = java.nio.ByteBuffer.wrap(arr);
    const buffer = ArrayBuffer.from(bb);
    return buffer;
},

@NathanWalker NathanWalker added this to the 8.6 milestone Mar 16, 2023
@NathanWalker NathanWalker modified the milestones: 8.6, 9.0 Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants