brave / brave-browser

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

[Feature request] Add a setting to set the time for the Memory Saver feature #30929

Open ghost opened 1 year ago

ghost commented 1 year ago

By Default, [I think] Memory Saver will start working after 1 hour by default.

In the past, there was the flag HighEfficiencyModeAvailable with options to set the discarding for, 5seconds, 30seconds, 2minutes, 1 hour, etc, all the flag did was to --enable-features=HighEfficiencyModeAvailable:time_before_discard/1h where the 1h could be replaced with any value and with units for ms, s, m, h.

Recent versions of Brave, Chromium changed that flag and now you can only find:

brave://flags/#heuristic-memory-saver-mode with options for Enables, Aggressive, Balanced and Conservative.

The explanation of each mode is found in here Chromium src about_flags.cc

The feature now uses a Threshold as the first value, which is explained in main:components/performance_manager/public/features.h, but pretty much is about the available devices memory when the Memory Saver will start discarding tabs, and the second value is the minimum time a tab was inactive.

So now when starting the browser, the flag will enable the feature as --enable-features=HeuristicMemorySaver:threshold_percent/30/minimum_minutes_in_background/30 for the Aggressive for example.

So, It only works in minutes now, but the good news is the time still can be personalized in the commandline, and while it is still just discarding the tabs, and not sleeping them like other browsers or Brave is still not using Windows 11 efficiency mode, it would be nice if users could just set anytime they want for the Memory Saver in brave://settings/system, and maybe the Threshold, although since that is like an advanced concept for many, maybe it to a high number so it will work as expected for the user, probably 60% or higher.

But It would be nice some more freedom in the way Memory Saver works, instead of relaying on the 'unknown minimum' or 30 minutes being the lowest it can go.

Thank you.

Sa-Ja-Di commented 1 year ago

There is zero real fine tuning possible right now in general. Also no real sleeping tabs, if you look for example at Edge.

Tab memory management/efficiency management is inferior in Brave and should be remade like Microsoft has done it with Edge.

And as we speak about inferior memory management.... The main problem with Brave is that at EVERY start all the open tabs are loaded - in Edge only the most used tabs are loaded, in Vivaldi only the last used tab is loaded.

Brave right now is a SSD writing-cycle destroyer during start-up

ghost commented 1 year ago

@Sa-Ja-Di Brave uses the same memory management as Chrome, the only difference with Chrome seems to be the Efficiency mode being used by Chrome, while Brave doesn't, but to be honest, efficiency mode in Win11 is nothing special, and the internal Edge efficiency mode is pretty bad because it will affects everything badly, including the videos FPS and all that... and for what? not much, would be better just to use SystemInformer to set Brave to a lower priority and it will do a better job when required and giving priority to other processes, just an idea.

Anyway, I am requesting this for people the people who want to use this, like I said in my post it's been available to customize the time for the Memory Saver since it was released by Brave under a different flag. I am not really discussing if Chromium memory saver feature is good or not, I am sure Brave knows about Edge improvements in the memory saving feature there, but we also know how smaller Brave team is and many features Brave will get is because Chromium added them like this one, and all Brave has done is to expose it in the Settings page properly with the exclusion list.

Manually setting the time for the Memory Saver is something pretty easy to hack it through windows registry or the different Brave shortcuts to make Brave always opening with the desired time, but that's obviously not something people are going to do, because it is for advanced users only.

The only thing for normal users is to set Memory Saver to the pre-defined value Chromium decided to want, so Brave adding the input box for the time and exposing it in the Settings page, would be the easiest and best way to do it, just like they did with the exclusion list.

And I don't personally use Memory Saver, because memory is cheap and memory not used is memory wasted, but I am requesting it because it is a pretty simple thing to do for Brave. I am surprised nobody else requested before, a lot of people want it but nobody even tried to make an issue about it.

Whatever problems you are having, you should make the respective issues about it, take the necessary measures about them. Seems like most issues are on Linux uses and I use Windows, so I can't really care much about the issues, when Brave on my side is not writing differently to my disks, Brave is stable in Nightly, Brave uses less CPU than Edge, Brave Vertical tabs is a better experience than Edge, not everything is positive, some issues take to long to resolve but can't complain, sometimes I wish Brave was faster implementing some stuff but it's still okay, so nothing I will complain everyday about.

ghost commented 1 year ago

@rebron Chromium 115.0.5790.32 (since 1.54.72 Nightly) added Memory Saver improvements (flags) exactly for this, so it seems like Brave doesn't have to implement anything, and I guess it is just about making them default if they are 'good enough'.

Enable the multi-state option for Memory Saver Mode.

When enabled, Memory Saver can take one of three options: enabled with a hueristic (spelling mistake) mode, enabled with a fixed timer, and discabled. Configure this through the settings page. – Mac, Windows, Linux, ChromeOS, Fuchsia, Lacros brave://flags/#memory-saver-multi-state-mode

which adds these settings in the Performance panel:

image

There is also:

Configure discard timer for Memory Saver

When set, this controls the time before memory saver discards a tab. – Mac, Windows, Linux, ChromeOS, Fuchsia, Lacros brave://flags/#high-efficiency-mode-time-before-discard

Which adds --time-before-discard-in-minutes= Command Line argument to Brave. But this flag alone doesn't do anything, it depends on the memory-saver-multi-state-mode one to be enabled to change modes, so it doesn't use (I guess) Heuristic Mode = "Brave decides when a tab becomes inactive" with the memory threshold, and can use the fixed time to discard the tabs.

Any value that is not present in memory-saver-multi-state-mode drop-down menu, like 1 minute, is displayed as "custom" (like in my screenshot).

Chromium 115 also added other improvements to memory Saver, like a way to modify the Favicon to make them opaque and also add a ring around it to reflect discarded tabs, and a nicer UI for the popup Report button in the omnibox, and even a button to set Exceptions rights from the omnibox icon, rather than going to settings to do it, and even Efficiency mode for the browser; but these two flags are the only one related to this issue.