-
Notifications
You must be signed in to change notification settings - Fork 1
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
Review #30
Comments
For structured clone, see some discussion in #19. |
@syg for our own convenience making progress on your suggestions, I've turned your bullets in check boxes. I also turned the first paragraph into a checkbox, but it sounds like something you're queueing for yourself do. Yes? |
Yep, planning to do it myself. |
On My assumption: there will be many small immutable buffers, and many huge ones. Any use of the mmu is probably only worth it for the huge ones, but those are more likely to be the ones where micro performance matters.
Although I don't believe any of these optimization opportunities should affect whether this proposal advances, I'd love to hear from implementors whether any of these are practical. Thanks. |
@syg All concerns have been addressed (see new links above). |
Hi @ricea At w3c/webtransport#131 (comment) @domenic suggests you may be interested in this topic: #30 (comment) above. I look forward to your comments. Thanks! |
There were no concerns brought up at the Wasm CG meeting last week. We still believe this proposal to be orthogonal to what Wasm wants to do with memory protection. |
Ballpark, what byte lengths do you consider small and what do you consider huge? I do agree there, as if "small" is smaller than a typical 4K page, the only way to get OS-level protection is to reserve a whole page, which probably isn't worth it.
This is possible and is already an implementation technique for Wasm. But it's definitely a scary corner -- anything with fault handlers is. Wasm also has less... stuff... going on than user JS code, so I'd want some careful scrutiny because recommending this as an implementation strategy. In other words, even if immutable buffers were
Yeah, implementing this with OS-level page protection won't be a requirement for actually sharing the memory among threads. If a non-page protection implementation (e.g. a manual check on writes) is buggy, we believe that to only be a correctness issue from the engine's POV. Whatever other protections we've put into place to mitigate threats for mutable ArrayBuffers also applies here.
Thanks for the discussion. Agreed that the implementation strategies here don't block advancement to 2.7. My current hunch is that it's probably worth investing in an |
Ballpark, small is < 1MB. Huge is >= 1GB But of course this is for implementors to determine based on measurement, as these distinctions have no observable effect.
Good. Belt and suspenders
Within one process/address-space, that makes sense even in a multi-language environment. A weakness of memory safety of any threatens all, independent of arrayBuffers. But what about between processes, that are otherwise protected except for the Shared ArrayBuffers and the Immutable ArrayBuffers, if these are shared by mapping them into the participating processes?
Us too! Thanks.
Good. Given that, is it appropriate to close this issue? (What really matters is the checkboxes on the Path to Stage 4 page, which I see is already checked, so no prob either way.) Thanks! |
The trouble is that when the buffer is created we don't know whether it will need to be shared between address spaces or not, and using shared memory costs more. I did some benchmarking on Linux, and creating a shared memory mapping takes roughly ten times as long as an anonymous memory mapping. What's worse, the soft page faults on the shared memory mapping also take 10 times as long. So there's an O(N) cost for first use of the mapping. Example: 120ms to create and memset() a 1GB anonymous mapping; 1.25s to do the same thing with a shared mapping. I think the cost is prohibitive for engines to create huge mappings in shared memory just in case we will need to share them with a different address space later. |
Hi @ricea , thanks for the analysis! What if the implementation did not do this for the first creation, but instead on the first time it were passed between address spaces? Once it is passed between address spaces once, that might be a better predictor that it will be again. |
Yes, that is something that implementations could explore. |
Informative
Normative
Validate mutability in DetachArrayBuffer #38
Add immutable array buffer awareness to structuredClone whatwg/html#11033
mprotect
. However, that requires page alignment. We can't reveal the page size to user code, as that's a fingerprinting vector. Fixing a page size seems too unergonomic. Ideas? (Usingmprotect
is a nice-to-have for V8, not a requirement.)Editorial
Editorial: Improve/explain operation parameter names #33
Editorial: Improve/explain operation parameter names #33
The text was updated successfully, but these errors were encountered: