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

Consider decode() with offset/length #219

Open
inexorabletash opened this issue Jun 12, 2020 · 2 comments
Open

Consider decode() with offset/length #219

inexorabletash opened this issue Jun 12, 2020 · 2 comments
Labels
addition/proposal New features or enhancements topic: api

Comments

@inexorabletash
Copy link
Member

Context: https://bugs.chromium.org/p/chromium/issues/detail?id=1093980

When decoding a subset of an ArrayBuffer, the API currently requires the creation of a new view (Uint8Array) to encapsulate the byte offset/length. High performance applications try to avoid creating temporaries to reduce GC impact.

The request is to support a form of decode() which takes a buffersource, byte offset, and length. This could be done e.g. as:

decoder.decode(bufferSource, {offset, length});

(Although in real high-performance code the caller would re-use the options object.)

IIRC we talked about this in the distant past and decided "no, views are how you do this" but we now have developer feedback that this is a bottleneck. Improving the performance of bindings/GC is possible, but this API shape has a seemingly unnecessary overhead imposed by requiring views.

@inexorabletash inexorabletash added the addition/proposal New features or enhancements label Jun 12, 2020
@annevk
Copy link
Member

annevk commented Jun 13, 2020

Yeah, see #69 (comment) onward. #69 (comment) mentions how you could optimize the view allocations away in Wasm (with theoretical host bindings).

  1. Is the performance drawback consistent across browsers? How bad is it? (The bug doesn't go into much detail and it seems like a lot of effort to get access to the linked document.)
  2. Has TC39 considered some kind of mutable view to help with these scenarios? It seems bad if we would have to do this for each API taking a view.
  3. If we want speed is overloading the way to go? Dictionaries? (Why not use Wasm with theoretical host bindings?)

@hsivonen
Copy link
Member

High performance applications try to avoid creating temporaries to reduce GC impact.

Is there a reason why the JS engines can't do escape analysis and heap-allocate temporary view objects? Is there a reason why the nursery in the GC doesn't take care of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: api
Development

No branches or pull requests

3 participants