bazarr icon indicating copy to clipboard operation
bazarr copied to clipboard

High CPU usage at idle

Open 2fst4u opened this issue 1 year ago • 18 comments

Describe the bug Bazarr seems to have consistently high CPU at idle, with no tasks in particular running other than the regular searches. Without limits in place on my system I see over 1 whole core of CPU used consistently.

To Reproduce Steps to reproduce the behavior:

  1. Nothing in particular. Just always high CPU

Expected behavior At idle I'd expect no more than 100 milicores of CPU. I understand some tasks are intensive but they're not always running.

Software (please complete the following information):

  • Bazarr: v1.1.0 however I've seen this consistently for many versions so far
  • Radarr version: 4.1.0.6175
  • Sonarr version: 3.0.8.1507
  • OS: Ubuntu 21.10

Additional context Running on kubernetes (so docker)

2fst4u avatar Jul 30 '22 05:07 2fst4u

Can you show as some graph with debug log?

We need to see what is bazarr doing at that time.

halali avatar Jul 30 '22 05:07 halali

I don't have a graph because it's just constant. Left unlimited the CPU usage just stays above 1 full core. I have it limited to about 500 milicores currently and it's still working fine so I'm continually lowering the limit to see what breaks.

What's the best way to upload debug logs? I have one for the last hour or two.

2fst4u avatar Jul 30 '22 23:07 2fst4u

What's the best way to upload debug logs? I have one for the last hour or two.

You can simply put it here or use 0bin.

morpheus65535 avatar Aug 11 '22 11:08 morpheus65535

I started a new debug log since it was a while ago now that I opened this but the CPU usage is still high while it was logging. bazarr.log

2fst4u avatar Aug 11 '22 21:08 2fst4u

@2fst4u there's nothing wrong in your log. Can you show us top output or anything that cna show us the process using that much CPU?

If possible, send me your last Bazarr backup in private on Discord so I look into your db and config just in case.

morpheus65535 avatar Aug 12 '22 12:08 morpheus65535

This is a TOP from inside the container: This is a TOP from inside the container

This is a static output from kubectl top This is a static output from kubectl top which shows resource usage from the Kubernetes cluster. This is with the pod limited to 400milicores (so it maxes it out).

I will send db via discord.

2fst4u avatar Aug 15 '22 03:08 2fst4u

What kind of hardware are you using to run Bazarr?

First impression:

  • You should enable multithreading to search concurrently on all enabled providers.
  • Sonarr and Radarr should be accessed directly, not through your reverse proxy.
  • Embeddedsubtitles provider is resource intensive but it doesn't seems to be your issue here.
  • Subtitles synchronization is also resource intensive.

Other than that, I don't see anything wrong in your database or config.ini file.

morpheus65535 avatar Aug 15 '22 12:08 morpheus65535

I may have an issue relating to this I updated on the 25th of August (Australia) to latest linuxserver docker file and have witnessed high CPU usage finally was able to investigate it tonight and narrowed it down to Bazarr and the python3 process. I thought it might be the Custom Post Processing running Subcleaner as that's python3 but disabling that and restarting still has high usage.

GazaShaggy avatar Aug 29 '22 08:08 GazaShaggy

I may have an issue relating to this I updated on the 25th of August (Australia) to latest linuxserver docker file and have witnessed high CPU usage finally was able to investigate it tonight and narrowed it down to Bazarr and the python3 process. I thought it might be the Custom Post Processing running Subcleaner as that's python3 but disabling that and restarting still has high usage.

Same for me. Since a few days my fans are blasting every hour or so. Also using linuxserver docker (compose). I tried reinstalling but no luck yet. Never had such high CPU before, my server is in my room and it kept me up at night (so that is saying something). I am going to disable bazarr for now, waiting for a fix.

light-bit avatar Aug 30 '22 20:08 light-bit

@light-bit there no fix in the pipeline as I don't know what's causing this issue and I can't replicate.

morpheus65535 avatar Aug 30 '22 20:08 morpheus65535

@light-bit there no fix in the pipeline as I don't know what's causing this issue and I can't replicate.

Sure. I understand. The weird thing is that I did not change any settings, maybe it is a connection issue with external sources. I am going to do another clean install with minimum settings, see if that helps. Maybe it is the sub providers? Cuz I did notice Subscene being disconnected a few times.

light-bit avatar Aug 30 '22 20:08 light-bit

Sure. I understand. The weird thing is that I did not change any settings, maybe it is a connection issue with external sources. I am going to do another clean install with minimum settings, see if that helps. Maybe it is the sub providers? Cuz I did notice Subscene being disconnected a few times.

Thanks for teting out. You can also try hotio image without changing your config directory. Just to see if it's related to LSIO. Also, subscene is a broken providers for many, you can try subf2m as a replacement.

morpheus65535 avatar Aug 30 '22 20:08 morpheus65535

Sure. I understand. The weird thing is that I did not change any settings, maybe it is a connection issue with external sources. I am going to do another clean install with minimum settings, see if that helps. Maybe it is the sub providers? Cuz I did notice Subscene being disconnected a few times.

Thanks for teting out. You can also try hotio image without changing your config directory. Just to see if it's related to LSIO. Also, subscene is a broken providers for many, you can try subf2m as a replacement.

I deleted my config dir (to start fresh) and ran the LSIO Docker Compose once again. I decided to not add Subscene this time. I am only using OpenSubtitles.org, which should be enough anyway. It seems to have fixed my issue. I do not see any CPU spikes on my server anymore, and the fans are not blasting every now and then. Not sure if this will help the other guys with high CPU usage but wanted to get the word out at least.

Could it be that Bazarr constantly trying to connect to a faulty provider, such as Subscene, causes this? Cuz it doesn't sound like a CPU heavy task.

light-bit avatar Aug 31 '22 10:08 light-bit

@light-bit did you try to simply remove subscene from you previous config?

morpheus65535 avatar Aug 31 '22 10:08 morpheus65535

@morpheus65535 Nope, honestly I did not expect it to be the culprit. But you are right, I should have tried. :)

light-bit avatar Aug 31 '22 15:08 light-bit

honestly I did not expect it to be the culprit

Me neither and that's why I would have appreciated if we could have cleared that (or not) as the root cause.

morpheus65535 avatar Aug 31 '22 16:08 morpheus65535

I will try to reproduce it, I will let you know.

light-bit avatar Aug 31 '22 17:08 light-bit

I didn't have sub scene to start with for context. So I don't think it's related.

2fst4u avatar Aug 31 '22 18:08 2fst4u

I installed Bazarr under Docker on a Synology just now -- the config is completely default and it's showing rather high CPU usage.

Screen Shot 2022-09-30 at 11 54 21 AM

Screen Shot 2022-09-30 at 11 57 25 AM

The web server also doesn't seem to respond, I'm not able to pull up the home page.

endquote avatar Sep 30 '22 18:09 endquote

Dont think this is an issue..

You installed bazarr and bazarr need to index your database, and also bazarr use ffmpeg to extract some info from files... This can be cpu intensive especially on nas device... If this cpu usage will be high also after some time... Post debug log so we can at least see what bazarr is doing. Its hard debug something from screenshots.

halali avatar Sep 30 '22 20:09 halali

This is a fresh install on an empty machine -- there is nothing to index.

Looking at the logs, it was caught in some kind of loop because the time zone wasn't set correctly: tzlocal.utils.ZoneInfoNotFoundError: 'tzlocal() does not support non-zoneinfo timezones like %s. \nPlease use a timezone in the form of Continent/City'

Maybe a more graceful failure is possible here.

endquote avatar Sep 30 '22 20:09 endquote

@endquote of course we can catch it but we'll need the full stack trace, not just the error.

morpheus65535 avatar Sep 30 '22 23:09 morpheus65535

I don't have anything left to investigate here. Unless someone is able to provide useful informations to find the root cause, I won't be able to do anything about it.

morpheus65535 avatar Oct 22 '22 13:10 morpheus65535

Yea sorry I haven't been able to get a time series logger installed so I can't pinpoint when it happens. I hope I'm not the only one with this and that others experience this.

I guess this should be closed with a view to reopen if there is anymore information.

-------- Original Message -------- On 23 Oct 2022, 02:07, morpheus65535 wrote:

I don't have anything left to investigate here. Unless someone is able to provide useful informations to find the root cause, I won't be able to do anything about it.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

2fst4u avatar Oct 22 '22 17:10 2fst4u

@2fst4u feel free to reopen once you have time to bring more information to pinpoint the root cause.

morpheus65535 avatar Oct 24 '22 01:10 morpheus65535

Was having same issue then reversed the Continent/City timezone in the environmental variables used in the container. Recreated the container and it no longer consumed high CPU and would now launch web app.

E.G

This didn't work - - TZ=Sydney/Australia

This worked - - TZ=Australia/Sydney

hamishm456 avatar Jan 14 '23 05:01 hamishm456

That's really odd because it shouldn't work. Maybe that just "breaks" the timezone setting and stops whatever was causing the bug from occurring?

I still get this issue on the latest version. I'll try just commenting out my timezone.

2fst4u avatar Jan 14 '23 05:01 2fst4u

very odd. I have all my docker-compose scripts in a single stack file and deploy in Portainer. Every other container uses City/Continent except Bazarr which uses Continent/City.

hamishm456 avatar Jan 14 '23 05:01 hamishm456

Yea but what I mean is, is it actually using it in the reversed form? Or is it just broken and therefore ignored by bazarr?

2fst4u avatar Jan 14 '23 05:01 2fst4u

Incredibly removing the timezone envvar seems to have done the trick. I'll leave it for a day and see what happens.

2fst4u avatar Jan 14 '23 09:01 2fst4u