Slashdot Mirror


Slashdot Asks: Why Are Browsers So Slow? (ilyabirman.net)

Designer Ilya Birman writes: I understand why rendering a complicated layout may be slow. Or why executing a complicated script may be slow. Actually, browsers are rather fast doing these things. If you studied programming and have a rough idea about how many computations are made to render a page, it is surprising the browsers can do it all that fast. But I am not talking about rendering and scripts. I am talking about everything else. Safari may take a second or two just to open a new blank tab on a 2014 iMac. And with ten or fifteen open tabs it eventually becomes sluggish as hell. Chrome is better, but not much so. What are they doing? The tabs are already open. Everything has been rendered. Why does it take more than, say, a thousandth of a second to switch between tabs or create a new one? Opening a 20-megapixel photo from disk doesn't take any noticeable amount of time, it renders instantaneously. Browsers store their stuff in memory. Why can't they just show the pixels immediately when I ask for them? [...] Unfortunately, modern browsers are so stupid that they reload all the tabs when you restart them. Which takes ages if you have a hundred of tabs. Opera was sane: it did not reload a tab unless you asked for it. It just reopened everything from cache. Which took a couple of seconds. Modern browsers boast their rendering and script execution performance, but that's not what matters to me as a user. I just don't understand why programmers spend any time optimising for that while the Chrome is laughably slow even by ten-years-old standards.Do you agree with Birman? If yes, why do you think browsers are generally slow today?

25 of 766 comments (clear)

  1. Why they are slow? by nospam007 · · Score: 5, Insightful

    Because we need a canvas-blocker add-on and a flash-blocker add-on and a cookie warning remover add-on and add-ons to remove all the ads on the page and we need add-ons to remove the dozens of trackers to protect our privacy and also add-ons that remove all the social buttons (twitter, FB, etc) which share our behavior even if we are not a member and add-ons that remove all the javascripts that load popups, do unwanted refreshs and Greasemonkey to make some pages readable and remove the ads that are inside the articles and we need an add-on to circumvent the anti-adblockers and .....

    1. Re:Why they are slow? by nucrash · · Score: 5, Interesting

      Pretty much this.

      I feel that so many websites have gone to insane levels on ad loading that the web has become almost unusable by some standards.

      Yes, I say that with at minimum, 12 tabs open, but most problems I have are around specific ad revenue driven, ad block loathing sites.

      --
      Place something witty here
    2. Re:Why they are slow? by JaredOfEuropa · · Score: 5, Informative

      It's not just ads; a lot of websites pull in JS helper scripts from other sources (instead of hosting local copies of their own). And those sources do not always have the best performance.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    3. Re:Why they are slow? by SQLGuru · · Score: 5, Interesting

      The idea of not hosting your own local copy is that if everyone uses a common source for the library, then the browser should already have that resource cached even if it's the first time you hit the page. For large enough libraries that the Google CDN (or another CDN) includes it, it's worth it.

      https://developers.google.com/...
      https://www.asp.net/ajax/cdn
      https://www.keycdn.com/support...

      Now, for obscure libraries, you're better off hosting your own so that you can control the version and not worry about the referenced script changing/moving/breaking stuff.

    4. Re:Why they are slow? by Anonymous Coward · · Score: 5, Informative

      Using a good, fast third party source

      LOL

      I see what you did there.

      Also, I just clicked on AdBlock Plus --> Open Blockable Items. There are 31 scripts on this page.

      31 MOTHERFUCKING SCRIPTS ON ONE PAGE!!! You people are insane.

    5. Re:Why they are slow? by fuzzyfuzzyfungus · · Score: 5, Interesting

      This would involve admitting the (arguably ugly; but undeniable) truth that web pages have become a somewhat dysfunctional software development platform; but it'd be nice to see browser caching mechanisms that don't just treat giant JS libraries as a special case of cacheable assets generally and hope for the best; and instead offered something more in the vein of what Linux package managers do.

      If you host your own; the user ends up downloading a copy even if it is identical to the one they pulled from somebody else for a different site that uses the same library. If you avail yourself of Google's...generous...hosted offer, the user is more likely to cache; but then every load of your page also involves a chat with Team Mountain View.

      Ideally, you'd specify that you use JSLibXYZ, with cryptographic has and/or signature specified, and at least one source for a client who doesn't have it to get a copy; but the user's browser could make use of JSLibXYZ from any source, so long as the hash and signature match, since that provides assurance that it's the same thing. Caching mechanisms based on domain of origin are sensible enough for assets that are likely to be site specific(pictures, stylesheets, etc.); but, like it or not, giant javascript libraries, many shared across a large number of otherwise unrelated sites, have a lot more in common with dlls than with images; and it would be handy if they were treated as being a different case. With hashes and/or signatures, you could ensure integrity even in cross-site sharing situations; allow caching to work regardless of how the site operator has set up script hosting, and end the choice between 'serve yourself, lose out of caching/let google do it, get caching but add a 3rd party to everything you do'.

    6. Re:Why they are slow? by mysidia · · Score: 5, Interesting

      It's not just ads; a lot of websites pull in JS helper scripts from other sources (instead of hosting local copies of their own). And those sources do not always have the best performance.

      What we should do is get the web standards updated to add a Rule:

      Remotely-loaded scripts (Loading from a different server) must specify a SHA256 sum in the Script tag such as
        <script src="https://example.com/mycode.js" integrity="sha256-7d774a8ff0e73f2791c3a12dfc3ef1f9a1a640d470584b9b9222d395e8519fc5">

      If the hashcode is not specified, then the script will not be run.

      If the hashcode IS specified, then it can be cached by any 3rd party.
      The URL becomes "Advisory", and Popular hashcodes can be distributed by Amazon, Google, or your local ISP.

      There should be a way to have a DNS suffix DNS record to specify local object-caching servers that can be queried by code.

      Caching is permanent. An outage of the original source server has no affect.

    7. Re:Why they are slow? by holophrastic · · Score: 5, Insightful

      You're wrong. I've been doing this for three decades now. If you're serving a page to a client, sending them to a third-party to get the library always sucks. Even if they've already got the library disk-cached, it's actually slower to access the disk cache, and check the cache age, and verify that there isn't a newer library version (did you know the browser often goes round-trip just to check?) than it does to simply serve the library in-line.

      Serving the library yourself can still run in parallel, and it often reuses the same primary connection, so it's about as fast as your server can handle.

      Now you're going to mention the browser's memory cache, instead of disk cache. First, nowadays, with each-tab-in-a-separate-sandboxed-process, those memory caches ain't as fast as they once were. But even when they are, you just ain't a'gonna beat in-line scripts.

      Benchmark it yourself. Serve 100KB of javascript in-line, in the middle of your html file. Compare that to a separate src= js file. Mid-stream, in an HTML file of another 100KB, the javascript runs at full download speed, with full text transmission compression. Those 100KB easily compress down to 50KB, more often 25KB, mid-transmission, and at any modern residential bandwidth, you're talking about the tiniest of fractions of a second. No disk access, no file handles, no separate rendering processes, no sandboxes, and, most importantly, no virus scanners, no swapping.

      But it does eat up your server's bandwidth costs.

      If you're huge, amazon style, then you want to off-load cycles and bits anywhere you can. If you're not huge, then the added 10% bandwidth costs mean nothing to you.

    8. Re:Why they are slow? by bmo · · Score: 5, Insightful

      >somewhat dysfunctional

      DOOM was 16MB. A whole game in 3D with full on-the-fly animation and sound effects and music. That was amazing for the time when Myst was a game that served up mostly static images.

      A web page mostly serves up text, static images, and sometimes video.

      Yet this needs 16MB to be downloaded to be functional, somehow.

      >somewhat dysfunctional

      Try completely dysfunctional

      Oh, and to the assholes who put in autoplay video that you can't turn off/pause: die. in. a. fire. Your pages actually last 5 seconds in my browser tab, and I'm sure this is the other case with people who are either on mobile, or just simply want to be quiet.

      --
      BMO

    9. Re:Why they are slow? by lgw · · Score: 5, Interesting

      You're talking about fast, as seen by the user. They don't care about that at all - they're optimizing for fast as seen by the server: less bandwidth. Anything they can offload is a win, no matter how much the user experience sucks.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    10. Re:Why they are slow? by fnj · · Score: 5, Informative

      OK, I just benchmarked 1000 forks in C++ on the lowest-end desktop Sandy Bridge Core i3-2120T running at a reduced frequency of 1.6 GHz. I got 89,130: a whopping 89.13 microseconds per fork.

      #include <chrono>
      #include <iostream>
      #include <unistd.h>

      #define N 1000

      int main()
      {
          auto start = std::chrono::system_clock::now();
          for (int i = 0; i < N; ++i)
          {
              int pid;
              if (!(pid = fork())) {
                  exit(0);
              } // std::cout << pid << '\n';
          }
          auto stop = std::chrono::system_clock::now();
          auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
          std::cout << elapsed.count() << " microseconds for " << N << " forks\n";
          return 0;
      }

    11. Re:Why they are slow? by ArhcAngel · · Score: 5, Informative

      Looking at RequestPolicy this page redirects to 41 other sites.

      41 MOTHERFUCKING REDIRECTS ON ONE PAGE!!! You people are insane.

      --
      "A person is smart. People are dumb, panicky dangerous animals and you know it." - K
    12. Re:Why they are slow? by profke · · Score: 5, Informative

      Ghostery

    13. Re:Why they are slow? by Anonymous Coward · · Score: 5, Insightful

      I really don't mean to attack you personally (really, I don't) but your post is a great example of a huge and growing problem in society in general: people who are very very sure of themselves, write well, sound authoritative, but are WRONG.

      Most, if not all, of your argument is based on fast network. Far too many programmers these days just assume huge network bandwidth. They think nothing (MS) of starting a "background" update process which can try to download GIGABYTES of unwanted crap.

      News flash: not everyone has 10GB Internet, Core i7 or better CPU, 16 GB RAM, 1 TB SSD, etc.

      And stop the arrogant attitude of telling everyone they're using dinosaur computers, to "upgrade" everything, etc. By expecting everyone to be on fast Internet, etc., you're shutting out a chunk of your market. I've stopped using many major news sites because a redesign not only looks terrible (if it's readable at all) or takes so long to load it's a waste of my time. The advertisers need to know this, right?

      My poor mom bought a "smart" phone (Android) 18 months ago. Several well-meaning (over-confident, sure they know everything tech) "helped" her by installing many apps. She did not buy a huge data plan, and in 1 month was dozens of times over her data limit- just in the apps constantly 1) phoning home, and 2) updating themselves. The provider was kind enough to forgive her and she gave me the phone.

      And while I'm at it, how about an International law stating that NO website will ever be allowed to download, stream, or otherwise hog network bandwidth without the users 100% knowledge AND permission. Example: I'm trying to read a news article, and an unwanted window starts playing a video without my request nor permission.

      How about ALWAYS, with NO exception, asking the user how much bandwidth they are OK giving up? How about testing network bandwidth BEFORE doing huge downloads? And don't forget latency while you're linking nested .js from around the world.

      About 60-70% of my browsing is done on Old Opera (11.x) because you would be stunned at how much faster most websites are with javascript OFF. I know, all too well, how many websites barely work, or not at all, with javascript turned off. I've studied the code and I see they render in javascript to force you to turn it on because their trackers and ad popups need javascript.

    14. Re:Why they are slow? by holophrastic · · Score: 5, Informative

      My first e-mail address had a comma in it, and token rings sucked for a lot of reasons. That's how long I've been developing web-sites.

      But I didn't say I've been building web-site for three decades. I said, quite obviously, that I've been serving pages to clients for three decades.

      You may be way too young to understand the difference between real-world practical and academic history, but the world wide web was not the start of the internet, the internet was not the start of networking, and networking was not the start of serving pages to clients.

      Caching's been around for a very long time. If you want to learn about the benefits of caching, and the pitfalls, you want to look at archive caches, not transmission caches. When access involves an elevator, or a truck, you quickly learn what does and does not make sense.

      Here's a perspective for you. When accessing a cache from a warehouse two miles away involves a truck, you get to consider the effects of rush hour traffic. So when your third-party server caches your javascript file, you get to consider that it isn't geographically in the same place as your primary server, meaning that not only does your client need to hit "another" server, with another connection, another keep-alive, and another set of caches, but it also needs to get there, through an ISP channel full of traffic. You've just doubled the amount of traffic globally. You can't ever bet on it being fast. You can only hope.

      So, of course, you have a basement cache of your warehouse cache -- i.e. the disk cache. Elevators don't have traffic; or so you say. But the warehouse is full -- always, because that's what a warehouse is. So you get to search stacks and shelves and indexes. You get to have organizational training, and inventory days. Welcome to the magic of disk thrashing. The file table is incredibly slow in terms of file handles. Welcome to WAD files. Defragging is the inventory day, by the way.

      So now you've got your reliable cache, that's only reliable under minimal load. Perfect. But some things get accessed often. So you keep a copy upstairs in the filing cabinet. But the filing cabinet is small. So you shuttle different cabinets up and down per day. Today you need the green cabinet. Tomorrow, the red. And life is good. Welcome to swap files -- memory to disk and back.

      Now you've got employees shuttling cabinets, with dollies, and elevators, and warehouses, and trucks, and traffic. And here's the kicker. You haven't eaten yet! You've got a dozen staff, countless duplicate copies of files, trucks, buildings, elevators, desks. But you haven't done a lick of revenue-generating work yet.

    15. Re:Why they are slow? by holophrastic · · Score: 5, Interesting

      Dell machines are usually designed to be quiet. That's why things are slow. But that's a different story.

      You aren't working cradle-to-grave. hitting the local disk isn't about the disk speed. Those 15ms can be zero for this discussion. Similarly, the ping to the site of 125ms is meaningless. Here's what happens, cradle-to-grave:

      Scenario 1, live streaming:
      connect to site: 125 ms
      download 200KB of html and javascript, compressed to 100KB, 1s

      Scenario 2, external file:
      connect to site: 125ms
      download 100KB of html, compressed to 50KB, 1s
      download 100KB of javascript, compressed to 50KB, 1s

      Scenario 3, external file cached:
      connect to site: 125ms
      download 100KB of html, compressed to 50KB, 1s
      wait for disk to be available, access disk for 100KB of javascript, wait for disk to spin up, 15ms
      wait for virus scan, read cache meta data, determine that our cache file isn't already too old, 1s
      HEAD the web-site file, to compare meta data, check to see that our cache is good enough, 1s
      -- look at all of the side-work involved, and we're still hitting the site much of the time to check the cache anyway!

      Scenario 4, external site
      connect to site: 125ms
      download 100KB of html, compressed to 50KB, 1s
      connect to second site: 125ms
      download 100KB of javascript, compressed to 50KB, 1s

      Scenario 5, external site, cached
      connect to site: 125ms
      download 100KB of html, compressed to 50KB, 1s
      wait for disk to be available, access disk for 100KB of javascript, wait for disk to spin up, 15ms
      wait for virus scan, read cache meta data, determine that our cache file isn't already too old, 1s
      connect to second site: 125ms
      HEAD the web-site file, to compare meta data, check to see that our cache is good enough, 1s
      -- now we have side work, a second connection, traffic everywhere

      And all of this gets even worse when you realize that the connection to your primary site is keep-alived for your entire visit -- minutes at a time -- but to your secondary site, you're lucky to get a full second. Add all of the other hardware that you're using, in terms of disk, cpu, virus scanners. Now add the entire local permission system, cooling system, throttling systems, battery savers, and you're now conflicting with everything else running in the background.

  2. Opera is NOT sane. by snarfies · · Score: 5, Insightful

    >Opera was sane: it did not reload a tab unless you asked for it. It just reopened everything from cache

    No. That is NOT sane, normal, or desired.

    Webpages are live. If I want to look at a chached version, I'll save the webpage locally. If I'm pointing a browser at an address, I expect a current webpage. If it takes all of three seconds to give me that, I think that's okay.

  3. Browsers are NOT slow by Yvan256 · · Score: 5, Informative

    It's web pages that are filled with useless javascript libraries that people think they still need to use for cross-browser support even though Internet Explorer is long dead.

    It's web pages that are filled with useless ads that run their own scripts, sometimes with their own libraries too, fetched from multiple servers.

    It's web pages that are filled with useless tracking scripts, sometimes with their own libraries too, fetched from multiple servers.

    It's web pages that are filled with huge animated GIFs that should be in video form instead.

    It's web pages that are filled with auto-loading, auto-playing videos, jamming our connection to download something we don't even want to see instead of downloading the web page we're trying to read.

    Disable plug-ins. Disable javascript. You'll see how fast browsers really are.

    1. Re:Browsers are NOT slow by Calydor · · Score: 5, Insightful

      I am trying to figure out what part of what you wrote (which is all true, mind you) explains why opening a new tab in Chrome or Firefox has to take as long as it does.

      --
      -=This sig has nothing to do with my comment. Move along now=-
  4. They're not by kwerle · · Score: 5, Insightful

    Possibilities:
    * You have too many slow addons enabled
    * You are out of RAM
    * The page is slow (big/complex)
    * Your network connection is slow/saturated
    * Their network connection is slow/saturated
    * You are out of CPU (unlikely)

  5. Browsers are fine by sjbe · · Score: 5, Interesting

    Do you agree with Birman? If yes, why do you think browsers are generally slow today?

    Not really, no. Tabs open up basically instantly on the computer I'm typing this with. Doesn't matter much which browser I'm using either. I'm almost always limited either by the bandwidth of my internet connection or the slowness of the database on the other end of the line. I hear people bitching about this browser or that one being "slow" and I frankly have no idea what they are talking about. If you have an even vaguely recently built computer with reasonable hardware then it is a non problem. I also see comparisons between the browsers which claim this one or that one is faster and I simply don't see any meaningful difference. The only difference between them to me is the user interface and what bugs I run into. If there are speed differences they are simply too small for me to care.

    Now he did say "hundreds of tabs" which is probably the root of the problem. My guess is that he's overtaxing his computer and running out of RAM. If you have hundreds of tabs open then you are Doing It Wrong.

    I have a 2012 vintage Mac Mini and it runs just fine. Safari, Firefox, Chrome, doesn't matter. I'm typing this on a PC with a Intel i5 chip and an adequate amount of RAM and it's fine no matter what browser I use. I mostly use Firefox but I'm pretty agnostic about which browser to use as long as it works and I can block ads and trackers adequately. So no I don't think there is a problem with browser speed as a general proposition. I do think people can do stupid things that slow down browsers significantly.

  6. Re:Because Use Cases by Dixie_Flatline · · Score: 5, Insightful

    Uh, I have 23 tabs open in one window and 39 in another (Vivaldi). I have a dozen open in MS Edge. Lots of them are work related or reference tabs. My Vivaldi tabs are things that I'm reading or things that I always keep open.

    I'm not unusual. When I walk past other people's machines, everyone has dozens upon dozens of tabs open.

    I get that I'm a huge nerd and that my use case is often niche, but browsers are just as much work tools as entertainment tools these days. It IS a useful test case. Hundreds of tabs is maybe pushing it, but it's definitely conceivable.

    Most of the webpages that I have open ARE static content--they're a news story or a review or something that doesn't immediately need updating. It makes it much faster to load. Only a few things like Reddit or Facebook need a lot of refreshing.

  7. Deep stacks by Bryan+Ischo · · Score: 5, Insightful

    I don't know the specific code in question, but I have seen enough code to have a theory.

    Long-lived software projects that implement programs with complex features (and web browsers have an astounding array of features), especially those that interact directly with users, who put programs into a position of continually having to respond to extremely complex sets of inputs (just think of how many valid inputs there are to a web browser at any one moment), tend towards a style of implementation that can best be described as "layers upon layers upon layers of framework".

    One aspect of programming that many engineers are, in my experience, not very good at, is deciding when to simplify frameworks versus making them more complex. I think it comes from a fear that many people have of painting themselves into a corner -- we've all seen code so inflexible that it makes extending it at a later time difficult, and I think that many people respond by going too far in the opposite direction - to avoid painting themselves into a corner, they put 100 doors in every room so that there is always a way out.

    The end result is that every aspect of the complex program is designed to be extensible well beyond anything that will ever likely occur in practice. And the interactions between these complex layers of framework become so complex themselves that new layers have to be invented just to try to simplify things and allow any hope of rationally moving forward.

    So what you end up with is incredibly deep stacks of function calls for almost any action, as various extensibility layers are passed through, along with the layers that consolidate previously implemented extensibility layers into simplified layers that more directly match the actual requirements of the program.

    I have occasionally seen stack traces from programs like Firefox, and I expect Chrome is no different, and the depth of the stack at the point of a crash is always somewhat breathtaking. You may end up going 30 - 40 layers deep before you actually get to a piece of code that has a tangible effect on the state of the program.

    Now imagine that a particular user input requires running through a function that has to call out to several parts of another framework layer, and you're going to be paying the deep stack penalty multiple times.

    What you end up with is a large code base that does everything necessary, but in a way that is embellished to a nearly pathological degree, where every action takes 10 - 20 times longer than it would had that action been encoded much more directly and with far fewer framework layers.

    The advantage of such a large code base is that it has enough flexibility to rarely, if ever, require a complete redesign as new feature requirements come up.

    The disadvantage is that it will never operate as efficiently as a more directly coded program, and you get user interfaces that require executing literally billions of machine instructions just to effect fairly simple changes to its internal state machine.

    That's your web browser.

  8. Re:Because Use Cases by johannesg · · Score: 5, Insightful

    I don't think that's the standard use case for testing, nor should it be. What the hell are you doing with that many tabs open.

    Speak for yourself. I normally open a bunch of websites I read, and then just middle-click to open the articles I find interesting in separate tabs. You can quite easily end up with dozens of articles. I wouldn't consider that to be unusual at all.

  9. Re:This totally breaks the rendering speed. by ckatko · · Score: 5, Interesting

    The UI is not slow.

    What's slow is the fact you're loading MEGABYTE APPLICATIONS full of commands through the web that have to be processed before display.

    Go to a 90's era website with HTML3.2. Watch how magically fast everything is displayed.

    Check out the old website, "Internet Explorer is Evil":

    http://toastytech.com/evil/

    Watch how magically fast the animated GIF backgrounds display. How magically instantaneous the text renders. Why? NO CSS. NO JAVASCRIPT. No 5 MB app being downloaded.

    And even then CSS and JS don't have to be slow. But people designing these websites simply don't give a shit about speed. Have you ever tried to load a Google Document on a Netbook with an Atom processor? Apparently a dual-core CPU with 2 GB of RAM isn't enough TO DISPLAY TEXT and if you try and multi-task it'll bring your computer to a complete halt. I've literally had to panic close tabs in Linux with my netbook with Google Docs open with other tabs, because if it starts getting laggy, it'll quickly get to the point it freezes the whole computer (>15 seconds between mouse moving) and it's actually faster to reboot the entire thing. (SSD ftw.)