brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.74k stars 2.31k forks source link

Brave thrashes HDD after launch long after it's loaded, and even long after it's closed #9961

Open dark-penguin opened 4 years ago

dark-penguin commented 4 years ago

Description

After launching Brave, even with no tabs open, I can hear my hard drive thrashing really hard long after Brave is fully loaded (can open pages). If I close Brave immediately, this continues long after it is closed.

Maybe it's trying to load all the cache, which can be pretty sizeable, since removing the cache directory seems to alleviate the problem to a certain degree.

Additionally, trying to open Brave again while it's still thrashing sometimes causes a "Brave did not shut down properly" or "Something's wrong with your profile" errors.

Steps to Reproduce

Launch Brave Browser.

For the best results, use a slow and loud hard drive. For consequent launches, drop the page cache first:

$ sync
$ echo 1 | sudo tee /proc/sys/vm/drop_caches
$ brave-browser

Actual result:

Brave thrashes the HDD for a long time after Brave is fully opened, even long after I close Brave.

Expected result:

Opening Brave with no tabs does not need to read that much data, whatever it is it's doing. And it does not need to load all the cache into memory after it's launched, if that's what it's doing. Closing Brave should immediately kill the process and all subprocesses. Brave does not need to read that much data after it is closed. It especially does not need to load the cache after it is closed.

Reproduces how often:

Easily reproduced; it happens every time it's launched, provided you don't have whatever it needs in the page cache.

Brave version (brave://version info)

Brave   1.7.98 Chromium: 81.0.4044.113 (Official Build) (64-bit)
Revision    e3225dafb0475864a1812a374d73a92e391635ac-refs/branch-heads/4044@{#936}
OS  Linux
JavaScript  V8 8.1.307.28
Flash   (Disabled)
User Agent  Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36
Command Line    /opt/brave.com/brave/brave --password-store=basic --enable-dom-distiller --disable-domain-reliability --no-pings --extension-content-verification=enforce_strict --extensions-install-verification=enforce --sync-url=https://no-thanks.invalid --enable-features=PasswordImport,WebUIDarkMode,AutoupgradeMixedContent,PassiveMixedContentWarning,SimplifyHttpsIndicator,MixedContentSiteSetting,DnsOverHttps --disable-features=TextFragmentAnchor,AllowPopupsDuringPageUnload,AutofillServerCommunication,LookalikeUrlNavigationSuggestionsUI,SmsReceiver,AudioServiceOutOfProcess,NotificationTriggers,VideoPlaybackQuality --flag-switches-begin --flag-switches-end --disable-webrtc-apm-in-audio-service --disable-sync
Executable Path /opt/brave.com/brave/brave

Version/Channel Information:

I did not try anything other than the "normal" version.

Other Additional Information:

Miscellaneous Information:

I have Brave installed on an SSD, so the thrashing definitely comes from my home directory, which is on a HDD.

MinisterFister commented 4 years ago

Do you have Brave Rewards enabled? If so it might be related to this https://github.com/brave/brave-browser/issues/9908

dark-penguin commented 4 years ago

I think I did enable Rewards before, but now clicking the Rewards icon says "Wallet creation failed"... And anyway, does it really have to redownload the entire database every time it's launched, even if it's just few seconds after the last launch?..

I've tried opening it with "about:blank" as the only tab saved in the session, to avoid the fancy newtab page that shows rewards. That did not change anything.

Now I'm observing a slightly different behaviour - I might have missed something previously. When Brave is open, it thrashes the hard drive. After several minutes, I've had enough and closed it. After closing, it took a good few seconds to stop the thrashing. then I re-opened it, and it started again, for several more minutes - even though I did not drop caches, and removed my browser cache directory. So my guess about loading the cache was probably wrong. (To clarify the difference: now it does not take very long to die, but while it's open, it's not stopping, no matter how long I wait - several minutes at least.)

rebron commented 4 years ago

@dark-penguin Can you try with the latest version, 1.10.97? Still an issue?

dark-penguin commented 4 years ago

Yes. Almost - it seems to be a little different now.

$ brave-browser --version
Brave Browser 83.1.10.97

Now it looks like this:

rebron commented 4 years ago

cc: @bsclifton

bsclifton commented 4 years ago

@dark-penguin if you're still using Brave, please let us know if you've seen this with more recent versions. There have been some things we've found and fixed - hoping we've made some progress. There's not enough info here for us to reproduce, which is why we really haven't been able to take any concrete steps

dark-penguin commented 4 years ago

I've disabled Brave Rewards some time ago (apparently, "Wallet creation failed" error that I saw before meant that they were enabled, while I concluded the opposite). Now the behavior seems to be normal - starting Brave is quite slow, but that can be considered normal on my system (launching Firefox Quantum takes 20 sec, launching Brave takes 24 sec).

Just to test it, I clicked "Try again" to re-enable rewards, and... now Brave is almost hanged for a good few minutes, thrashing the HDD. So yes, seems like it's a problem with Rewards after all.

Consecutive launches after dropping the disk cache were slower than without rewards, but not by much (without Rewards, 24 sec; with Rewards, 32 sec). It did not keep thrashing for minutes (but I should try again a week later - that's how it was usually reproduced to full extent).

It may be worth mentioning that I'm on btrfs, so if there are any relatively large databases or write-heavy things like that, fragmentation could explain some of it.

I've tried disabling Rewards again, restarting, and re-enabling them. This time, enabling Rewards was instantaneous. Now I can't figure out what's going on. :) But since it seems to be a problem with Rewards, which seem to be kind of "under construction", we can just wait for more Rewards optimizations.

(I'm not really "using" Brave - I have it installed in case something does not work properly on Firefox, and I don't want Chrome. This may explain some things - maybe something goes "stale" and has to rebuild if not launched regularly. But I can usually be helpful in diagnosing bugs, so I wanted to help. I'd imagine that people who can notice thrashing and report bugs are usually not on slow hard drives, so this could go unnoticed for a long time otherwise.)

This was on: Brave Version 1.14.84 Chromium: 85.0.4183.121 (Official Build) (64-bit)

bsclifton commented 4 years ago

cc: @NejcZdovc

cjwijtmans commented 2 years ago

brave seems to be using about 5MB/s (0% disk usages) while it should not be doing anything on the disk at all 🤔