Live data from Hacker News

Firefox’s new streaming and tiering compiler

hacks.mozilla.org

101–110 of 229 posts

Re: Firefox’s new streaming and tiering compiler

#101

Earlier quoted context omitted.

Why Hotspot? There are many bytecode languages, with their own execution environments - .NET/CLR, Parrot, BEAM, etc. wasm is an attempt to design one specifically for the web, rather than trying to shoehorn one made for a different environment.

HotSpots optimization and code generation is far superior than any other VM. But that is kind of my point - there are advanced vms out there. I don't see why the web needs its own vm apart from them. All the differences I see are fairly minimal.

But the bytecode and stdlib it works with are the least suitable. I could go on for a long time about JVM insns and the class model and GC assumptions that make it bad for the web. Similarly, I could go on forever about the stdlib that supports this bytecode (strings, threads, class loaders, etc) and why it's bad for the web too.

Re: Firefox’s new streaming and tiering compiler

#102
On a desktop, we compile 30-60 megabytes of WebAssembly code per second. That’s faster than the network delivers the packets.

Funny enough, on my workstation it seems to compile something more like 60-80 MiB/s, to keep up with my network which was recently upgraded to gigabit.

Very impressive stuff, I hope workstation CPUs can keep pace with networks.

Re: Firefox’s new streaming and tiering compiler

#103
post #5

Nice article. Although, as always with articles on WebAssembly, it keeps repeating that wasm is faster than JavaScript, without ever mentioning the limitations of wasm wrt. JS (no GC, no interaction with the DOM or with JS libraries besides numbers, etc.). And that means there are zillions of developers who keep being misled in thinking stuff like "Why don't you compile to wasm to make your stuff faster?". That inclu…

No one is saying you should do your whole application in WASM though, it's really just like native extensions in any dynamic language: of course, you're not going to get GC or interaction with dynamic parts of the language in your extension, but the reason might be: - libraries written in another language, such as SQL.js - hot spots of an application that can benefit from fast number crunching (e.g., gaming, visualiz…

I understand all that. I have been writing compilers for more than 10 years, including the compiler of Scala.js. I am not criticizing wasm nor its benefits.

What I profoundly dislike is that such good articles about wasm, written by excellent technical people, all silently ignore that. I am absolutely certain that the authors know all about it, but they don't mention that to their audience, which, for the majority, doesn't know. Therefore, that very silence (not just glossing over, but actual silence) brings misinformation to the masses.

Re: Firefox’s new streaming and tiering compiler

#104
post #30

Earlier quoted context omitted.

Running a native app compiled to wasm into the browser ? So the opposite of running an Electron app?

Calling it now: 1) Write a Windows app 2) Run it in the browser with wasm 3) Stuff that into Electron and distribute to Mac/Linux/Windows Why distribute the electron wrapped wasm on Windows instead of using the real native Windows app? It's more consistent this way! Single codebase! Developer efficiencies!

Small deviation - write a native linux or mac app (instead of targeting Windows for the initial app)... mostly because I feel like developing on those platforms is so much more enjoyable.

Re: Firefox’s new streaming and tiering compiler

#106

Earlier quoted context omitted.

Is it actually a JIT? It's just compiling everything unconditionally. I guess the fact that the second tier replaces previously compiled functions with more optimized versions makes it a JIT? Or does the definition of JIT require recompiling in response to information about which code would benefit most?

Do you think for something to be a JIT it must only compile code immediately before it's used? In that case the only real JIT I know of is basic-block-versioning. I think almost all JITs will compile branches or methods to some extent before they are actually needed. Yours is probably not a reasonable definition therefore. I think a JIT is just a compiler that can compile as the program is running.

> Do you think for something to be a JIT it must only compile code immediately before it's used?

I mean, that's more or less what the name "just-in-time compiler" implies. I'm aware that the name is not necessarily a precise definition, but I'm not sure how far the definition stretches. Does JIT have a precise agreed-upon definition, or is it somewhat more vaguely defined?

Re: Firefox’s new streaming and tiering compiler

#107

Earlier quoted context omitted.

How would the client know the hash is valid?

Perhaps he means you compile the code locally, hash it, and then next time you can fetch the compiled code from a server, and check the hash matches?

That's possible; a kind of second-level cache. That assumes the compilation is reproducible, though.

Re: Firefox’s new streaming and tiering compiler

#108
post #6

Earlier quoted context omitted.

That would assume you trust the server not to give you malicious machine code (which you of course cannot!). wasm is specified in such a way that it is still sandboxed by the VM that compiles it. If you fetch arbitrary machine code, you cannot verify it and that leads to huge security holes!

> which you of course cannot! Didn't Google's NaCL implement verification of sandboxed machine code?

Maybe, but at what cost? I wouldn't be surprised if the cost of verifying the machine code was higher than the cost of compiling wasm to machine code.

Re: Firefox’s new streaming and tiering compiler

#109

Earlier quoted context omitted.

Do you think for something to be a JIT it must only compile code immediately before it's used? In that case the only real JIT I know of is basic-block-versioning. I think almost all JITs will compile branches or methods to some extent before they are actually needed. Yours is probably not a reasonable definition therefore. I think a JIT is just a compiler that can compile as the program is running.

> Do you think for something to be a JIT it must only compile code immediately before it's used? I mean, that's more or less what the name "just-in-time compiler" implies. I'm aware that the name is not necessarily a precise definition, but I'm not sure how far the definition stretches. Does JIT have a precise agreed-upon definition, or is it somewhat more vaguely defined?

No these terms never have precise meanings, and trying to debate them too much doesn't achieve much. But if your definition doesn't actually work for any examples of the thing you're defining at all except one then it's probably wrong.

Re: Firefox’s new streaming and tiering compiler

#110

Earlier quoted context omitted.

> Do you think for something to be a JIT it must only compile code immediately before it's used? I mean, that's more or less what the name "just-in-time compiler" implies. I'm aware that the name is not necessarily a precise definition, but I'm not sure how far the definition stretches. Does JIT have a precise agreed-upon definition, or is it somewhat more vaguely defined?

No these terms never have precise meanings, and trying to debate them too much doesn't achieve much. But if your definition doesn't actually work for any examples of the thing you're defining at all except one then it's probably wrong.

Ok, fair enough. I was worried that there was some precise definition I had missed, but if that's not the case, I agree there's no point in debating it.
Post reply on HN