mbnuqw / sidebery

Firefox extension for managing tabs and bookmarks in sidebar.
MIT License
3.26k stars 163 forks source link

sidebery performance is very slow with large numbers of tabs #591

Open boldcompany opened 2 years ago

boldcompany commented 2 years ago

On a high-performance system, with about 1,000 tabs loaded in a Firefox instance with Sidebery running, Sidebery is laggy but all other Firefox processes complete near-instantly.

As a quick test example:

  1. Close a tab via native Firefox interface. The tab closes instantly.
  2. Close a tab via Sidebery sidebar interface. The tab closes after 2-3 seconds.

Is it possible to improve Sidebery performance?

mbnuqw commented 2 years ago

This is possible (within reasonable limits) and it is planned in v5.

cpgeek commented 2 years ago

Have the proposed performance enhancements been implemented in the current beta or is this something planned for a subsequent version of v5? - Also, my primary computing environment is very performant (5950x, 128gb ram, 3090) and I typically work with 10-15k tabs open. I would very much like to contribute to this project by testing performance improvements as they are implemented. Thank you for such an amazing project!

botkero commented 2 years ago

@cpgeek

I typically work with 10-15k tabs open.

This has nothing to do with the topic, but how do you work with 10k tabs?! How many unique tabs do you have? And do you use special settings to keep tabs loaded or are they unloaded automatically? You do know that you can close tabs? Wouldn't the browsing history be better? How does Sideberry help you with all this? I opened over 1000 tabs for fun and it scrolls for ages with 10k tabs it's 10 times as long. So I would guess you just use the search function of Firefox to search the tabs? I'm really interested in how you work with it because otherwise I see myself just leaving everything open.

megamorphg commented 2 years ago

I'm starting to notice some performance issues too. In addition to some minor lag when switching tabs via keyboard shortucts, closing tabs, and opening new tabs... even when moving mouse over tabs it has a visual lag.

Steps to reproduce:

  1. Have 3 windows open with 100 tabs in each with different nesting levels.
  2. Move mouse over tabs in window 1 twice and observe tab highlighting works fine.
  3. Move mouse over tabs in window 2 twice and observe tab highlighting works fine.
  4. Move mouse over tabs in window 3. Observe the performance slows.

I'm using v5. I think the performance in v4 was better. Turned off animations and made history and bookmarks on-demand only and still experience this issue. Even turned off colorize option (temporarily).

Maybe we can add more things to turn off? I don't need a fancy highlighting animation when moving my mouse over tabs. Definitely worth having more performance improving options though at this point I will just tolerate the minor lags. 😅

megamorphg commented 2 years ago

@botkero I have 1k+ tabs so I can sympathize and can imagine having 10k tabs some day... With automatic unloading of nested tabs (there is no way to live without that), think of it as having a bookmarks tree as tabs instead. Also imagine working on dozens of projects, failing to finish any of them completely, and also a lot of support projects that will never end. And also throw in a bit of laziness of properly organizing and archiving as bookmarks the tabs that will rarely be used.

Bookmark panels or standard bookmarks don't serve the same purpose because it is kind of broken at the moment and too slow to switch to a project (several steps to get to the point of having a bunch of tabs loaded in the proper tree structure and unloaded, ready to load when needed).

nh2 commented 1 year ago

I suffer from this issue as well.

Here are 2 videos that show the problem, one from 2 years ago and one from today, with 1300 and 2000 tabs respectively.

I have to wait for multiple seconds until the tab closes, and then for a few more seconds, sidebery is slow (you can see it in the slow mouseover animations in the second video, after the tab disappears).

2021-10-30

https://user-images.githubusercontent.com/399535/211941823-80cf9dac-1300-44a2-9045-d18a5d5a4791.mp4

2023-01-12 (version 4.10.2)

https://user-images.githubusercontent.com/399535/211941826-8e2e4bd9-35cb-45a1-915e-bdc0f710a36e.mp4

nh2 commented 1 year ago

Also, with the above amount of tabs, if I select 600 tabs and batch-close them, they disappear from the list, but in the tab counter in the top left, the number drops by only 1 per second, meaning it takes 10 minutes for the tabs to close, and during that time, it takes 100% CPU.

This makes getting down from a high tab count slow and tedious.

nh2 commented 1 year ago

I am reasonably sure that tab closing performance gets worse quadratically; having 4x less tabs makes tab closing roughly 16x faster.

muesli4 commented 1 year ago

This goes as far as stopping videos that run in other windows completely (for 2 minutes if I close 250 tabs at once). I have no clue about the firefox architecture, but if it can be influenced so easily it must be bad.

megamorphg commented 1 year ago

I'm on the latest Sidebery and on a newer computer with a 12th gen Intel CPU and more RAM (64GB) and don't notice much in terms of performance issues (sidebar being slow to close, etc.). I have >2000 tabs across 5 windows and 2 panels. 95% of the tabs are suspended of course.

I did used to have random issues (tabs dropping when dragged, slower open/close) on similar hardware before so maybe the last few updates have fixed those UI issues.

jjaksic commented 1 year ago

I just updated from v4.10 to v5.0 RC3 (not before going through the code and thinking "hm, this all looks good to me").

Holy cow, the difference is incredible! I have ~3k tabs and everything happens instantly, whereas with v4 it took seconds of high CPU usage to close a single tab, so closing even a small group was extremely painful (and sometimes closed tabs would later inexplicably reappear). Ironically, I can now close many of my tabs, because it's no longer painful.

I think this issue can be closed.

nh2 commented 1 year ago

Holy cow, the difference is incredible! I have ~3k tabs and everything happens instantly, whereas in v4 it took seconds of high CPU usage to close a single tab

I have tried v5 RC3 too now, and can confirm this (of course I made a backup of my Firefox profile dir first).

Finally Ctrl+T is fast when you have ~1000 tabs!

Awesome.


For others who want to try it:

The Sidebery panel was originally empty after upgrading to the v5.0 RC3. I had to go to the Sidebery settings, which shows a prompt to migrate its state to the new version (and allowed me to do a backup first). Only after that I got my panel contents back.

nh2 commented 1 year ago

@mbnuqw What was the change that made it fast?

Also, can I donate outside of Cryptocurrency options? If not, what service would you recommend to auto-convert your current options?

mbnuqw commented 1 year ago

@nh2 What was the change that made it fast? Well, lots of stuff was rewritten since v4: a new messaging system between different parts of addon, lots of optimizations in updating the internal state after tab creation/removing/moving and rendering... But there is still room for improvements: e.g. currently, sidebery is rendering all elements in list - both visible elements in viewport and scrolled out elements, so the next thing I plan to work on is to skip rendering of the elements out of the visible area by implementing "recycle scroller". (Not sure, will this be added before or after v5 release)

Also, can I donate outside of Cryptocurrency options? No, sorry.

If not, what service would you recommend to auto-convert your current options? Probably the simplest way is to use Trust Wallet to buy/send crypto. There are also cryptocurrency exchanges like: Binance, Coinbase Exchange, Kraken

jlokier commented 11 months ago

TLDR: I'm seeing a nice drop in apparent RAM usage since Sidebery auto-updated to v5 followed by me restarting Firefox (but not until the restart).

I currently have about ~17,000 tabs in about 35 windows.

Until today, Firefox RAM usage (as reported by iStat menus) went up to 20-25GB, or occasionally even 67GB(!) when I opened Telegram web, if I had Sidebery open in general and opened a few tabs (10 or so) in my active window, or just used Firefox for a while. Even non-graphical tabs like Hacker News (news.ycombinator.com), so images were not the cause of the increased RAM usage. This was too much for my 16GB laptop with other things also running on it.

I even saw increases in RAM usage of >1GB when opening one more tab sometimes, with nothing heavy in it.

For a while I'd been using Sidebery, having switched to it from Tree Style Tabs which I'd found after years was the reason Firefox was slow for me. Sidebery felt much faster when I first started using it (except for the very slow "move tabs one at a time" function).

I assumed high RAM usage was just Firefox with that many tabs (most of them unloaded of course, just 1 tab loaded per window, except for my active window). But when the RAM used got to silly levels, and it was straining with swapping and pausing and spinning beachballs, eventually I went through all my extensions. I was disappointed to find disabling Sidebery helped a lot, so Sidebery was in some sense the cause.

Unfortunately, although I confirmed the Sidebery connection by experimenting, about:memory and about:processes showed nothing about this. Neither tabs nor extensions reported excessive memory use, even though it was obviously being used.

Having learned the high RAM use and spikes in RAM use were due to Sidebery or connected to it, I started turning off Sidebary just in my active window, while keeping it on in the others. This worked well. Typical RAM usage dropped to the 17-21GB range, and stayed there reliably rarely exceeding that. This was ok, but things still ran a bit slowly. Most importantly, opening more tabs no longer increased RAM usage a lot. It predictably stayed down to the 17-21GB range, rather than growing to 25+GB sometimes.

I lived with this but it wasn't great. It's a 16GB RAM laptop, with other things running on it too, and Firefox garbage collected rather often, while using a few GB of swap space. And it meant I had to close the Sidebery sidebar in my active window, defeating the point a bit.

...Today. Sidebery has auto-updated itself to v5. I wasn't expecting this. I noticed when the sidebar showed some worrying errors about being unable to load something. Uh oh - did I lose data?

Still, I clicked the "continue" button and thought, hmm, let's try leaving Sidebery on in my active window for a change. Has the memory situation changed? Not really - it wasn't much of an improvement...

...Until I restarted Firefox. Wow!! Since the Firefox restart after the Sidebery update, RAM usage for Firefox is down to about 15GB and seems to be staying there. Even after opening 20 more tabs quickly, which used to raise RAM usage by a few GB predictably, and opening a Telegram web-edition tab, which was my goto test case for pushing up the reported RAM usage to very high levels. It seems to be staying there at about 15GB now.

It's not perfect. There are still little pauses. But it does feel more fluid than before the auto-update, and it's nice to see the RAM used with Sidebery enabled in my active window (and all others), is now using less than when I disabled Sidebery in the active window to save RAM before.

Thanks for this nice performance improvement! Whatever you did to save memory (or not leak, perhaps), keep doing it :-)

devgid commented 7 months ago

I use the extension (Auto Tab Discard) in combination with SideBerry and solved large number of tabs performance problems which shows to me the performance issue is more to do with Firefox than with Sideberry.

Here is the link: https://addons.mozilla.org/en-US/firefox/addon/auto-tab-discard/

This extension has many settings for unloading tabs and it makes no sense moving such functionality to sideberry due to the shear amount of settings you could have. My unloading is set to 10 minutes. After I installed it my performance problems were gone.

Don't be fooled by the name as the tabs stays in Sideberry just unloaded from memory.

I would suggest we don't over-complicate SideBerry with too many option as Tab Unloading has so many options itself.

megamorphg commented 7 months ago

I agree. Another framework limitation is that ATD doesn't discard page group pages, or any plug-in's pages. Have to discard those via Sidebery manually. I just manually discard all tabs in current window with Sidebery once in a while. Not a good enough reason to add to Sidebery, especially since recent updates have fixed issues with performance issues while dragging tabs across windows. Not sure if I notice any more Sidebery specific performance issues anymore... especially after the update last week, especially moving things around among my several windows and thousand+ tabs.

cherrynoize commented 6 months ago

I have all tabs unloaded and only maybe 60 tabs total (though split in 6 panels) and performance is unbearable laggy. I'll admit I am using Floorp, which is kinda experimental, but still the rest of the browser seems to be more reactive.

muesli4 commented 6 months ago

I have all tabs unloaded and only maybe 60 tabs total (though split in 6 panels) and performance is unbearable laggy. I'll admit I am using Floorp, which is kinda experimental, but still the rest of the browser seems to be more reactive.

I do not have UI lag anymore. I am therefore skeptical whether this is the fault of Sidebery. I wonder what Firefox actually does with unloaded tabs. I have thousands of tabs and most are unloaded but it still takes a lot of memory.

vitaly-zdanevich commented 1 month ago

I have almost 6k tabs - waiting ~5 seconds to open :(

https://github.com/user-attachments/assets/73433569-7332-437d-a151-fe1e0575f9aa