Live data from Hacker News

Up to 4GB of Memory in WebAssembly

v8.dev

41–50 of 86 posts

Re: Up to 4GB of Memory in WebAssembly

#41
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?

That won't happen on a 64 bit machine. By the time we need that, the code will be so vastly different that trying to prepare for it now would be counterproductive.

Re: Up to 4GB of Memory in WebAssembly

#42
post #29

Earlier quoted context omitted.

I, on the other hand, wish everyone would embrace 32 bit by default. Doubling the size of every index, integer, etc comes at significant memory cost for next to no benefit. Increasing the amount of memory used directly impacts performance considering how slow memory is and how important it is to keep commonly used items in cache. If you're seriously using more than 4gb in a web page... I wouldn't mind a non-default w…

On some platforms like ARM, the transition from 32bit to 64bit(Aarch64) and the improvements to the ISA allowed some software to run much quicker on the same hardware. While the increased memory usage was detrimental if you are running into memory pressure issues, the speed improvements would be well worth the change for most tasks. When the Pi 3 launched it had a 32bit OS, but switching to 64bit improved the speed f…

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.

Re: Up to 4GB of Memory in WebAssembly

#43
post #38

Earlier quoted context omitted.

I'm 39 and I don't get it.

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.

Re: Up to 4GB of Memory in WebAssembly

#44
post #37

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 are probably right about the heap, but in the stack there are no big data structures. To move all data types to 64bits would impact the stack size of processes and threads. Bigger data structures also mean more cache misses. So, systems would be also slower. As, bringing data from memory to the CPU is very slow compared with accessing L1 or L2 cached data. So, you have a point. But, it does not apply equally to a…

Let's take an example in your favor and say you've got 16 integer local variables per stack frame and you're recursing 1000 (!!!) times over some really unbalanced tree or such. You saved 64 kilobytes...

Ok, now let's say 32 bit integers are the standard: You either wrote a program that starts to fail in mysterious ways when someone runs it on a 2 GB file, or you complicated the hell out of your data structures by needing arrays of arrays (i.e. https://www.nayuki.io/page/large-arrays-proposal-for-java).

It should be easier to make correct programs.

Re: Up to 4GB of Memory in WebAssembly

#45
post #31

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.

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...

Re: Up to 4GB of Memory in WebAssembly

#46
post #29

Earlier quoted context omitted.

I, on the other hand, wish everyone would embrace 32 bit by default. Doubling the size of every index, integer, etc comes at significant memory cost for next to no benefit. Increasing the amount of memory used directly impacts performance considering how slow memory is and how important it is to keep commonly used items in cache. If you're seriously using more than 4gb in a web page... I wouldn't mind a non-default w…

> 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.

Re: Up to 4GB of Memory in WebAssembly

#47
post #16

I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s) For a web page, 4…

Also V8 underpins Node, which has many more legitimate use-cases for that much memory.

That said I think we need some sort of user-facing permissions constraints for memory usage and/or webassembly execution. I fear that in practice this new capacity will mostly get used by unscrupulous crypto-miners.

Re: Up to 4GB of Memory in WebAssembly

#48
post #10

So, will we need to have 4GB of ram to run Javascripts now? :)

If we start playing crossplatform, browser-based wasm games[0], we might. And we should. OS independence when. 0: https://wasm.continuation-labs.com/d3demo/

No, please.

Most games are already cross-platform. No need to make them slower, less efficient.

Re: Up to 4GB of Memory in WebAssembly

#49
post #16

I wish new platforms would embrace 64 bit as the default. C and C++ for all common platforms use 32 bit literals and prefer 32 bit operations (char * short => int). Rust made a similar mistake. Java arrays use 32 bit subscripts, etc... I don't have a single computer (including my phone) using 32 bit pointers, but integers are stuck in the late 80s. (We already had 64 bit DEC alphas in the early 90s) For a web page, 4…

Using 64 bits when you don't need them is the mistake, not the other way around.

Cache isn't infinite.

Re: Up to 4GB of Memory in WebAssembly

#50
post #7
post #2

Amazing that they have a dark mode detection on that website.

You can do that in CSS now. I've noticed surprisingly many sites adjusting when I started using a Windows machine and set my system-wide preference to dark mode.

Would really love it if HackerNews got this... It's blinding when I browse it on my desktop monitor in the evenings.
Post reply on HN