Announcement

Collapse
No announcement yet.

Fedora Looks To Build Firefox With Clang For Better Performance & Compilation Speed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #11
    Originally posted by tichun
    Is the performance argument true? gcc vs clang benchmarks on phoronix tend to show gcc as leading in most aspects iirc.
    Solus developer noticed minor improvements after switching to clang https://dev.getsol.us/T4966#128937
    They are building Firefox with clang since 62 version.

    Comment


    • #12
      how much of the code base of firefox is still C/C++ and how much is already written in rust? Of course this ratio would be more interesting for the performance/security critical stuff.

      If in the (far far) future more code will be ported to/replaced by rust, does this change then really matter? Then the rust compiler should be the critical part or?

      In the posted wayland bug report, I have seen that the linux binary provided by mozilla is build with –enable-rust-simd which is not used by my ubuntu 18.04 supplied version.

      Simd should be really helpful for video acceleration, since we wont get handware acceleration anytime soon, so this sounds very helpful since video playback in browsers is still hugging bad for battery. Does someone maybe have more information which and where simd intrinsics are used in firefox?

      I definitely will try some video playback with the ubuntu and mozila build version to see what causes more battery train.

      Comment


      • #13
        Originally posted by zaphod_ View Post
        how much of the code base of firefox is still C/C++ and how much is already written in rust? Of course this ratio would be more interesting for the performance/security critical stuff.
        This wiki page gives an overview, but you'd have to get statistics by running e.g. tokei on a checkout of the source repository, though that may be somewhat inaccurate since WebRender recently moved in-tree and isn't used on release yet.

        Originally posted by zaphod_ View Post
        If in the (far far) future more code will be ported to/replaced by rust, does this change then really matter? Then the rust compiler should be the critical part or?
        This is expected to matter in the future when e.g. cross-language ThinLTO becomes a thing. It doesn't make sense to base today's decision on which compiler to use on some hypothetical future though.

        Originally posted by zaphod_ View Post
        Does someone maybe have more information which and where simd intrinsics are used in firefox?
        I don't know about the C/C++ parts, but regarding Rust code AFAIK the encoding_rs and regex crates currently use SIMD. dav1d will bring SIMD accelerated AV1 decoding.

        Last edited by johnp117; 11 December 2018, 07:33 PM.

        Comment


        • #14
          Originally posted by zaphod_ View Post
          how much of the code base of firefox is still C/C++ and how much is already written in rust?
          That's probably the main reason -- you need LLVM for rust anyway, so why not build the C++ stuff with it as well?

          Comment


          • #15
            Originally posted by tichun
            Is the performance argument true? gcc vs clang benchmarks on phoronix tend to show gcc as leading in most aspects iirc.
            When Mozilla did the benchmarking, they compared the VERY old version of GCC 6 against the latest Clang+LLVM version 7, and no surprise, Clang+LLVM won. They had no real interest in comparing against GCC 8 since they had already decided to switch to supporting Clang+LLVM only for Firefox. GCC has all the optimizations Clang+LLVM has, including PGO and LTO.

            That said, it's nothing wrong with Mozilla wanting to only support one toolchain in order to lessen their maintenance burden, but it says nothing about the current relative performance of GCC and Clang+LLVM.

            Comment


            • #16
              Thanks johnp117 for the interesting links. I also found this summary https://4e6.github.io/firefox-lang-stats/ from https://www.reddit.com/r/rust/commen...st_in_firefox/ . According to this rust already has 6.7% vs 14.3% C and 28.4% C++.

              The argument from mlau that llvm is also needed for rust is striking since this allows lto/inlining between rust and C/C++. So this switch very reasonable!

              I did some quick benchmarks for testing the differences between the firefox linux binary provide by ubuntu (build with gcc 7.3) and mozilla (still build with gcc 6.4...):

              ubuntu vs mozilla build (still firefox 63.0.3 64bit with the same profile/addons):
              speedometer 60.0 vs. 66.3
              jetstream 150.75 vs. 156.92
              (I just used https://browserbench.org/JetStream/ and https://browserbench.org/Speedometer/)

              so the mozilla binary build with the older gcc is nevertheless faster.
              about:buildconfig shows the following noticeably differences: mozilla uses O3 instead of O2 and also defines MOZ_PGO=1 (profile guided optimization) and –enable-rust-simd

              so maybe distros should also look more closely at the compile options.
              Does someone know if the simd code paths can be selected at runtime or is this chosen at compile time?

              Comment


              • #17
                They are probably doing this so they can simplify their life and only really target one or two compilers in their build system.
                Unfortunately this is also how compiler specific quirks get in a codebase. It would be more responsible to at least test compiling with a number of different vendor compilers because they pick up different potential issues.

                Comment


                • #18
                  Why is it that the minute LLVM/CLang is mentioned in any post a bunch of nervous nellies have to chime in all concerned about why GCC was left out? In this case it is likely more about Rust, debugging support and other factors beyond performance that makes the changes reasonable to the Firefox team. Even then the delta between the two compiler chains is minor when running C++ code, with GCC's biggest wins being for features Firefox doesn't even use.

                  Comment


                  • #19
                    Originally posted by jpg44 View Post

                    Phoronix has shown virtually no performance benefit from Wayland. You can run X applications on Wayland, of course.
                    It'd probably be nice not to pull in 100MB of X and dependencies every time you start a browser, though.

                    Fedora already compiles Firefox for Wayland, though, so I'm not sure it's that big of a deal that upstream hasn't enabled it yet.

                    Comment


                    • #20
                      Originally posted by wizard69 View Post
                      Why is it that the minute LLVM/CLang is mentioned in any post a bunch of nervous nellies have to chime in all concerned about why GCC was left out? In this case it is likely more about Rust, debugging support and other factors beyond performance that makes the changes reasonable to the Firefox team. Even then the delta between the two compiler chains is minor when running C++ code, with GCC's biggest wins being for features Firefox doesn't even use.
                      For the same reason they go on about why Qt was left out whenever someone mentions GTK, why flatpak was left out if someone mentions snap, etc.

                      Having said that, one of the reasons in this case is allegedly performance and since tests suggest that gcc seems to outperform clang in a majority of cases, it's undoubtedly a valid question. Other than that I agree with you; since they already use rust it only makes sense to move to clang.

                      Comment

                      Working...
                      X