Structured clone only gets you a new object in this heap, not a new object in an isolate. You’re still doing stringify/parse under the hood every time you sendMessage.

postMessage uses it transparently: https://developer.mozilla.org/en-US/docs/Web/API/Worker/post...

So I wonder if any of these improvements could be applied to structuredClone.

Benchmarks aren’t showing structuredClone favorably versus JSON round tripping. Likely because JSON-compatible data structures are less complex than clonable data. I suspect with this change JSON will now be faster than structuredClone.

> Benchmarks aren’t showing structuredClone favorably versus JSON round tripping.

Which ones?

Structured clone seems to be approximately the same as FF according to this (structuredClone is slightly faster on my machine, probably margin of error): https://measurethat.net/Benchmarks/Show/23052/0/structuredcl... (Linux: FF 141, Chromium 138).

So think about how that graph is going to look once the stringify part is twice as fast. Instead of being slightly faster it'll be statistically slower.