qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.23k stars 3.97k forks source link

Qbittorrent freeze every 30sec #17451

Open Aleksman4o opened 2 years ago

Aleksman4o commented 2 years ago

qBittorrent & operating system versions

qBittorrent-nox: 4.5.0 from master Operating system: Manjaro, kernel 5.18 libtorrent-rasterbar: 2.0.7

What is the problem?

While uploading ~30-40k torrents faster than ~500mbit, qbitttorrent freezes every 30 sec and start using 1 cpu thread at 100% for 2-3 sec, while other threads not used. While this happens, disks busy at 5%, network busy 5%, used memory not changes. I've been seeing this behavior for a long time, but my internet was not so fast, so that was not noticeable. I've tried various settings - had no affect, usually i have 40k active torrents, 100 upload slot and 4GB cache.

Steps to reproduce

  1. Get gigabite internet
  2. run qbittorrent with 30k torrents
  3. ...
  4. PROFIT

Additional context

Screenshot_20220729_040547

Log(s) & preferences file(s)

qBittorrent.conf.txt

glassez commented 2 years ago

Can you test it with libtorrent-1.2?

Aleksman4o commented 2 years ago

Can you test it with libtorrent-1.2? Little bit later. I'm also noticed increase opened sockets while freeze happens Screenshot_20220729_102727

stalkerok commented 2 years ago

What router do you have? I can describe a similar problem, but mine is most likely related to the router. My TP-Link Archer AX55 router and I have such drops every minute when the gigabit channel is fully loaded from two PCs, if you use gigabit from only one PC, then there is no such thing.

Aleksman4o commented 2 years ago

I have two routers now for 2 gigabits connection - Archer C5 and Keenetic Speedster. There's no difference which one i'm using. And it is qbittorrent fully loaded 1 thread cpu while freezing

Aleksman4o commented 2 years ago

Can you test it with libtorrent-1.2?

recompiled qbittorrent with libtorrent-rasterbar-1-1.2.17. This problem still exists too. Although problem with moving files to another disk after downloading has gone :) Screenshot_20220729_135926

Aleksman4o commented 2 years ago

I found network_threads setting in libtorrent, default is 1, may be this is a bottleneck. How can i increase this setting to test perfomance?

xavier2k6 commented 2 years ago

I'm sure network_threads was deprecated?!

Perhaps looking in to recv_socket_buffer_size & send_socket_buffer_size may be better options?!

Aleksman4o commented 2 years ago

Not sure this can help, but i can try. How can i tune this options?

Aleksman4o commented 2 years ago

Well, may be it's a story of my success. I've decided to perform some inspection with Perf tool and inspected Qbittorrent process, that eats 100% of 1 cpu while freeze happens and seen that read_hpet is a main character of this process - about 17% of all calls, if i'm understood it right. There are zillion of calls clock_gettime() while freeze. So i googled hpet and found that it's precision timer one of a three - tsc, hpet and acpi_pm. cat /sys/devices/system/clocksource/clocksource0/available_clocksource shows that my system supports only last two of them. Hpet is about 20 times slower than tsc and that's why calls to it eats my processor. So, i'm just add clocksource=tsc tsc=reliable to linux kernel parameters and reboot the machine. After that cat /sys/devices/system/clocksource/clocksource*/current_clocksource shows tsc and it's look like my problem is solved. Now i can say that qbittorrent perfomance is just amazing.

Aleksman4o commented 2 years ago

It seems tsc=reliable cause some issues with zfs, so it's not solve the probem :(

xavier2k6 commented 2 years ago

@arvidn If & when you have time, can you look into this please.

arvidn commented 2 years ago

I imagine the underlying issue is that libtorrent end up in a state where a timer expires and is reissued at the current time, and so it fires again, pegging the CPU. @Aleksman4o would you be willing to share the perf profile you collected? maybe just a screenshot of the top call stacks.

There was an issue with HTTP tracker timeouts that was fixed recently that could have this symptom. Could this be it?

I believe it was released in 1.2.17 and 2.0.7. https://github.com/arvidn/libtorrent/pull/6951

arvidn commented 2 years ago

one issue I recently discovered was that, when I have a VPN enabled, linux broadcasts frequent redundant updates over NETLINK_ROUTE sockets. Libtorrent currently subscribes to such updates to be notified of changes to the local network setup (new interfaces coming online or disappearing).

When this notification happens often, all the work libtorrent does to re-open listen sockets can add up and be expensive (as well as announcing to trackers). This is being addressed in https://github.com/arvidn/libtorrent/pull/7058

Aleksman4o commented 1 year ago

Fresh news: now i have about 70k torrents and qbittorrent's freezes now more massive ) image

xavier2k6 commented 1 month ago

@Aleksman4o How does qBittorrent v5.0.0 behave for you?

Aleksman4o commented 1 month ago

It seems there was some improvements. But i understand that i'm not typical qbittorrent user, so i've divided qbittorrent on 2 instances to solve this problem. image