5 ms·
IMHO it's pretty simple: low-level performance. Even 25% slower than the output of a good C++ compiler means a browser goes from first to last place in many ben
by pcwalton 13y ago
IMHO it's pretty simple: low-level performance. Even 25% slower than the output of a good C++ compiler means a browser goes from first to last place in many benchmarks. People expect the page to scroll at 60 FPS and that rules out GC pauses longer than 16 ms. Browsers are a mature market and unless the proposed replacement has the performance of C++ it's not worth the risk. Horizontally scaling server software has greater flexibility for performance; hence the explosion of languages on the server side while the client side is largely confined to languages developed in the 80s.
Parallelism may be the key to disruption here however; if a new browser can scale better to the multi-core present and future it may be worth taking a small hit over C++ in the sequential case. That's Servo's bet (although Rust strives for C++-level performance even in the single-threaded case).
- dustingetz 13y agoIn 2013 I don't think it has anything to do with the merits of C++ vs other languages. You can surely write a better browser from scratch in a language like Haskell; a project this important could even implement their own JVM if they want to use Scala and need to guarantee some performance characteristics. Like how Facebook wrote their own PHP compiler/optimizer. A browser that breaks on non-standard markup is worse than useless. Legacy compat is so critical and so complex that a rewrite is just not an option. Lots of money and time is invested in battle-tested security etc, you can't just throw that investment away. Again, like how Facebook is still written in PHP.
- Arelius 13y ago> You can surely write a better browser from scratch in a language like Haskell. This isn't something quite as self-evident as you make it.
- cwzwarich 13y agoHaving written web browsers / browser engines and compilers for functional languages, I don't think you could do this with anything that exists today. And if you did it, the result would not be idiomatic Haskell; it would just have one huge monad threaded through the entire thing with no pure portion. You would also probably have to drop down to unsafe manual memory management for performance reasons.
- deleted 13y ago[deleted]
- ww520 13y agoI think you are too optimistic. Even today C++ is probably the best choice for writing a general purpose browser from scratch.
- tzs 13y ago> People expect the page to scroll at 60 FPS and that rules out GC pauses longer than 16 ms How do people writing games in Java or C# deal with this? Gaming is an area where people expect smooth, high speed performance.
- munificent 13y agoObject pools: they allocate objects upfront and re-use instances instead of creating and releasing them.
- Arelius 13y agoThis is one trick, among many. Most of which negate many of the advantages of GC in the first place.
- zurn 13y agoThe advantages of memory-safety remain.
- pcwalton 13y agoSome advantages of memory safety remain. When using pools, you don't get protection against use-after-free or leaks. It does somewhat mitigate the consequences of those, however: it's much harder for a use-after-free to become a security exploit in a pool in a GC'd language, for example.
- zurn 13y agoSounds like you have a specific kind of object pool implementation in mind? Invalid object refs don't have to break the memory safety, cf. weakrefs. An object pool can also be implemented without unsafe bulding blocks or other language support, as a pool of objects that are manually recycled after the pool lifetime is up. Then a bug could let you confuse a previous generation object witha current-gen one, but would not break memory-safety either.
- deleted 13y ago[deleted]
- zxcdw 13y agoSo what you're saying(or, implying, as I stubbornly deduce from references to GC, sue me ;)) is that it is unfortunate that we can't use... gasp Java? Oh dear.
- nilliams 13y agoOr the many other GC'd languages game devs might like to use: Python, Ruby, JavaScript, Scala, Clojure ... Yes, it is unfortunate we can't use those languages and achieve the same performance as manual memory management in C/C++.
- Arelius 13y ago> GC pauses wouldn't really be a problem if development in the past twenty five years had been focused on hardware assisted incremental garbage collection Hardware assisted GC isn't free. It comes at a large cost of silicon* and power. And makes a lot of assumptions and puts a lot of restrictions on your GC. And it still doesn't solve the caching problems related to automatic memory management. * The silicon has to come out of the die budget somewhere. likely decreasing performance on other operations. Or removing other special purpose instructions altogether (SIMD?)
- cwzwarich 13y agoThe hardware features required for hardware-assisted GC are actually pretty simple. See https://www.usenix.org/legacy/events/vee05/full_papers/p46-click.pdf https://www.usenix.org/legacy/events/vee05/full_papers/p46-c... for a description. Other features like hardware-assisted write barriers (simple) and transactional memory (much more complex) can be used to increase performance.
- Dewie 13y ago> Even 25% slower than the output of a good C++ compiler means a browser goes from first to last place in many benchmarks. Do most people care about that, though? Like, go to a page that demonstrates browser-benchmarks, then uninstalling their current browser, downloading the best one and installing it? Or are the browser they got "bundled with the OS" fast enough for them? (not to mention exporting and importing all their bookmarks.) Maybe I've been spoiled by having fast browsers, but I can imagine that I could live with that, if I gained other benefits. Most of the websites I read are either very "static" pages for mostly reading stuff, or videos. I am pretty content as long as webpages load in around one second (I can probably live with more than that too) and my videos buffer at a respectable rate. If I got a browser that was 25% slower, but on the other hand was very much less prone to buggy behaviour, then that sounds like a great deal to me as a user. Chrome is annoying me right now because of the relatively recent behaviour of freezing the UI-frame when I make a new tab: I can type in text but it's effectively hidden to me, and I only get to press enter and see what I wrote after up Five seconds. Another problem (very common in Chromium) is the whole webpage being unresponsive until the whole page is loaded, instead of loading stuff like text and letting me navigate the loaded stuff. If these things could be actually fixed for me, the lazy user (ie without me changing browser or diddling around with stuff that I shouldn't need to diddle around with in order to have a performant browser), then that sounds like a good deal to me.
- rossjudson 13y agoWould you rip out the guts of a modern browser and replace them with brand-new code that you claim is 25% faster? No way. You'd be laughed out of the room. How exactly would you get a radical expansion of the attack surface past a security audit? You might do it in a game, where security is (usually) not a primary concern. Anyone who would sacrifice browser security for a 25% increase in performance is a fool. Browsers need to be secure, and then performance needs to be "good enough".
- pcwalton 13y ago> Would you rip out the guts of a modern browser and replace them with brand-new code that you claim is 25% faster? We do it all the time.
- rossjudson 13y agoI'll bite. Which browser is that?