Live data from Hacker News

Up to 4GB of Memory in WebAssembly

v8.dev

61–70 of 86 posts

Re: Up to 4GB of Memory in WebAssembly

#61
post #42

Earlier quoted context omitted.

There doesn't have to be a choice between a fast ISA, and even 64 bit registers, and using 32 bit pointers/indices. We can do theoretically do both - it's just extremely rare in practice.

Not rare at all. 32-bit "pointers" in a 64-bit process is relatively common, even, as it's what ART does on Android ( https://www.anandtech.com/show/8231/a-closer-look-at-android... ). And Hotspot has a similar optimization: https://wiki.openjdk.java.net/display/HotSpot/CompressedOops

And it's also common to truncate 64 bit pointers down to 48 bits to pack other info alongside them, since those are the only bits that actually get used on most architectures.

Re: Up to 4GB of Memory in WebAssembly

#62

Earlier quoted context omitted.

> Doubling the size of every index, integer, etc comes at significant memory cost for next to no benefit. The overwhelming majority of GUI program data is composed of images, textures, sounds, videos, 3D models, text, etc. I would bet that less than 5% of the memory required to host a popular web page (facebook, amazon, etc.) is dedicated to pointers, array indices, etc.

You would lose your money, because most of that is not needed in RAM, and definitely not in cache.

The browser stores all of that stuff in RAM.

Re: Up to 4GB of Memory in WebAssembly

#63
post #38

Earlier quoted context omitted.

I assume it's from when you used to boot DOS mode games that addressed beyond 640KB conventional memory they had DOS/4GW labeled all over. https://en.wikipedia.org/wiki/DOS/4G

The slash helps. I'm pretty sure Duke Nukem, Doom, and similar all showed that banner during startup.

Yeah, sorry. Forgot the slash. It's only been 20 to 25 years... :)

Re: Up to 4GB of Memory in WebAssembly

#64
post #31

Earlier quoted context omitted.

The overwhelming majority of what wasm will be used for probably does not include images, textures, sounds, videos or 3d models. The overwhelming majority of the memory in most wasm programs will probably be not large arrays of text. The webpage as a whole is a gui program, but wasm is primarily a place to run computationally intensive code. The web-browser deals with things like rendering images natively without sto…

What do you think that computationally expensive code is cranking on? It ain't small bits of text.

When it is text, it's usually more small bits of text than big bits. If you're just copying around giant strings you're unlikely to be using webasm. More likely you're copying around tons of small strings as you format them into a giant string if that's the end goal. Or you're copying around tons of small strings as you use those small strings to make api calls to the dom (indirectly through js). Or you're just plain running something like a physics simulation and don't even have text in the first place.

Re: Up to 4GB of Memory in WebAssembly

#65
post #45
post #31

Earlier quoted context omitted.

The overwhelming majority of what wasm will be used for probably does not include images, textures, sounds, videos or 3d models. The overwhelming majority of the memory in most wasm programs will probably be not large arrays of text. The webpage as a whole is a gui program, but wasm is primarily a place to run computationally intensive code. The web-browser deals with things like rendering images natively without sto…

Honestly, I don't like the trend of web apps for everything, and I'd be ok if web pages couldn't really be more than toy programs. However, at that point, why even bother with WASM? I mean what is that even for if you're not doing real computation on real data sets? Real data sets are bigger than 2 billion sometimes...

If you've got 2GB of data and you're doing it in WASM... you're probably doing something wrong, for the simple reason that that means you probably loaded 2GB of data over the internet into the browser (and will probably need to redo that every time you revisit the page). That's enough data that you want to save it to disk, which means (probably) not using a browser.

As for "what is the point if not doing computation on "real" data sets"... letting you do computation on reasonably sized data sets. Consider that the size of a gaint codebase like linux is still only a few hundred megabytes (uncompressed). That's more than enough data to be doing interesting work. Or look at the size of a game like quake3.

Re: Up to 4GB of Memory in WebAssembly

#66
post #65
post #45

Earlier quoted context omitted.

Honestly, I don't like the trend of web apps for everything, and I'd be ok if web pages couldn't really be more than toy programs. However, at that point, why even bother with WASM? I mean what is that even for if you're not doing real computation on real data sets? Real data sets are bigger than 2 billion sometimes...

If you've got 2GB of data and you're doing it in WASM... you're probably doing something wrong, for the simple reason that that means you probably loaded 2GB of data over the internet into the browser (and will probably need to redo that every time you revisit the page). That's enough data that you want to save it to disk, which means (probably) not using a browser. As for "what is the point if not doing computation…

> for the simple reason that that means you probably loaded 2GB of data over the internet

No, web pages can access local storage.

Re: Up to 4GB of Memory in WebAssembly

#67
post #66
post #65

Earlier quoted context omitted.

If you've got 2GB of data and you're doing it in WASM... you're probably doing something wrong, for the simple reason that that means you probably loaded 2GB of data over the internet into the browser (and will probably need to redo that every time you revisit the page). That's enough data that you want to save it to disk, which means (probably) not using a browser. As for "what is the point if not doing computation…

> for the simple reason that that means you probably loaded 2GB of data over the internet No, web pages can access local storage.

You mean file:// urls? If you have access to do that... why not just install a real executable as well.

(Can't say I'm terribly up to date on the different ways to store data as a website... but if there's a way to persist multiple gb I would be very surprised)

Re: Up to 4GB of Memory in WebAssembly

#68

Earlier quoted context omitted.

Why prefer 64bit pointers over multiple memory address spaces ( https://github.com/WebAssembly/multi-memory )? Your CPU has to do a lot of work to keep pretending it's memory is flat, If we give up that pretense you can optimize cache utilization and multiplex multiple WASM threads onto a single OS thread without allowing specter.

Because the CPU is going to do the work to make that illusion happen regardless of if you participate in it or not - so why constrain yourself to anything less than 64-bit pointers if you're not going to get anything in return? What cache optimization are you referring to? Just that 32-bit pointers is a form of pseudo-compression and can be more densely packed? Because there's not really any other cache benefits in p…

Immutable data structures tend to use a lot of pointers see how Haskell executes, even in other paradigms halving pointer s can have a significant impact on alignment (tags, enums, etc).

V8 sandboxes WASM by placing them in a dedicated OS process, this buys 64 bit pointers, but comes at a cost. We can chose for a 64 bit processor to buy us in process memory isolation, by masking pointers or we can have 64 bit pointers.

Re: Up to 4GB of Memory in WebAssembly

#69
post #14

Earlier quoted context omitted.

As is mentioned in the article, u64 was used to future proof for wasm's upcoming memory64 type: https://github.com/WebAssembly/memory64/blob/master/proposal...

Yeah, so what are they going to do when they then claim to need to to represent the length 2^64?

If 32 bit is from your face to your hand, 64 bit is from you to the sun. You aren't going to need that on a single computer in your lifetime.
Post reply on HN