17 ms·
I think that browser developers are optimizing the wrong thing. Specifically: they optimize for execution speed while they better optimize for minimum memory us
by codedokode 5y ago
I think that browser developers are optimizing the wrong thing. Specifically: they optimize for execution speed while they better optimize for minimum memory usage instead. Let me explain why this is more important.
Let's say I am visiting a properly made website and it takes 10% of CPU to render. Even if browser devs make their browser twice faster, it will only save 5% of CPU time - and that would be completely unnoticeable. You might ask, what about modern websites, built with D*t compiled to webassembly, GPU acceleration, reactive frameworks, material design and capable to load the multi-core CPU at 100%? I am not using such sites so I don't care.
Now let's look at memory usage. Optimizing for speed usually causes increased memory consumption, and this increases the chance of invoking swapping. If the system starts swapping, it becomes orders of magnitude slower. No speed optimizations will matter in this case.
Therefore if you are targeting wide audience, and not only mac users, then you should be optimizing for memory usage. If the browser could use two times less memory while using twice amount of CPU time that would be perfect. Just think how many laptops with 2 or 4 Gb of RAM would become usable again.
- wwtrv 5y agoThe laptops with 2 or 4 Gb of RAM (e.g. Chromebooks) are also likely to have Celeron or MediaTek CPUs which might struggle much more than that, also unless you have multiple tabs open 4GB of RAM might not be that bad. And given a choice between being able to open several tabs all of which are barely functional and being stuck on a single website at at time which runs smoothly I'd definitely choose the later (of course the tradeoff is probably not as straightforward, then again it's not completely obvious to me that optimizing for speed would necessarily result in higher memory consumption). IMO even if they are optimizing for Macs, I'm not sure this approach would make sense (assuming the tradeoff between CPU performance and RAM usage exists) since they are much more likely to have less memory and better CPUs than PC laptops (e.g. you can probably easily get a Windows laptops with 32GB for $1000 or less).
- omnimike 5y agoThe reason for the focus on CPU time is that it has the larger impact on battery life.
- tasn 5y agoYou'd be surprised (I was), but high memory usage is also a power drain.
- tehbeard 5y agoSo is the screen, keyboard, WiFi/ethernet adapter... Do you have any graphs/charts/tables to substantiate the claim that high memory usage is power hungry enough to be optimized for vs CPU?
- dspillett 5y agoIt isn't a surprise when you consider indirect power costs: CPU use filling that memory and reading it back later, extra IO because the memory consumed is not available for caching purposes (or worse because paging out to more power-expensive storage is happening), and so forth. It is like when people say page fragmentation in SQL Server isn't important any more because random access is so fast due to SSDs and other IO subsystem improvements – pages are held in RAM in the storage format so if they are only ⅔ filled you are wasting ⅓ of the allocated memory which can have significant performance effects if your common working set is not smaller than the memory available. Though in fairness, I would agree that this issue is usually quite far down the list of things that need addressing in poorly performing database & applications.
- IshKebab 5y agoThat sounds unlikely since DRAM is all refreshed constantly regardless of whether or not it is being used. Perhaps you meant storing and fetching from memory lots impacts battery life?
- kalleboo 5y agoWith higher memory usage you have less free memory for caching so you hit the disk/SSD more often. If it gets too high you start swapping which is really bad.
- ggreg84 5y ago> Optimizing for speed usually causes increased memory consumption, Lol, no? If your benchmark is memory bound, reducing memory usage is probably the simplest way to make it faster.
- rat9988 5y agoHe is right though. Chrome isn't memory bound... yet.
- ggreg84 5y agoDo you have a reference?
- viraptor 5y agoThere are some truly memory-bound problems, but I believe the parent comment is correct on average. A lot of common speed issues can be helped by: adding a cache, adding an extra lookup index, memoising calculated values, adding a new denormalised data projection, etc. I think "usually" was a fair description.
- oxplot 5y agoIf you improve CPU performance, you can compress memory with the leftover cycles. This is what I do on my RPi which allows me to run quite a few memory hungry processes at the cost of some CPU (which is fine, because those processes are mostly idle).
- KMag 5y ago... and some of us disable swap to prolong laptop-motherboard-soldered-SSD lifetime, and Windows 10 regularly bluescreens when memory is exhausted and swap is disabled.
- bscphil 5y ago> You might ask, what about modern websites, built with D*t compiled to webassembly, GPU acceleration, reactive frameworks, material design and capable to load the multi-core CPU at 100%? I am not using such sites so I don't care. Does this just mean that browser developers are optimizing for the right thing, just not something that benefits you? Tons of people use these sites. > If the system starts swapping, it becomes orders of magnitude slower. Not really. Browsers try to keep stuff in swap that they probably won't need. Swapping doesn't become a problem until you're almost out of memory as well, and then you might get thrashing. But there's a wide range where CPU optimizations make sense. And such a large fraction of people have SSDs that even swap access can be pretty fast.
- _Algernon_ 5y agoI disagree. Memory is cheap. Battery life isn't.
- aurora72 5y agoHigh memory consumption eats battery life too
- _Algernon_ 5y agoGiven that only one of those components tends to have active cooling as a requirement, I'll assume that the difference in energy consumption is at least an order of magnitude. Happy to be proven wrong though.
- dspillett 5y agoEven in the lowest power consuming of sleep modes volatile RAM still needs to be constantly refreshed, so considering a device with a duty cycle like that of a phone or tablet you might find the power being used for memory is more significant than you think. But that refresh is essentially a fixed cost from a software PoV, if the memory is not used it'll still be refreshed, where chunks of modern CPUs can be almost completely turned off when not needed. There are secondary costs of extra memory use though (CPU to populate & later read, IO subsystem activity as there is less free memory for cache, etc.).
- codedokode 5y agoYou cannot install "cheap" memory into older laptops. Battery life doesn't matter for laptops as they are mostly used at home.
- yrro 5y agoI have two identical laptops, one with 8 GiB and the other with 32 GiB of RAM. The former lasts over 2 weeks in S3, the latter not even a week.
- ihateolives 5y ago
- franga2000 5y agoWell all know what the "solution" here is: to have multiple browser vendors, each optimising for something else. Imagine having a lightweight browser ran a bit slower but could run on a potato with 512MB or RAM. Or one that optimises for viewing static documents (you know - websites) and so uses barely any CPU when idle, but might not support all the crazy JS features. Of course, having turned browsers into virtual machines, there isn't much specialisation that can be done without breaking things. Might it be time to create a subset of features that sites could limit themselves to and allow browsers to use a simpler and faster render pipeline? You know, like what we thought AMP was going to be before it turned out to have Google's monopolistic shit smeared all over it.
- alyandon 5y agoOf course, having turned browsers into virtual machines I really wish browsers would take that one extra step and utilize their intimate knowledge of what memory allocations belong to which sites that are actually active and implement paging to disk instead of gobbling up ram like it is a infinite resource and expecting the general purpose OS to figure it all out.
- zild3d 5y ago> I think that browser developers are optimizing the wrong thing. > You might ask, what about modern websites [...] I am not using such sites so I don't care. They might be optimizing the wrong thing for you, but the majority do use "modern sites"
- ksec 5y agoThere are over 3B devices using Chrome as browser. 2.5B of them are either on Laptop, Smartphone or Tablet. Average Opened Tabs is still under 5. As much as I want them to optimise for memory usage. Taking less CPU time for rendering is extremely important for battery. Not to mention faster site is noticeable. And that is what sells. Chrome was faster than everything else when it launched. ( May be apart from Opera )
- dwiel 5y agoHow do you know that isn't just measuring that most people keep to 5 tabs because otherwise everything grind to a halt. That's about how many tabs my wife's old Chromebook can handle before she has to start closing old tabs.
- ksec 5y agoI am assuming it grind to a halt because it is CPU bound and not Memory bound? In that case the premises of CPU optimisations are not important would be, inaccurate? In reality it is complicated when we have extra CPU cycle to burn developers tends to put fancy new things. Which is basically what andy giveth bill taketh away.
- codedokode 5y agoProbably "everything stops" because tabs consume too much memory and OS starts swapping data to disk.
- dwiel 5y agoIt's because she runs out of memory and it starts swapping, I check the task monitor or whatever it is called in chrome. Some of the AdBlock extensions are taking up ram as well.
- yc4joe 5y agoI agree 100% -- and, as a front-end developer for more than half the time I've been writing code for web applications since 1995, I think my opinion should matter. I've seen the trends and can relate to exactly this point. Well-stated and, frankly, late to the public eye (but, that's my fault since I should've written something similar years ago).
- jollybean 5y agoThey optimised mostly for startup time, not execution speed. Java for example uses runtime VM information before it starts compiling classes to machine code. That means it's faster in the long run, but requires a 'warm up time'. Obviously a bit better for server side.
- jeffbee 5y agoMan, that math did not make any sense at all. A program can't use 10% of the CPU. It either uses the CPU or it doesn't. If a page renders with "5% CPU" measured over some interval that means it rendered twice as quickly, which is a substantial improvement.
- YetAnotherNick 5y agoUse tabsuspender for that. It saves memory by suspending the tabs which is not used for quite some time.