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?

10 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 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.

    2. 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

    3. 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.

  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. 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)

  4. 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.

  5. 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.

  6. 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=-
  7. 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.