-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
V8 4.4 to remove indexed properties via external data #1451
Comments
I just saw the email on v8-dev and I've left a comment. I appreciate the heads up and I can't stress enough the impact that change will have on the io.js and node.js ecosystem. |
Yikes |
I realize this is disruptive, but I don't see how it's fundamentally different from e.g. the MaybeLocal<> or Persistent<> changes that also force existing embedders to update. anyway, as I mentioned on the CL, we'll discuss this internally. Will update this issue with the outcome. |
@bnoordhuis Doesn't this mean that it would no longer be possible to have |
the same functionality is provided by the ArrayBuffer API. The javascript objects will look exactly the same. |
It's not just compatibility but you can't implement something like SharedArrayBuffer (partial ownership transfers) with only ArrayBuffer api |
See @petkaantonov's comment.. We'd need enough hooks to at least make a replacement... |
All those use cases should be supported. If you have a concrete instance of On Fri, Apr 17, 2015, 5:38 PM Jeremiah Senkpiel [email protected]
|
I feel if there aren't any blocking functionality issues then this is ok. It seems more of an agenda issue to say making breaking changes is unacceptable. It won't break node as node lives on v8 from the past and they've said they won't update v8 often because of changes like this. Whereas iojs was willing to take the hit for the better engine, I'm not sure you can always have your cake and eat it.. If iojs has an agenda to keep up with v8 then it also needs to point out that this can be disruptive to native modules. |
I think you can do transferable ArrayBuffers using |
You can just allocate the memory yourself using the ArrayBufferAllocator node already defines and pass that memory to ArrayBuffer::New() I'd put the pointer to the underlying memory in one of the internal fields of the arraybuffer (via SetAlignedPointerInInternalField) because the ArrayBuffer::Externalize API only gives you the pointer once... If there are additional APIs you'd need on ArrayBuffer, ArrayBufferView, or the typed Arrays, we can certainly add them there. |
basically, what will be dropped is the ability to add external data to any object. Instead, the object needs to inherit from one of the typed array types (ArrayBufferView) or DataView. All other functionality will stay - if something is not accessible via the typed array API this can be easily fixed. |
@jeisinger so it will be possible to access ArrayBuffer data without copying/externalizing? |
Note that externalizing doesn't copy (unless you had a small typed array allocated on the V8 heap - you can disable this by setting --typed_array_max_size_in_heap=0). Whether an array buffer is externalized or not just decides who has to free the memory. If you'd have V8 manage the memory, I can add a method ArrayBuffer::GetContents that returns a pointer to the data without externalizing it. Note that this is a bit of a foot-gun as the pointer will stop being valid as soon as V8 gc'd the object. |
@jeisinger it's not hard to prevent object from being gc'd with C++ API, the problem with externalizing is that you can't unexternalize when you are done with the buffer |
something like this should fix this: https://codereview.chromium.org/1095083002 |
@jeisinger This will at minimum require removing an entire API. There are also a couple other things I'd like to ask:
|
it's not possible to resize an array buffer, but you can create arbitrary views on that buffer. |
@indutny have an idea of what kind of overhead to expect from needing to always determine the correct number of bytes being written instead of being able to @jeisinger I'm glad to see there's a cli option, but @thlorenz has told me it's possible to compile in V8 options. Guess we'd just have to use that. |
node.cc has several calls to SetFlagsFromString - why not just put it there? |
actually, I think it might be possible to resize array buffers, let me check |
ES7 defines ArrayBuffer.transfer() but it's not yet implemented in V8 :-/ |
@jeisinger Thanks for taking the time to look into it. :) |
Streams will want ArrayBuffer.transfer-like functionality (not necessarily publicly exposed, but at least in the engine) so I hope it shows up sooner or later :) |
after looking more into it, ArrayBuffer.transfer will not let you change the capacity of one object. It still creates a new ArrayBuffer, it just allows the underlying implementation to use realloc() instead of just copying the contents. So while we might add that API anyway, it won't solve your problem that you want to change the capacity of a given object :-/ |
@chrisdickinson That is the plan. I'm working on test implementations ATM using latest V8 4.4. The main breakage comes that all native modules that use Buffer will break. I'm seeing what can be done to mitigate that. The patch https://codereview.chromium.org/1095083002 from @jeisinger will help. |
I was hoping we could get it closer to the normal ES6 'use strict';
const ITER = 1e7;
class Nuffer extends Uint8Array {
constructor(n) {
super(n);
}
}
var t = process.hrtime();
for (var i = 0; i < ITER; i++)
new Nuffer(1);
t = process.hrtime(t);
t = t[0] * 1e9 + t[1];
console.log((t / ITER).toFixed(1) + ' ns/op'); Runs in ~245 ns/op. Unfortunately once the size of the allocation increases we're seriously hosed because of the need to zero-fill. As per usual I have a very nasty way to get around the performance issue for allocating Buffers from JS, but I'd very much prefer not to abuse the V8 API that way. It also doesn't fix the performance issue of creating a new Buffer around an existing |
I think it should be possible to get the performance of those three C++ On Tue, May 5, 2015, 11:27 PM Trevor Norris [email protected]
|
@domenic I queried npmjs regarding packages that depend on NAN indirectly or directly. The result was 60453 unique packages. npm currently lists 146600 packages. Thus, 60453/146600 = 41 % of packages in npm depend on NAN in some way, and thereby also depend on native modules. So, while it may be technically true that most users don't depend on native modules, a significant chunk do depend on them. |
@jeisinger I've noticed that calling |
Yes, many of the newly added ES6 features aren't yet fully optimized. I don't know what the roadmap for specific features is. |
removing |
I think this can be closed, the relevant core work was done in #1825 and that landed in 65cd82a...f72ecc4. |
@jeisinger Here was my solution to allowing creating the Horrible abuse of the API, but is working great. |
Overall construction time of Typed Arrays is faster in JS, but the problem with using it normally is zero-fill of memory. Get around this by using a flag in the ArrayBuffer::Allocator to trigger when memory should or shouldn't be zero-filled. Remove Buffer::Create() as it is no longer called. The creation of the Uint8Array() was done at each callsite because at the time of this patch there was a performance penalty for centralizing the call in a single function. PR-URL: #2866 Reviewed-By: Fedor Indutny <[email protected]>
You'll lose the optimizations for length and other fields that way, no On Wed, Sep 16, 2015, 1:38 AM Trevor Norris [email protected]
|
/cc @indutny have info for @jeisinger's question? |
@jeisinger Wouldn't we have lost these anyway by using |
@jeisinger I think I just fixed that in v8 |
ah, k |
Our current older versions of node-opencl refers to V8 apis that got removed between 4.3 and 4.4. See nodejs/node#1451 for details
Hey,
I'm about to remove SetIndexedPropertiesToExternalArrayData and related APIs from V8. I think there are some callsites of this API in io.js that would need to be updated.
You should use the standardized ArrayBuffers / ArrayBufferViews instead.
CL to remove them is here: https://codereview.chromium.org/1092923002
this will land in V8 4.4
The text was updated successfully, but these errors were encountered: