23 ms·
Improving Firefox Responsiveness on macOS
- jhatax 4y agoGreat to hear that Firefox on macOS might get snappier with these changes. The reliance on undocumented APIs is the only potential red flag. Out of curiosity, does Chromium use spinlocks on macOS? If they do in a scenario where characteristics need to be similar to the jemalloc use case, how are they accomplishing the outcome?
- l1n 4y agolooks like they just use system malloc: https://chromium.googlesource.com/chromium/src/base/+/master/allocator/README.md https://chromium.googlesource.com/chromium/src/base/+/master...
- garaetjjte 4y agoThis document is outdated, PartitionAlloc is used for all allocations now: https://chromium.googlesource.com/chromium/src/+/ec6b52f91a4cfa3fe28fd7cf2c3662efb1d55235 https://chromium.googlesource.com/chromium/src/+/ec6b52f91a4... It uses plain os_unfair_lock: https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/base/allocator/partition_allocator/spinning_mutex.h#51 https://chromium.googlesource.com/chromium/src.git/+/refs/he... EDIT: It also combines os_unfair_lock with manual PAUSE spinning.
- solarkraft 4y ago> If you’re running Firefox on macOS you might have noticed that its responsiveness has improved significantly in version 103, especially if you’ve got a lot of tabs, or when your machine is busy running other applications at the same time. Huh, now that you say it: I haven't been all that angry at Firefox lately.
- lapcat 4y agoNote that Firefox is distributed outside the Mac App Store, otherwise the use of private functions would be disallowed by Apple.
- MiddleEndian 4y agoIt's so clear how Mac OS and Windows both can function without app stores that it's obvious that app stores are a rent-seeking middle men. Terrible that they've been normalized for mobile devices.
- Melatonic 4y agoF-Droid though is awesome! I think the problem is locking us to one app store - because the app store does provide some added functionality (easy of use - one place to go for all apps - security vetting - automated update settings across apps)
- saagarjha 4y agoThe App Store on macOS is a convenient distribution channel. It’s helpful to have, especially because alternatives exist if it doesn’t have the right tradeoffs for you.
- stu2b50 4y agoI don't see any issue with the app store models for macOS (mostly) and windows (could be useful, but not in its current implementation). They act as more curated package managers with a GUI, and an added bonus of taking care of payments (a hard problem!). App stores allow users a centralized place to both acquire known and verified applications as well as get updates for them. They are a safe place to buy things - Apple is not going to steal your credit card. For developers, they are a convenient place to park your app, without having to manage your own distribution services. And payments is always pain - it's probably the single biggest value add that the app stores cover it for you. And you can always circumvent it on these platforms. It's just an addition. I'd prefer to get an app on the mac app store if it is there, if it is not then that is fine as well, but will require more digging to verify it's authenticity.
- ghostpepper 4y agoThis is good to hear, I'm looking forward to trying it out. Off topic, but has anyone noticed Firefox on iOS has gotten quite slow? It happens when I switch from another app to Firefox, and then tap the URL bar to highlight the text in preparation to type either a URL or a search query, the whole app will stop responding for anywhere from 1-5 seconds. This happens even on a fresh restart of the phone or after killing the app. I'm using an iPhone 12 Mini on the latest iOS but I've noticed it for a few months now. It might sound minor but when everything else on the phone (including Safari) is so snappy, it's very noticeable.
- deleted 4y ago[deleted]
- lucideer 4y agoYup - have noticed this. Just in the past week or maybe 2. Safari doesn't exhibit the issue so it seems to be with the wrapper - & definitely related to addressbar/URL typing/homepage functionality freezing the app. Quite a few crashes too which I've never seen before.
- pca006132 4y agoI thought firefox on iOS is just Safari with another skin.
- dochtman 4y agoIt is.
- jonas21 4y agoThe browser engine is the same, but all of the UI surrounding it is provided by the app, so they could have done something that caused a slowdown.
- _23sd 4y agoI'm fine with calling Blink based browsers "Chrome skins" and WebKit based browsers "Safari skins" but only if we all understand that "skin" isn't just a cosmetic thing. Firefox on iOS has its own features, settings, history, bookmarks, sync system, and other stuff that can create real, noticeable differences. Even if you assume "skin" means just the UI behavior, wouldn't it make sense that there could be a Firefox-specific bug with the URL bar? To answer the GP's question, this does sound like a known Awesomebar issue that might be improved with a future update to the Places database: https://github.com/mozilla-mobile/firefox-ios/issues/11775 https://github.com/mozilla-mobile/firefox-ios/issues/11775
- jeffbee 4y agoThis has the whiff of someone discovering the basics of high-performance locking. For e.g. other long-standing mutex implementations have spin/pause,sleep strategies. See Go's mutex, absl::Mutex, and others. One problem with the x86 pause instruction is the number of cycles spent paused has varied dramatically from one CPU to another. Some CPU models ignore it. On others it is very short, a few or ten cycles, and on some it is hundreds of cycles. So you need a startup calibration that measures it, otherwise it will have a random outcome.
- rockdoe 4y agoThe problem is that these are the locks in the memory allocator, so they cannot allocate any memory. Most high performance implementations don't need to operate under that limitation.
- jeffbee 4y agoThat doesn't strike me as much of a constraint. TCMalloc's transfer cache and global page heap are protected by Abseil locks and this doesn't seem to have caused a circular dependency crisis.
- BeeOnRope 4y agoMany high performance locks do not, fundamentally, need to allocate memory. If they do, it is often for: 1) optional features such as statistics tracking or diagnostics (e.g., the ability to traverse all held locks in the process) 2) A space optimization to keep the lock object very small if uncontended, only allocating ancillary data structures on the heap needed to block at the OS level when contention is detected. You can easily avoid this: don't support (1) in your specific malloc lock, and don't apply the optimization (2): just put those fields in the main structure. In any case, no fancy lock is needed either: really they just want a vanilla "userspace aquire + userspace limited spin + fallback to OS blocking primitive" which is pretty much strictly better than their "userspace aquire + forever spin" existing lock. I don't think this is hard to do at all unless the OS-level locking primitives are very strange on OSX.
- FartyMcFarter 4y ago
- Fidgeting0026 4y agoHas the battery life issue improved with Firefox at all in the last year or two? I had to choose between degoogled-chromium and Safari because videos drained my battery so fast on my Macbook.
- gizmo 4y agoOn m2 MBA firefox battery life is fantastic
- aliqot 4y agoIt's not m1 with safari fantastic. Safari's bland though, so compromises get made.
- smoldesu 4y agoIf only Apple hadn't pulled a Google on us and let people use uBlock Origin in Safari unimpeded...
- chaxor 4y agoMan, why is everyone so obsessed with uBO? It's fine, but not sufficient IMO - uMatrix is worlds better.
- TylerE 4y agoSome of us don’t like 80% of the web being broken by default.
- smoldesu 4y agoThey're both great, but it's kinda irrelevant if they're both broken.
- Fidgeting0026 4y agoWhat's better about uMatrix?
- zerop 4y agoI have been using FF on MacOS. Will checkout this. I moved from Chrome and finding this good so far. I face two issues though: 1. Switching on/off VPN would hamper the connectivity (sometimes only), not sure if this specific to my network 2. Responsiveness is an issue, key type response is slower. I will check if this new version helps. Thanks FF team for your efforts.
- hugocbp 4y ago1 happens to me as well. And I even use the Mozilla VPN. I noticed it also happens with Cloudfare's Warp. Turning it on/off or even closing the display while they are active sometimes result in complete loss of connectivity when trying to interact with a tab again. A lot of times, I have to close the current tab and open a new one to regain connectivity. It is my only issue with Firefox on mac, currently.
- platelminto 4y agoThought this was because of Mullvad! I also have this issue on FF with Linux Mint.
- zmk5 4y agoMozilla VPN is a skin of Mullvad VPN I believe
- clairity 4y agoas someone with many tabs across many windows across many desktops/spaces, one weird trick i found is that when firefox starts up (on an intel MBP, 2019), it will churn CPU at over 100% until you go and foreground each of the windows in each of the workspaces. then the CPU usage becomes normal. perhaps it has to do with extensions like noscript or ublock origin, or my propensity to start firefox without internet access, but i don't think that matters here. not sure why this happens, but it's been required across at least the last few firefox restarts for me.
- nrclark 4y agoI have the VPN problem too. For me, it's a proxy thing. My company puts an HTTP proxy in-place inside of their VPN, and Firefox picks up the settings from MacOS. When I disconnect from VPN, Firefox still has the VPN's proxy settings. I have to restart it to refresh Firefox's cached proxy settings. So that means I effectively have to restart Firefox any time I change between VPN and non-VPN. If that's your problem too, then I don't have a fix for it. I'd love to hear if anybody else does though.
- mcovalt 4y agoNote that the version of Firefox this article references was released on July 26, 2022.
- seba_dos1 4y agoI remember reading this article around that time too. Not sure why it shows as released today (or am I having a deja vu?). [edit] Could be this Twitter thread that I have in mind: https://twitter.com/gabrielesvelto/status/1558083461059153920 https://twitter.com/gabrielesvelto/status/155808346105915392...
- disadvantage 4y ago> its responsiveness has improved significantly in version 103, especially if you’ve got a lot of tabs Whilst many like to have a lot of tabs open, I rarely surf that way. If something's interesting, I don't hoard it away in a tab. I have a Pinboard.in bookmarklet I use and tuck it away in there for perusal at a later stage. If the page is no longer needed, I close the tab and continue working.
- _ph_ 4y agoI have been a very happy Firefox user for several years but recently (with 104) I noticed how it uses massive amounts of CPU when being idle. About 60-120% CPU are not uncommon. In the task manager there is no task with heavy CPU load. It seems to get somewhat better over time, but it is really significant, making my Macs quite loud with just an idle Firefox.
- magicalhippo 4y agoSimilar on Windows FWIW. It could be using a full core or more, but FF task manager shows barely any activity. Not always, but often.
- viraptor 4y agoHave you reported the bug? If not, please do. Things won't get fixed without people actually helping with the experience.
- _ph_ 4y agoNo, where would I do that? And of course I can offer litte more than the description I gave here.
- viraptor 4y agohttps://bugzilla.mozilla.org/ https://bugzilla.mozilla.org/ You can start with your description and end with "I'd like to help, but I don't have the knowledge how to debug this further. I'm happy to provide more information if you can guide me." The first thing you'll be pointed at is likely https://profiler.firefox.com/docs/#/./guide-getting-started https://profiler.firefox.com/docs/#/./guide-getting-started so it may be a good idea to start with capturing the "idle" profile for a while and submitting that with your initial report. Check the "Share a profile" section.
- _ph_ 4y agoI think I went there once and got lost :p I filed a bug report, lets see whether anything comes out of that.
- CrankyBear 4y ago
- chaxor 4y agoEw
- flutas 4y ago> Switch to Chrome. Support a less centralized internet. Switch to any browser that isn't chrome or chromium based.
- Melatonic 4y agoAlways cracked me up that the browser named "Chrome" had a logo that was literally a super colourful circle with nothing chrome about it
- nayeemcodes 4y agoManifest V3 is coming!
- meisel 4y agoHow does chrome deal with this in whatever allocator they use?
- jeffbee 4y agoIt's designed to avoid contention. The allocator mutex is tuned for fastest uncontended acquire and release.
- rockdoe 4y agoSeems like it actually works similarly to the "old compatible path" described in the article: https://news.ycombinator.com/item?id=33153080 https://news.ycombinator.com/item?id=33153080
- cbsmith 4y agoI think, without exception, thread safe allocators all try to avoid contention. Under the covers Chrome uses futex on Linux, SRWlock on Windows and os_unfair_lock (not _with_options) on MacOS.
- ccouzens 4y agoAnd how does Firefox deal with it on other platforms? (Windows, desktop Linux, Android Linux)
- cbsmith 4y agoYou can see the relevant code from the links. It's all in memory/build/Mutex.h. On windows it uses critical sections and on non-Darwin systems it uses pthread mutexes.
- shadowgovt 4y agoSee in the article where the author says > Memory allocators have to be thread safe and – in order to be performant – need to be able to serve a large number of concurrent requests from different threads. Another approach is to create a bunch of individual allocators that all hold onto a big chunk of memory that only a small set of threads (or even one thread) use. These allocators only contend for locks with each other when they need to fetch more memory from the OS. Otherwise, they just hold onto the big slab of memory they've allocated, give it out when needed, and when it's "deallocated" they keep holding onto it instead of handing it back to the OS, under the expectation that the thread (or small pool of threads) they're managing memory for will need more again soon. The only downside to this approach is that over time, the app ends up holding onto tons of memory it's not using right now, on the assumption it will be needed in the future. Ever notice how Chrome eats memory like it's a three-year-old at an ice cream buffet? That performance ain't free.
- dahfizz 4y ago> However, as I dug into Apple’s libraries and kernel, I noticed that some spin locks were indeed available, and they did the spinning in kernel-space where they could make a more informed choice with regards to load and scheduling. Those would have been an excellent choice for our use-case. > So how do you use them? Well, it turns out they’re not documented. They rely on a non-public function and flags which I had to duplicate in Firefox. Gotta love it. You need to reverse engineer the kernel to get good performance on MacOS.
- lilyball 4y agoThe code comment links to Apple Darwin GitHub repos. It sounds like “undocumented” means “not in the SDK”, rather than requiring reverse-engineering.
- shadowgovt 4y agoAt some level of performance demand, you need to reverse-engineer (or read the source code of, if available) the kernel to get good performance on any OS.
- fsflover 4y agoExcept, you know, on a FLOSS OS.
- shadowgovt 4y agoI slipped a note about the source code in... But on further reflection, I suspect for the best performance some reverse-engineering will still be needed even if all components are open (does the source code really tell you what assembly is generated? Does the assembly really tell you how the CPU will execute it?)
- smoldesu 4y agoWhen was the last time you needed to read assembly code to debug a kernel-level issue in FOSS software? There's a lot of software you can use to profile the entire kernel and userspace[0], or explore the stack trace[1] of your software. If you're not using those and instead debugging your software by counting SIMD calls in the Ghidra editor, you're wasting an unconscionable amount of time. People read through assembly to fix compiler issues, not to rationalize what the kernel is doing. You're right that this skill is still required for "perfect" optimization, but it's not really relevant when comparing kernels. [0] http://www.sysprof.com/ http://www.sysprof.com/ [1] https://github.com/brendangregg/FlameGraph https://github.com/brendangregg/FlameGraph
- gnicholas 4y agoAfter decades of using FF and its progenitors, I switched to Brave a couple years ago for performance reasons. As much as I like the experience (especially now that vertical tabs are rolling out), I'd rather support a non-Chromium browser like FF. (I've been playing with Orion for the same reason, and it also seems great.) Does any one have any suggestions for what addons to use with FF these days to make the web livable? It's been years since I was gone, and I want to do an apples-to-apples comparison to see how it fares.
- deleted 4y ago[deleted]
- nsgi 4y agoI don't know the answer to your question but I would agree with you. I used to be all for Chrome but with Manifest V3 it's clear Google has too much influence and we need to either switch to Firefox or create a fork of Chromium that is developed entirely separately
- gnicholas 4y agoBingo. I forgot to mention my company has two Chrome extensions, which we are now in the throes of updating. That definitely soured my mood, and increased my interest in getting off the Chromium train (even though I understand Brave plans to continue supporting V2 extensions indefinitely).
- jorvi 4y ago> I switched to Brave a couple years ago for performance reasons. Same. They also staunchly fight against introducing adblocking to the iOS version, with no justification given. Sadly, the fight over on which browser engine the web runs is a done deal. Even if Manifest V3 sucks, it won’t lead to a mass exodus to Gecko. People will just switch their upstream to a Manifest V2 fork. Blink has become the Linux kernel of the web.
- behnamoh 4y agoI use Brave on iOS too and it blocks YouTube ads :)
- bgro 4y agoThe trick to using Firefox on mac like 5 years ago was to use the developer edition. For some reason it was way faster than standard Firefox. I don't know if that's still the case, but I stick to it for good luck.
- callahad 4y agoFor a few years, DevEdition had multiple content processes enabled (codename "electrolysis", aka e10s), while it was still off in release builds. That made a huge, huge difference to responsiveness and resilience.
- notacoward 4y agoWhen I tried going back to Firefox (for about the tenth time) recently, I was able to determine that the main reason for the lack of responsiveness was their awful not-very-concurrent TLS library. Things would tend to stall in all tabs when one tab was setting up a connection to fetch some resource or other. If you think about how many resources are on a typical page nowadays, it's easy to see how this leads to near-constant stalls. IMO they could fix a lot of their responsiveness problems by transitioning to a better performing (and BTW more standard) TLS library.
- LtWorf 4y agoDid you investigate the code? This doesn't seem like it can be a real thing.
- notacoward 4y agoSome things are more visible via runtime observation than via code inspection, plus I have prior experience coding with NSS and trying to work around its performance shortcomings. I'll bet neither you nor any of the downvoters have checked the code either, or worked with NSS, or even remembered prior cases where NSS was responsible for major slowdowns. Some people just don't like to see criticism of their favorites, and lash out kind of mindlessly. I have no interest in trying to engage with people who bring nothing but denial to the table.
- LtWorf 4y agoOk so no. I have not checked the code. But I've worked with 3 ssl libraries and they all worked fine with non blocking file descriptors.
- notacoward 4y agoWas one of those NSS? "Worked fine" doesn't necessarily mean that it performs well, especially under contention. It's absolutely trivial to write code that will happily consume non-blocking descriptors, or nominally provide them, while still blocking all over the place behind the scenes. Most often this happens because all real work is shoved to separate worker threads, like Linux AIO did for a long time, but there are other ways it can happen too. When I was adding SSL/TLS support to Gluster, I also worked with three libraries. NSS was tied with OpenSSL for the worst API, and was definitely the worst for performance. Maybe it doesn't matter when you never stress it, but I was stressing it so I could tell. Because of that experience I knew exactly what to look for, and was very unsurprised when I saw the familiar old symptoms. I even considered spending some time to fix it, but dealing with those super-hairy interfaces and crazy build systems etc. seemed like a poor fit for my first post-retirement project. I'll probably do some work on sshfs first, since it currently lacks a maintainer and is a better fit for me, then maybe I'll look into getting elbow deep in Firefox's "unique" codebase.
- runlevel1 4y agoI tried Firefox again a few days ago, and it was indeed noticeably snappier. In fact, it felt snappier than Chrome on the handful of sites I tried. With all the things they've addressed in Firefox recently and with Chrome's manifest v3 nonsense, I'm running out of reasons not to switch.
- Forgeties79 4y agoI’ve been on brave for about 2 years now and all I see people talk about is Firefox. Should I swap? I thought people liked brave but I really don’t see it mentioned anymore.
- james_pm 4y agoSame situation. I switched to Brave a couple of years ago (from Firefox) and I occasionally check in on Firefox to see if I should switch back. I haven't seen a reason yet. Things like full screen support in YouTube sees a bit janky still. I like where Brave is going with getting rid of cookie consent and other annoyances without extensions.
- donatzsky 4y ago> I like where Brave is going with getting rid of cookie consent and other annoyances without extensions. Firefox is supposed to get that too. Believe it's in Nightly already.
- wryun 4y agoDepends what you care about. I think there are two main reasons to use Firefox over Chrome: - better privacy protections - not wanting to leave web standards entirely to Google/Apple (for-profit corps) Brave attempts to address the first, but does little about the second as it uses Blink (i.e. Chrome's engine). Personally, I care a lot more about the second.
- nicoburns 4y agoIMO Firefox with a few extensions is much better than brave for the first.
- magicalhippo 4y agoThe go-to synchronization primitive on Windows, critical sections[1], does a short spin in then waits. To me it has always seemed as a decent strategy, and when working on a cross-platform heavily multi-threaded code base which had a fairly contested hot-spot, Windows performed quite well using just plain critical sections. [1]: https://learn.microsoft.com/en-us/windows/win32/sync/critical-section-objects https://learn.microsoft.com/en-us/windows/win32/sync/critica...
- mnurzia 4y agoMusl libc also does this for threads, spinning 100 times by default before switching to a heavier system wait (see line 71): https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_mutex_timedlock.c#n71 https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_...
- Sirened 4y agoyou just know someone at apple is having a terrible day now that they realized they'll have to support their weird hack for hybrid spinlocks forever now that firefox adopted it
- TillE 4y agoThat's definitely not how Apple works. They'll just break it if they want to, though the change would probably show up in a beta OS first.
- saagarjha 4y agoApple would only break this if there was significant benefit to them for doing so.
- mattnewton 4y agoI'd actually bet nobody at apple cares if they break Firefox users, they don't have the backwards compatibility culture of some companies like microsoft, especially for undocumented apis.
- saagarjha 4y agoDon’t, you’ll lose your money. Firefox is popular enough to be on their list of apps they try not to break. And the culture you’re talking about does exist, they’re just less insane (and chatty) about it.
- cbsmith 4y agoYou might be confusing a feature for a bug. ;-)
- jeevestizzobs 4y ago
- AceJohnny2 4y agoIf you use an undocumented API and it breaks, Apple will point at you and laugh. Then they will use the example to tout the App Store. Especially if you're an org with the pedigree of Mozilla.
- steve_john 4y ago
- cnagesh 4y agoSorry to say this, it still sucks on mac. For ex: If I press `click to go back` it still shows the same page, if I click again it will directly jump to last but one page.
- alpaca128 4y agoI know that issue, it happens when I use a Google site like YouTube where they decided to break the browser UI's functionality and badly implement it themselves. So the back button sometimes doesn't work when the site's JS encounters a bug, you can't stop loading because YT does everything without reloading the page etc.
- ubercow13 4y agoOh! Safari does that for me too, since forever.
- strager 4y agoThis happens for me with YouTube in Safari occasionally. It might be a bug with the website, not Firefox or Safari.
- r00fus 4y agoI absolutely love FF but the cookie prevention is breaking some of my internal sites (not just for me but coworkers who I don't control which browser they use). Add to the fact that FF and TouchID don't work for our SSO provider for 2nd factor. Both of these are making it tough for me to continue using FF for my daily driver (though I'd still use FF+uBO for personal browsing)
- genrilz 4y agoAssuming you are talking about tracking protection, you can turn that off on a per site basis by clicking on the shield symbol on the url bar while you are on the website that is breaking, and clicking the slider next to the "enhanced tracking protection is on" text. Unfortunately I don't know anything about how TouchID interacts with Firefox.
- r00fus 4y agoThe issue for per-site disabling is that the default is "on" and many sites simply fail to work (silently) when they aren't allowed 3rd party cookies. Obviously this could be configured with a group policy but our IT group isn't going out of its way for a non-preferred browser. For the TouchID it's FIDO2 compliance - not sure if it's our SSO/MFA provider or FF but... it works fine with Chrome :/
- wryun 4y agoCan't you just turn off the cookie protection for all sites and keep using Firefox (well, not for TouchID...)? Security, custom, ...
- moralestapia 4y ago
- robert_foss 4y agoHave a look at 'about:performance' to diagnose your CPU usage issue.
- nine_k 4y agoFor me, FF has a killer feature: tree-style tabs (extension). Does Brave plan to add such a feature? (When FF suddenly decides to eat too much CPU, what helps us to open a tab with about:performance. Just the act of doing so seems to kick some misbehaving thread, and the CPU consumption goes down to normal amounts. I hope somebody at Mozilla is working on fixing that.)
- mgkimsal 4y ago> If you’re running Firefox on macOS you might have noticed that its responsiveness has improved significantly in version 103, especially if you’ve got a lot of tabs, or when your machine is busy running other applications at the same time. Nope. Sorry. It might actually be faster, but I haven't noticed anything over the last several months. I have FF/Mac/m1 open for hours per day, multiple tabs. Nothing jumped out from performance where it was noticeable.
- sniglom 4y agoSadly, I agree, don't think I noticed anything special when this happened. I'm on older hardware though; MBP 2014, i5 2.6GHz, 16GB DDR3. Still, I applaud the effort to make Firefox faster on MacOS. I'm happy for every performance gain I can get, even if I don't notice it straight away. A few more minutes of battery life or a bit less fan noise can make such a difference.
- wafriedemann 4y agoI have been using FIrefox as my main browser on Mac for a couple of months now (again) and it really does feel like they've done a lot of performance enhancing under the hood. It's really the only browser left that let's you do deep customization. With the right settings (not that many) you can basically strip it of all bloat. And of course it will be the last (big) browser with full Ubo support when Google introduces Manifest 3 (Ubo was also the reason I switched from Safari to Firefox).
- eshack94 4y agoHey, would you mind posting some tips (or an article/link) describing how you stripped the bloat from your Firefox config? I'm in the same situation as a lot of others here, where I'm thinking about permanently migrating back to Firefox after Chrome takes their Manifest v3 + WebRequest API changes live, and I'd love to know how I can improve the performance of Firefox & ensure my configuration is as good as it can be.
- cptskippy 4y agoNo the OP, but for me the only bloat is Pocket. I also disable DoH but that isn't really bloat.
- eshack94 4y agoThanks for the info!
- elnr 4y agoOut of curiosity, why are people so concerned about Pocket? I personally use it to quickly bookmark things in a cross-platform "i'll look at this later" box (although not a fan of how it tries to show me pages in-app). Recommendations for alternatives would be equally accepted.
- deleted 4y ago[deleted]
- lxe 4y agoI'm using Firefox on Windows 11 and it's noticeably clunkier than Chrome, especially when using heavy web apps like Jupyter Lab. Oftentimes the browser hangs completely, including all its windows, for 10-30 seconds at a time. This has been my experience over the years every time I've attempted to switch back from Chrome to Firefox.
- Vinnl 4y agoTo quote some relevant comments on other threads here: > If you could grab a profile of the problem with the Firefox profiler and file a bug it would be greatly appreciated. From the sounds of it it's probably an edge-case we're not aware of where Firefox performs very poorly. The problem with this kind of things in Mozilla is that we're often blind until someone brings up the issue and notifies us. https://news.ycombinator.com/item?id=33156379 https://news.ycombinator.com/item?id=33156379 > Here are instructions of using the profiler with just a few clicks: https://profiler.firefox.com/ https://profiler.firefox.com/ https://news.ycombinator.com/item?id=33156317 https://news.ycombinator.com/item?id=33156317
- lxe 4y agoI love the FF profiler. However I can't use it when the entire browser is hanging. I would need to run an external profiler on the browser itself. I will file a ticket as soon as I have any useful info... but when it's an intermittent 30-second freeze on all browser windows, it's tough to get any data on it.
- Vinnl 4y agoAh, that's a bummer indeed! Possibly devs can help you get more useful data if you report the bug first?
- gotenyama 4y agoThis is greatly related to the lack of per-tab sandboxing in Firefox (https://madaidans-insecurities.github.io/firefox-chromium.html https://madaidans-insecurities.github.io/firefox-chromium.ht...) it's not only a security issue but a performance issue as well.
- Jarred 4y agoHave you looked at `__ulock_wake` versus `os_unfair_lock_with_options`? __ulock_wake is another private darwin API for locking. From some Zig code: // Darwin XNU 7195.50.7.100.1 introduced __ulock_wait2 and migrated code paths (notably pthread_cond_t) towards it: // https://github.com/apple/darwin-xnu/commit/d4061fb0260b3ed486147341b72468f836ed6c8f#diff-08f993cc40af475663274687b7c326cc6c3031e0db3ac8de7b24624610616be6 // // This XNU version appears to correspond to 11.0.1: // https://kernelshaman.blogspot.com/2021/01/building-xnu-for-macos-big-sur-1101.html // // ulock_wait() uses 32-bit micro-second timeouts where 0 = INFINITE or no-timeout // ulock_wait2() uses 64-bit nano-second timeouts (with the same convention)
- gsvelto 4y agoPost author here, `__ulock_wait2` is used under the hood by `os_unfair_lock()`. I considered it but it would have required more scaffolding, especially to support all the versions of macOS we care about. We might use it in the future though.
- cbsmith 4y agoPer the documentation (https://github.com/apple/darwin-xnu/blob/main/bsd/kern/sys_ulock.c#L84 https://github.com/apple/darwin-xnu/blob/main/bsd/kern/sys_u...), it looks like ulock_wait might be one of the XNU primitives that supports os_unfair_lock.
- kishansh 4y agoWhen will firefox backend become a complete rust codebase ?
- whoisthemachine 4y agoJust curious, when developing a cross-platform application such as FF, would it make sense to implement an efficient lock within the FF codebase rather than relying on undocumented OS functions?
- joeldo 4y agoMy understanding is that an efficient lock would require hardware support, which is surfaced by the OS.
- gsvelto 4y agoNo specific hardware support is needed to implement a lock. The atomic operations are all accessible from user-space - they are platform dependent though. The problem with locks is that they interact with scheduling and that's where the kernel comes in, that's why you need an OS-specific component too.
- joeldo 4y agoThat makes sense, thanks.
- gsvelto 4y agoIn a word: no. Efficient locks can only be implemented with significant involvement from the kernel. The best locks that can be implemented entirely in user-space will still suffer from the problems described in the article. Locks have complex interactions with scheduling and the only place where informed decisions can be made about them is within the kernel. That doesn't mean that good locks don't need a good user-space component - they do - but it's only one side of the coin.
- whoisthemachine 4y agoThanks, that completely makes sense, I hadn't thought of the scheduler's involvement.
- theodric 4y agoGuys, please, please make copy-paste in Firefox reliable on macOS. That's worth much more to me than more performance, because I find the performance quite good already! It's so frustrating to CUT (or copy) something in Firefox and then paste only to find the previous data still on the clipboard. It's been like this for ten years now, and it's still broken a good 20% of the time. It's only Firefox that I have this problem in, and it happens irrespective of profile or machine (I have many).
- pagade 4y agoFor a while now, performance has not been an issue for me to not use Firefox. It's the no support for the multiline tabs and/or tab groups. Both features which were previously possible in Firefox. This is pretty much a blocker for me and they don't seem to have any plan to fix this.
- viraptor 4y agoTree style tabs (https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/ https://addons.mozilla.org/en-US/firefox/addon/tree-style-ta...) work just fine. You get the grouping there.
- pagade 4y agoI have pretty much used all possible Firefox addons for this. No it is not fine. Using vertical tab navigation was painful and slowed me down.
- gjm11 4y agoWhat browser do you use instead that does support those?
- pagade 4y agoUsed following work around for few years: https://wrw.is/multiple-tab-rows-in-firefox/ https://wrw.is/multiple-tab-rows-in-firefox/ Then finally gave up Firefox (after using for 15+ years) when Chrome released tab groups. Use above workaround to believe me that I tried before giving up.
- andrewia 4y agoAre there reasons that the "Simple Tab Groups" extension isn't suitable for you? It seems to be well-maintained, cleverly uses Firefox's "hide tabs" API to keep a single window behind-the-scenes, and has integration with lots of other features like Firefox's containers. I think it's an indirect descendent of the old Tab Groups extension when it was spun out of Firefox. https://github.com/drive4ik/simple-tab-groups https://github.com/drive4ik/simple-tab-groups
- jupp0r 4y agoWhy does jemalloc need to lock in userspace in order to allocate memory? Isn't this an implementation detail of how the kernel allocates memory? I'm assuming jemalloc is maintaining some sort of cross thread allocation pool?
- saagarjha 4y agoKernels allocate memory and hand pages back. Allocators in userspace have the job of carving these up for application use, and must do so across multiple threads, necessitating locking or similar primitives.
- jupp0r 4y agoMy understanding was that allocators nowadays have cache pools per cpu or thread and only rarely need to lock on global state (when imbalances between pool sizes necessitate shifting resources around).
- saagarjha 4y agoYou are correct, but there are still places where synchronization is necessary.
- gsvelto 4y agoThey do and so does jemalloc in Firefox, however that lowers contention, it doesn't let you do away with synchronization. Consider this simple scenario: a thread allocates a chunk of memory from its per-thread pool, but the object is later released by another thread. You can't do that w/o synchronization around the pool. Per-CPU pools are even trickier because a thread might be moved around between different CPUs by the scheduler while it's allocating memory. So you need special facilities to implement those in user-space like restartable sequences: https://lwn.net/Articles/650333/ https://lwn.net/Articles/650333/
- saagarjha 4y agoAmusingly macOS also has this as SPI, it's used for the Objective-C runtime.
- dan-robertson 4y agoI’m curious how it was determined that the locking was causing problems? Was it just some intuition from cases with poor performance and staring at code, or some perf-like tool (I don’t really know about the landscape of performance monitoring tools for MacOS) highlighting that a lot of time was spent in locks, or some known MacOS vs others difference? I think I also don’t understand the discussion about spinning in kernel space. Doesn’t that require context switches which the article points out have issues? I would have guessed the answer would be to spin a bit in userspace with architecture-specific instructions like pause and then syscall if the lock couldn’t be acquired. Maybe I just don’t really know how syscalls work on a Mac. I’m also weakly curious why jemalloc needs so much locking anyway? I haven’t thought about this at all so I’m surely missing something but my guess would be allocation from per-thread pools with occasional synchronisation, and that this synchronisation would be too infrequent to have these issues.
- saagarjha 4y agoFrom the blog post it seems like the team was using OSSpinLock, which was deprecated (for good reason) and then when trying to use the replacement (os_unfair_lock) degraded performance on some tests. I don’t have details on how they determined what the issues were but considering if the results were across a single change and one had access to the source it doesn’t seem all that difficult to see why there are performance differences. The various profiling tools on macOS (Instruments, mostly) would help confirm this. Spinning in kernel space does require a transition into the kernel. But, critically, it does not require rescheduling another thread and waiting around, which is even more expensive. The kernel has the context to know what is running and what isn’t, as well as some information on who owns the lock, so it can do a pretty good job here. Spinning in userspace is bad because the thread holding the lock may be parked by the kernel, which means that you’re just spinning for no reason. If you don’t include any special instructions you burn power, and even if you do you don’t benefit from the knowledge the kernel has of whether you should just be scheduled off while waiting anyways.
- enragedcacti 4y ago> I’m also weakly curious why jemalloc needs so much locking anyway? I'd love to hear from someone with more firsthand knowledge, but from a quick read of the implementation details for jemalloc, it seems there is a balance that has to be struck between lock contention and memory fragmentation. Too few arenas and lock contention slows you down, too many arenas (or enabling thread-specific caches) and the cache misses from fragmentation will slow you down. the blog post also mentioned that Firefox's jemalloc is highly customized, maybe firefox's specific profile gets value out of a more lock-heavy strategy. https://jemalloc.net/jemalloc.3.html https://jemalloc.net/jemalloc.3.html (see "Implementation Notes")
- saagarjha 4y agoThis blog post has some good discussion about what makes a good locking primitive. On macOS, os_unfair_lock is generally a good choice for many applications. That said, > At this point, you might wonder if os_unfair_lock – possibly coupled with the undocumented flags – would be a good fit for your codebase. My answer is likely yes but you’ll have to be careful when using it. I would hesitate to give this advice. The overwhelming majority of applications on macOS do not have performance profiles like Firefox does. The system allocator (rather than jemalloc) is the right choice for all but very few use cases. There are a vanishingly small number of usecases where using the undocumented flags is appropriate. The rules are different when you’re a popular browser with an existing relationship with Apple and dozens of smart engineers who can (at least in theory) understand the consequences of using this API, and leverage an existing relationship with Apple to ensure that it doesn’t become a liability in the future as the platform evolves. For pretty much everyone else, this should be nothing more than a “wow, neat” blog post.
- lapcat 4y ago> leverage an existing relationship with Apple to ensure that it doesn’t become a liability in the future as the platform evolves I sincerely doubt that Firefox can leverage anything with Apple, or that Firefox engineers have much of a relationship at all with Apple. Who does, really. I'm not sure it matters though. Many smaller Mac developers have a long history of using private API, and it's largely fine. There's no truly "safe path" with Apple, because Apple does whatever it wants whenever it wants, and I've seen them break "supported" API plenty of times, and leave it in a broken state. But the risks of any given brokenness are small, and you can't predict what will break from year to year, so what can you do except go with what works, and hope for the best. It's certainly fair to say that the majority of applications on macOS do not have the performance profiles of Firefox, but it's also the case that the majority of applications weren't even using lower level primitives like OSSpinLock in the first place, so replacing it was not a concern.
- saagarjha 4y agoWith all due respect, you’re a small indie developer, and the situation is different when you make a browser used by millions of people. Apple does do whatever it wants, but sometimes it (wisely) realizes that what it wants is people to not be upset that people’s favorite app is broken in the next release of macOS, so occasionally steps are taken to ensure that doesn’t happen. This ranges from committing to SPI for longer than it is necessary for Apple’s own use, to putting in bundle ID or linked-on-or-after checks, or in rare cases reaching out to developers directly. The target for this comment is developers like you, but those who are less familiar with the platform than you are but of similar import. Those are the ones who will read this and say “wow Firefox says this is how to make my app fast so I should do it!!1!” and what is going to happen is either they’re going to use it wrong, because they aren’t really experts on how locking works, or they’ll copy the code of of Firefox and their app will break in a future OS release while Mozilla will update their code in July.
- AceJohnny2 4y agoTL;DR: Firefox switched to an undocumented kernel lock function and flags. Which is, of course, a pretty bad thing, and an especially stupid thing to recommend, even with caveats! I expected a whole bunch of warning signs and even a "haha only kidding", but no, the author seems pretty gung-ho about this approach. Apple is very happy to change and deprecate such things with no announcement. I don't know that anybody who'd follow such advice would also be careful enough to implement regression testing, and how reliable such testing can be! Perhaps they can help pressure Apple to make such a useful lock function official.
- thecosmicfrog 4y agoI've noticed pretty obvious performance improvements in Google Maps recently on macOS (with original M1 chip). Zooming and panning is much more responsive, akin to using Maps on Google Chrome. I wonder if this could have contributed?
- dividedbyzero 4y agoLooks like this might finally make Firefox not use at least 30% of CPU at all times, which meant that with Firefox running my 2020 Intel 13" had really terrible battery life and was always just a little bit of extra load away from annoying fan noise. Chrome/Brave never had any such issue even with hundreds of tabs so I don't think it's my particular choice of websites or the like. Will try the new version once I find time, I really hope it'll do the trick.
- olliej 4y agoFirefox could of course just do what webkit does, and implement the spin lock themselves: https://github.com/WebKit/WebKit/blob/ae32cf14a9c1570e6ea8d27c1462a4da16d1602b/Source/WTF/wtf/Lock.h https://github.com/WebKit/WebKit/blob/ae32cf14a9c1570e6ea8d2...
- soheil 4y agoIt's very concerning that Firefox, a major browser used by millions, relies on undocumented Apple APIs. While it's brilliant to discover this gem in kernel space to use it "in production" is a whole different story. I wonder if there are unknown system-wide negative consequences by using this new lock method.
- soheil 4y agoInteresting that Apple doesn't recommend using the technique the author describes but instead offers a worse option than the deprecated choice.
- soheil 4y agoI really hope it reverts back to the old documented approach if the new API breaks things, because I can the see the day that Apple pushes an update to remove this API without any prior notice.
- gotenyama 4y agoLack of the ability to create app specific window or menu-less tab is a huge negative for me right now.
- s_ting765 4y agoI want to like Firefox and ditch Chromium just because of this whole MV3 kerfuffle but it's not like Firefox is any better. Besides, Firefox has unilaterally killed off useful features like PWAs in the recent past. It's too flawed a product to be hyped up like this.
- bumblebritches5 4y ago
- carbonatedmilk 4y agoI've recently switched from Firefox to Orion. Ideologically, I'm Firefox all the way - But even in beta, Orion is such a better browser. * Vertical tabs * Support for most of the extensions I need * Much better battery life (at least 1hr+ extra on my 14" M1 Pro MBP) * Better RAM usage I get the occasional tab freeze / crash, and it has some glitches with Google Docs / Sheets, but it just feels so much faster and uses much less RAM too
- girvo 4y agoInteresting. It seems like WebKit + Firefox/Chrome WebExtension support? So, Safari but with way better extensions?
- azinman2 4y agoI’d love for it to be seamless to switch between browsers. For that, I’d want a common history, bookmarks, cookie store, open windows/tabs, and most importantly, use of the system keychain (on macOS). I’ve never seen anyone talk about trying to effectively sync with a preferred/primary browser. Why isn’t this the goal? Especially for Firefox who’s trying to get people to switch; make it easy! Import isn’t enough, and it still doesn’t use the system keychain.
- williamscales 4y agoI thought browsers on Mac were just skins over Safari? Does this mean I can run real Firefox on my iPad at last?
- nick_ 4y agoUntil they match Safari's scrolling responsiveness, it's second-rate. No browser I know of achieves the same incredible responsiveness of Safari.
- benibela 4y agoI wish they would make it more responsive for X11 forwarding It used to work fine, but then it became completely unresponsive. There are some options to restore the old behaviour ((gfx.webrender.force-disabled, gfx.webrender.force-legacy-layers, gfx.webrender.software or something), but it is still less responsive than it used to be
- justanorherhack 4y agoWould really love to switch. But Firefoxs extension management is unusable in my opinion. Can't quickly turn on/off extensions.