Firefox Javascript Engine Becomes Single Threaded
An anonymous reader writes with news about work on Mozilla's Javascript engine. Quoting Mozilla engineer Luke Wagner's blog: "With web workers in separate runtimes, there were no significant multi-threaded runtime uses remaining. Furthermore, to achieve single-threaded compartments, the platform features that allowed JS to easily ship a closure off to another thread had been removed since closures fundamentally carry with them a reference to their original enclosing scope. Even non-Mozilla SpiderMonkey embeddings had reportedly experienced problems that pushed them toward a similar shared-nothing design. Thus, there was little reason to maintain the non-trivial complexity caused by multi-threading support. There are a lot of things that 'would be nice' but what pushed us over the edge is that a single-threaded runtime allows us to hoist a lot data currently stored per-compartment into the runtime. This provides immediate memory savings."
ye
On second thought, let's not go to Camelot. It is a silly place.
God save the Queen !!
"memory savings".
Maybe I'm missing something, but then how will "threading" (i use that term extremely loosely) methods like SetInterval and SetTimeout be implemented?
Aren't single threaded programs bad?
The great technology inspired by illustrous Windows developers building the whole applications as everything-should-access-everything model, was abandoned!
Contrary to the popular belief, there indeed is no God.
"us to hoist a lot data currently stored"
I really wish I knew what this phrase meant. It sounds fascinating.
But seriously, if there's no performance gain from multithreading, it can be a really good idea to move away from the complexity of it. There's a lot of traps people can fall into with concurrent code if they don't know what they're doing.
It's an evil sentence for saving the tiranny originated by the supposed saved Queen, so many believers of this simple statement are simply fooled. Why to believe in their damn words instead of saving themselves?
For religion, the more correct statement should be: God saves his dear son 1st, Jesuchrist..
The Javascript Engine is single threaded because when it is in the client-side, the client-side's process is supposed to be a single thread. The issue is totally different when the Javascript Engine is used in the server-side that almost processes of many web servers are concurrent (aka multi-threaded).
Javascript is not a CPU-powerful language, so it's better to re-design the language (or to create one new) and its paradigm (e.g. instead of slot-based, untyped and single threaded, it should class-based, typed and multi-threaded) for gaining something luxurious of CPU performance and to be lesser memory-hog.
JCPM
Horribly.
Operating systems were widely available, Firefox has still failed to make a 64-bit dist
Wait, I thought that the goal all along was to move AWAY from the Giant Single Thread of Javascript model?
Oh.
I see what you did there.
The sad thing is that patterns have become so many and so complicated that I can't tell if you're joking or not. Proactor pattern? Is that really a thing?
If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.
Firefox Add-Ons (well, at least Extensions) are JavaScript code and chrome directives. Will these get a separate thread?
I really wish I knew what this phrase meant
You need to talk to the Executive Vice President of Sales and Marketing. Call for an appointment.
My initial sense of this, is that they are making a huge mistake here. I'll have to do more research, but my feeling is that they are moving in the wrong direction with this decision.
One of the really cool "baked in" things with functional style language is their fundamental support for horizontal scaling across CPUs. My hope has been that javascript evolves towards this, so that the generic suite of functional methods become massively performant on a larger scale with map/reduce/fold/each calls.
Closures present a bottleneck here, but it seems like a reasonable runtime could make some intelligent prediction about whether the isolated function is a closure or not, and ship it off to a different CPU/thread depending on optimization strategies, or even estimated closure size. Even better, this could be done at runtime with some runtime optimization based on execution metrics of an anonymous/declared function in-context.
At the point of calling the map/reduce/fold/each function, the runtime should be able to decide whether to parallelize out the call, or even use some language extensions to let the developer specify the threading.
The point is, now that they're making this decision, all of those options are gone from FF. And at a terrible time too. As we move toward CPU architectures that encourage parallelism, Mozilla is taking js off the table as a first-class language able to easily exploit those new architectures. That strikes me as a huge mistake, and I'm struggling to understand the rationale.
Drinking habits can be dangerous. You can choke on the cloth and the nuns will wonder where their clothes are.
" With so much happening in the computing world, now seemed like the right time to write "Welcome to the Jungle" - a sequel to my earlier "The Free Lunch Is Over" essay. "
So then, we will have this released, say ummmm.... 2 hours from now.
Sounds good to me. Multi-threaded synchronization is notoriously hard to get right, so why risk it unless you *really* need the multicore performance?
And the thing with browsers isn't that they need access to more resources – they should have *less* resources (CPU, memory) and use them better. I'm not particularly happy with dedicating 25% of a CPU just to have a browser window with some tabs open while I'm working on something else – particularly not while I'm on battery. Why can't I get Firefox (and/or Chromium) to suspend the JS engine and any plugins on tabs that aren't visible anyway? Yes I know that you *sometimes* want to listen to audio from another tab, but most of the time even that is just annoying.
Oh, and just sandbox the damn stuff, and get rid og 93% of the possible security issues...
But am I annoyed enough to file wishlists in Bugzilla or start writing patches? Not really, but that's possibly because I believe complaining on Slashdot should be more than enough to get things fixed.
I don't like this because it's clearly a step backwards. Yes, Shared Nothing does work but it puts a limit on how many cores you can ultimately use. You won't get speedups from processors with more and more cores.
I'll agree that it's a pain to try and make good parallel/concurrent code work. I've seen too many cases of we'll optimize with this parallel algorithm, but it only is faster in extream cases like sorting 100,000 items. I rarely need to sort anything like a 1000 items in a web page so I'd rarely use a parallel sort like that, but what they are doing sounds more like giving up rather then continuing to search for an answer for using multiple cores long term.
Just what are we going to do when we have 32 cores? Most apps I've worked on couldn't be separated into 32 separate shared nothing tasks, but I might have a couple loops that could be partitioned into N tasks.
So much for server-side javascript, where you actually need threads like nothing else.
So wait, if you run that in Songbird Browser does it become an Angry Bird? : )
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
In all seriousness, they need to do something about the extensions. Refuse to host leaky ones or something. Extensions can't be Firefox's killer feature if they make it eat all of your RAM.
I can't agree more. Things are much better than they used to be, but oofda. So much for 640K -- FF is currently using up almost 1GB with about a dozen tabs open, and with AdBlock Plus, NoScript, IE Tab2, Firebug, User Agent Switcher.
Cheers,
"What in the name of Fats Waller is that?"
"A four-foot prune."
... it'll just leak memory more slowly?
Multi-threading in JS is handled by web workers.
Oh, great! So now we're outsourcing even more textile jobs to anyone willing to work online, is that it? Sheesh!
(On a more serious note, thank you for that informative link.)
"What in the name of Fats Waller is that?"
"A four-foot prune."
We live in a world where 8GB of RAM costs $50. I'm not sure how much I actually care whether Firefox uses 500MB vs. 2GB anymore.
If only four applications you keep open all the time feel the same way you start caring quickly.
Swap is still annoying. Even when you have an SSD and cannot hear it...
"There is more worth loving than we have strength to love." - Brian Jay Stanley
Web Browsers are much more sophisticated than a text editor. If all you used them for was rendering html, then 32-bits would probably be fine. But, 64-bit could potentially be nice for things like 64-bit plugins and extensions - true, most plugins/extensions are just fine as 32-bit apps, but there could be some specialized plugins which might benefit from access to full memory.
So while they may have fixed most of the memory leaks (it still runs like shit on a Mac), let us not allow them to get complacent again. [snip] By not frequently reminding them about memory leaks, you are opening the door to yet more bloat going forward.
I believe there's a parallel with a common fable:
You saw a wolf. I said I shot many, that the wolf situation should be improved, but you kept seeing wolves. This repeated many times and made you angry.
Now lots of others are saying that there really are fewer wolves these days. Indeed, you have no reason to believe that they're wrong.
But because of the offense done to you some time ago, you're going to continue crying wolf, even given no evidence at all?
I don't understand. I guess this is an attempt to punish us? Is it that you feel like we harmed you with our lies, so you should try to harm us with yours? I'm afraid that by crying wolf, and encouraging others to do the same, may just cause us to ignore you all, which is exactly the outcome you don't want.
I'm very sorry you feel like Mozilla deceived and harmed you. But the malicious attitude here and elsewhere in this thread is getting old. Use Chrome, if you like! But don't encourage people to waste developers' time with false claims.
For me it only counts to blame the leak on a plug-in if they tell me which plug-in to nuke. If I disable 15 plug-ins, it's not even the same browser by the time I'm done. Why do all these extension leaks persist? Because there's no feasible way to push a complaint into the right bug queue. Who is responsible for this sorry state of affairs? FF-core.
In my opinion, any lost memory not attributed to a specific culprit is a leak in Firefox, the product.
I'm thrilled with the progress they've made with FF-core, once they fessed up. And I'm looking forward to more of the same with the add-ons, too. No grudges here, so long as the truth is served.
FWIW, I participated heavily during the original FF 3 beta cycle. With fewer plug-ins than now, my browser was leaking at the rate of 300MB/day. Under a heavily laden 3.6.3 that's down to about 50MB/day. Livable, but I'm not dancing a jig in the streets.
But now I've got Unity to complain about, so this seems like small fish.
Maybe we should go back to UNIX design with single threaded non-premptive kernels with horrible scaling properties.
As a separate data point, I've never had to restart firefox either on my 8GB work laptop running linux or on my 3GB home laptop running Win7.
Does this mean Firefox will stop freezing up every couple seconds while I'm trying to do complicated tasks like scrolling down a page?
...you should have just said so.
Baptise your browser!
I do a lot of photo editing, sometimes swap is simply required.
I also so no need to make my laptop noisy and power draining again with the inclusion of a spinning disk.
Yes it wears out the SSD quicker; who cares? I'm pretty sure I'll be replacing the SSD (or laptop) long before that ever might become an issue.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
80 users, 32GB, and suddenly a browser that gorges itself on RAM to fake performance optimization isn't as attractive any more. I'm looking at you, Chrom(ium).
BTW, Firefox running on my TS farm of 10 machines for 3+ years, *zero* memory related issues, and crashes are in the low 1-2% of session range after 4+ hours of uptime per session. I don't know what the fuck people are doing with their browsers to make them crash all the time. Also, flashblock is a godsend on terminal servers.
Well probably something like this http://www.youtube.com/watch?gl=US&v=_dErAZL1Hr8
There are two rules for success:
1. Never tell everything you know.
I think this affects me, as I understand it, no separate thread for web-workers.
It was my intention to use this in my Javascript Vic-20 emulators to run low ipc (1 kb/s) peripheral devices like disk drives.
As on core 2 duos it consumes most of one thread on Firefox to just do the computer emulation.
http://www.mdawson.net/vic20chrome/vic20.php
I wouldnt settle for anything below 4 gig, and I prefer 8gig for general use. Server side, 16gig is so cheap, id make it default
Liberty freedom are no1, not dicks in suits.
As an exercise in insanity, I tried to install a modern Linux distro on an old Pentium II system with only 128M of RAM. Used btrfs for the heck of it. It was all going well until I tried to run Firefox 9.0.1. Thrashed that system mercilessly. Never mind actually showing a web page, just starting up blank was extremely slow. Sometimes I saw the "unresponsive script" popups on Firefox's own Javascript. I hacked out everything that used memory, dumping the LXDE desktop environment for a plain old window manager (jwm), and this helped, but it's not enough. Turned off images and disabled Javascript. It still thrashes swap.
Chrome didn't do any better. Firefox 3.5 worked okay on an even smaller system (96M of RAM). Version 3.6.8 + LXDE works fine on a system with 192M of RAM. Here's hoping their MemShrink effort scores more big wins.
Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
There you go, no flash, I bet other problems are caused by flash, i know often flash can leak too but appear as firefox.
We need to kill flash.
Liberty freedom are no1, not dicks in suits.
Pentium II is from 1998. You should use a browser from a comparable age. FF 3 is about at the limit of what you can expect to run on that hardware reasonably well. Anything more recent has been developed with more CPU and RAM in mind but you might check LuaKIT. Definitely not intuitive but slim.
If you had looked at system requirement, you would have seen FF9 recommends 512 MB of RAM. Earlier versions necessitate less, linked to the most common configuration (read: amout of avaible RAM) at the time.
btrffs sucks for frequent filesyetem sync calls, even the author of btrfs says that.
Firefox is known to do many filesystem sync calls.
So I'm not surprised the combination sucked.
You should try ext4, you could even choose to use ext4 without journaling.
New things are always on the horizon
I can see the why this is a problem, I have seen memory usage upwards of 1 Gig in real memory, so yes it seems like a good choice but is this not severely restricting the future of this browser? I mean Memory management is a problem, stopping processes, (threads that have already begun is the issue and that is client side)
Multi-threading, is the future think of it like a multi dimensional array, where you can productively access several products at one time, with the web becoming more and more of a SAAS based property this move is severely restrictive of what could be a great thing.
I am glad I heard this story because I was developing a product exclusively for use with Firefox now I am going to have to move it over to Google Chrome.
The simple fact is that the desktop is slowly moving over to SAAS and with a single thread, the result will be a slow unresponsive browser that sucks
I'd be interested to know how the latest Opera runs.
To infinity, and beyond!
You insist these are only "one guy". You should have left that out if you wanted to prove your point. I'm not sure if you're familiar with filing bugs, but if one guy reports something, and another guy reports the same thing, one of those will be closed as a duplicate. If one guy is having that issue, it most likely means more than one guy is seeing it, and either not noticing, not reporting, or watching that bug report because either he found it was already reported or his was closed as a dupe.
Also, the fact that there is no reply doesn't mean it's not an issue. Effectively no insight can be had, it does not prove there are or are not memory leaks.
Given the history of FireFox, where devs insisted for *years* that there were no problems, and then suddenly a pile of memory allocation problems got fixed, I give no more credence to a developer saying it's "probably" not an issue than a user reporting it as an issue. It's a dead split in terms of reputation, and as long as it remains open I give the reporter the benefit of the doubt. I think that's fair.
It sounds like you believe FireFox is rock-solid, and are looking for any evidence to bolster your case, rather than being dispassionate and accepting and evaluating evidence on its own merits. Maybe if you try again, you might be able to re-phrase this in a way that might away someone who does not already agree with you.
Thanks! That could explain why I saw btrfs processes using so much CPU time. btrfs-endio sometimes used more than Firefox itself.
Thing I don't like about the ext's is they're not very space efficient, and that can make a difference on tiny hard drives such as the 8G this system has. Reiserfs is pretty good with space, and reiser4 was even better. Been wishing for btrfs to mature quickly, as reiser4 is probably dead. I found at least 1 gotcha with xfs. If you don't tune the parameters (block size and such), deletion of a large tree such as the Linux kernel source can take a very long time. Haven't tried any other file systems.
Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
No crashes in two days. Firefox is for the most part responsive despite the tests being done (deliberately) in the worst environment I could think of - my work Ubuntu VM. The only time it crawled was using Blogger to write a blog entry, and once I finished, it stopped crawling, which... well, that was itself a massive improvement, if I did something to make it crawl, typically the only way to stop Firefox crawling was to restart it. No longer.
Yahoo Mail and Twitter, together with less memory intensive tabs like GMail, are still sitting there and are usable. I can never figure out what the actual memory figure is, but with a lot of tabs open, it's somewhere between 600M and 1200M (explicit vs vsize); typically I'd expect the figures to be over 1G/over 2G respectively within an hour or two of restarting the browser.
I have to say I'm absolutely delighted. My favorite browser is usable again.
Thank you. Thank you thank you thank you! You've done a wonderful thing.
You are not alone. This is not normal. None of this is normal.