logoalt Hacker News

renehszyesterday at 7:55 PM5 repliesview on HN

Unfortunately, Memory64 comes with a significant performance penalty because the wasm runtime has to check bounds (which wasn't necessary on 32-bit as the runtime would simply allocate the full 4GB of address space every time).

But if you really need more than 4GB of memory, then sure, go ahead and use it.


Replies

jsheardyesterday at 8:01 PM

The comedy option would be to use the new multi-memory feature to juggle a bunch of 32bit memories instead of a 64bit one, at the cost of your sanity.

show 5 replies
Findecanoryesterday at 10:40 PM

Actually, runtimes often allocate 8GB of address space because WASM has a [base32 + index32] address mode where the effective address could overflow into the 33rd bit.

On x86-64, the start of the linear memory is typically put into one of the two remaining segment registers: GS or FS. Then the code can simply use an address mode such as "GS:[RAX + RCX]" without any additional instructions for addition or bounds-checking.

TrueDualityyesterday at 9:19 PM

The irony for me is that it's already slow because of the lack of native 64-bit math. I don't care about the memory space available nearly as much.

show 1 reply
fulafeltoday at 4:00 AM

Bounds checking in other PLT is often reproted to result in pretty low overheads. Will be interesting to see some details about how this turns out.

zarzavatyesterday at 10:58 PM

I still don't understand why it's slower to mask to 33 or 34 bit rather than 32. It's all running on 64-bit in the end isn't it? What's so special about 32?

show 4 replies