You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 24, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 24, 2023. It is now read-only.
Should implementations or hosts be allowed to observably round up byteLength? #24
Alignment with something like WebAssembly, which only accepts linear memory sizes in multiples of its hardcoded page size. (WebAssembly's page size is 65,536, which I think is too large to use for general-purpose buffers like this in JS.)
Applications that need an exact length would need to do manual tracking and may accidentally consume the excess bytes incorrectly. For example, for writing out a buffer to file, you'd need to remember to write out the exact length of the data, not the rounded up one.
Unlike #23, I think the cons more clearly outweigh the pros here and we shouldn't make this change.
And in the future, WebAssembly may have multiple notions of page size (smaller / custom page sizes are a common request, since so many computations are expressed in terms of the page size).
On some ARM64 devices / OSs, pages are 16KB (ARM64 Linux typically, though I see both Android and macOS are reverting to 4K, or allowing that to happen at least). So even if the rounding algorithm is not implementation-specific, it may be hardware-specific. I don't know if fingerprinting is still a real concern, but this would add a bit or two to that.
I would note APIs that consume TypedArrays may have surprising behavior to programmers if things are resized:
constmeta=newResizableArrayBuffer(22);// archive file metadata for example, may grow as entries grow// ...write(newUint8Array(meta));// wrote 1024 or some such bytes instead? now archive is misaligned
Are there any concerns with a potential loop of a recursive compaction failing?
Another interesting use case, yeah. I'm more and more convinced having the implementation rounding the requested resize size or the constructor size is just too surprising, and we shouldn't do it.
I haven't heard any compelling use cases beyond implementation ease to allow byteLength to be observably rounded. I find @bmeck's examples compelling, so I'm closing this issue with the decision to not allow implementations to observably round byteLength.
I mentioned this in our call on Friday, repeating it here: We would be more comfortable if this wasn't implementation defined, and would propose going with rounding up to 64k like Wasm.
Activity
codehag commentedon Jan 27, 2021
cc @lars-t-hansen and @jandem
lars-t-hansen commentedon Jan 27, 2021
And in the future, WebAssembly may have multiple notions of page size (smaller / custom page sizes are a common request, since so many computations are expressed in terms of the page size).
On some ARM64 devices / OSs, pages are 16KB (ARM64 Linux typically, though I see both Android and macOS are reverting to 4K, or allowing that to happen at least). So even if the rounding algorithm is not implementation-specific, it may be hardware-specific. I don't know if fingerprinting is still a real concern, but this would add a bit or two to that.
bmeck commentedon Jan 27, 2021
moved from #23
I would note APIs that consume TypedArrays may have surprising behavior to programmers if things are resized:
bmeck commentedon Jan 27, 2021
Are there any concerns with a potential loop of a recursive compaction failing?
syg commentedon Jan 27, 2021
Another interesting use case, yeah. I'm more and more convinced having the implementation rounding the requested resize size or the constructor size is just too surprising, and we shouldn't do it.
syg commentedon Feb 22, 2021
I haven't heard any compelling use cases beyond implementation ease to allow byteLength to be observably rounded. I find @bmeck's examples compelling, so I'm closing this issue with the decision to not allow implementations to observably round
byteLength.codehag commentedon Mar 10, 2021
I mentioned this in our call on Friday, repeating it here: We would be more comfortable if this wasn't implementation defined, and would propose going with rounding up to 64k like Wasm.