-
Notifications
You must be signed in to change notification settings - Fork 7
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
Perf of ReflectConstruct #109
Comments
In the past @aduh95 documented which primordials created a performance issue, I think we should add this there too. |
It's in the |
Based on nodejs/node#49730, we can improve the performance of This could be beneficial for webstreams and blobs, but I was not able to make it work, I tried: function InternalClonedBlob() {
markTransferMode(this, true, false);
}
ObjectSetPrototypeOf(InternalClonedBlob.prototype, Blob.prototype);
ObjectSetPrototypeOf(InternalClonedBlob, Blob);
InternalClonedBlob.prototype[kDeserialize] = () => {};
function ClonedBlob() {
var cloned = new InternalClonedBlob();
cloned.constructor = Blob;
return cloned;
} Which throws:
I was able to make a version that works doing: class ClonedBlob extends Blob {
static {
markTransferMode(this, true, false);
this[kDeserialize] = () => {};
}
}
ClonedBlob.prototype.constructor = Blob; It prints correctly the results of: const { Blob } = require('buffer');
(async () => {
console.log(structuredClone(new Blob(['hello'])));
console.log(await structuredClone(new Blob(['hello'])).text());
console.log(structuredClone(new Blob([])).constructor);
console.log(structuredClone(new Blob([])).constructor === Blob);
console.log(new Blob(['a']).slice(0, 1).constructor);
})();
But when we run the benchmark, it throws an error after a couple executions:
@rluvaton Do you have any hint? |
On top of my head no but I will try to investigate it I did not migrate transfer classes in webstream so did not encounter with this error |
The error of I discovered when I was trying to optimize the |
Legendecas opened a PR to fix the issue described in the previous issue, nodejs/node#50026, I would appreciate it if anyone here could approve that PR, I'm already using it to remove usages of ReflectConstruct on transferable objects. |
All PRs were merged, I think I already removed all the relevant references for ReflectConstruct, so I think we can close this as completed. |
I think this is the second PR I saw removing the usage of
ReflectConstruct
: nodejs/node#49546The first one improved a lot the creation of
WebStreams
, and there are much more cases where this function is used, so I think that it worth exploring the other usages to see if possible to remove that function.The text was updated successfully, but these errors were encountered: