Closed Bug 1774258 Opened 3 years ago Closed 3 years ago

Firefox uses 99-100% cpu when restoring pinned tabs at launch

Categories

(Core :: Performance: General, defect)

Firefox 101
x86_64
Linux
defect

Tracking

()

RESOLVED INVALID
Performance Impact none

People

(Reporter: zodigram, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0

Steps to reproduce:

  1. Launch Firefox
  2. Open several tabs (things like Youtube, Reddit, Discord, Facebook Messenger)
  3. Pin the tabs
  4. Set Firefox to restore previous session on startup
  5. Close and reopen

This problem appears any time I open Firefox on either my main profile or a new profile, and is present in the latest nightly (Build ID: 20220614082301) and in the default release. I use Arch Linux on a 2017 Macbook Air.

Actual results:

CPU usage instantly climbs to 99-100% until all pinned tabs are loaded

Here are my profiler recordings on Nightly:
Using my everyday profile: https://share.firefox.dev/3HkldPz
Using my everyday profile when the tabs aren't pinned: https://share.firefox.dev/3HowrCL
Using a new profile with Youtube, Reddit, Discord, and Messenger pinned: https://share.firefox.dev/3O85VQF

When the tabs aren't pinned, Firefox still launches to around 100% cpu, but for a shorter period of time. The tabs only ever seem to be loaded in the background when pinned

Expected results:

Firefox should not be using that much cpu to restore my pinned tabs

Performance Impact: --- → ?
Component: Untriaged → Performance
OS: Unspecified → Linux
Product: Firefox → Core
Hardware: Unspecified → x86_64
Component: Performance → Session Restore
Product: Core → Firefox
Component: Session Restore → Performance
Product: Firefox → Core

(In reply to zodigram from comment #0)

When the tabs aren't pinned, Firefox still launches to around 100% cpu, but for a shorter period of time. The tabs only ever seem to be loaded in the background when pinned

I think this by design - we want to treat pinned tabs differently from normal tabs during session restore, so that you don't need to switch to the pinned tab in order to load it.

Looking through about:config, I found browser.sessionstore.restore_pinned_tabs_on_demand - that might be the pref you're looking for!

Moreover, we want to load the tabs as fast as possible without making the browser unresponsive, so 100% CPU usage is expected. Less than 100% CPU usage would mean that we're wasting some loading time by letting the CPU sleep.

Furthermore, if you've been using startup profiling, you were seeing some extra CPU usage from the initialization of the profiler.

I think there's one change we could make that might improve the situation a little bit: We could try to avoid thread starvation by only restoring a few pinned tabs at the same time, depending on the number of cores in the CPU. For example, in your profile, I can see that you were recording this profile on a 2 physical / 4 logical core machine, and the content processes don't run at full 100% because they're starving each other a bit.

I guess I can try modifying that flag, but a lot of my pins tend to be messaging sites (Whatsapp web, Google messages for web, Facebook Messenger, Discord), that I'd ideally still want to load on their own and passively notify me of new messages. Is there a way I can somehow assign these lesser priority, so there's no rush to load them immediately, just eventually?

My computer has issues with heat as it is, and I'd like to avoid anything too cpu-intensive for too long if I can, especially at startup

If this is too niche of a concern, I completely understand. At the very least it's helpful to know this is an intended feature and not a problem with my system

Ah, I see. I think "slowing things down to avoid overheating" falls into the responsibility of the operating system, not of Firefox.

I'm going to close this bug because I think things are mostly working as intended. Sorry that I can't help you with the problem.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Performance Impact: ? → -
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.