MusicBot icon indicating copy to clipboard operation
MusicBot copied to clipboard

CPU load 100% when searching for a song on RPi2

Open dalaverd opened this issue 7 years ago • 11 comments

Hi,

I am running this bot on a Raspberry PI 2. When searching for a new song (!play), it hangs with near 100% CPU usage, which makes the current song playing stutters/skips.

Wiki explicitly says that Raspberry Pi 2 is supported. It doesn't seem to be 100% compatible since it uses the whole CPU load when searching.

Do you know how to make MusicBot use less CPU load for RPi2 or at least reduce stuttering?

dalaverd avatar Oct 29 '16 19:10 dalaverd

It doesn't do that for me. Are you sure that's all you have running?

MayhemBill avatar Oct 29 '16 20:10 MayhemBill

I have transmission and Plex media server running but they only use about 1% each on idle.

dalaverd avatar Oct 29 '16 20:10 dalaverd

You may have installed it wrong im not sure but it's running just fine for me

MayhemBill avatar Oct 29 '16 20:10 MayhemBill

I have followed all the steps for Raspbian. Maybe I should try to reinstall with Debian Jessie Guide since I am on this OS.

dalaverd avatar Oct 29 '16 20:10 dalaverd

It's worth a try. I don't really know what the problem is without fully knowing what went on during install

MayhemBill avatar Oct 29 '16 20:10 MayhemBill

Don't install it on root lmao

MayhemBill avatar Oct 29 '16 20:10 MayhemBill

I have exact same problem on RPI2. When i queue a song while some other song is playing, i get stutter. During the search there is a spike CPU usage and the sound is distorted.

Billy -- when some song is playing, and you search youtube, whats the CPU usage on your installation?

gccpy avatar Oct 31 '16 10:10 gccpy

I have looked at debug information on discord and everything seems normal for the bot. Ping is between 20-40 ms and a reasonable amount of packet losses. My RPi2 has a 50 mbps download connection and I can stream 1080p videos on it. The discord server selected is the one closer to my home where my RPi2 is hosted (US East).

And about the CPU, bot can use up to 100% of a single CPU but my total CPU load never exceeds 50% with a 1 GHz quad core CPU (RPi2).

So I have eliminated all of the possible reasons that are not related to the application :

  • Internet connection
  • Discord's servers
  • CPU usage

Using !play or !search with longer sentences on YouTube cause longer skips and artifacts. So there is a direct link between bot using ressources for song queries and the quality and consistency of the current song played.

Otherwise, if no commands are executed during a song, bot is flawless and song is played normally. The workaround is waiting for a song to finish to search for another one but it's not practical.

Please don't close this thread saying it's not an application issue.

dalaverd avatar Oct 31 '16 13:10 dalaverd

I'm not sure on why you're getting high CPU load while running the bot on your Pi. When playing or searching for a video/song, the bot asynchronously executes a query using youtube-dl.

I'm gonna ping @imayhaveborkedit here and see if it's anything we can look into.

jayktaylor avatar Oct 31 '16 14:10 jayktaylor

Its not likely its youtube-dl. The stutter seems to be caused by search, there is no skipping when playing a video directly through its URL. Also tried downloading some random videos with youtube-dl command directly while playing something on the musicbot, and there was no interference.

gccpy avatar Nov 04 '16 16:11 gccpy

Can confirm this happens in RPi3 as well, observing the top command I can see that it is python3.5 that draws most CPU resources (50%+) while the transcoding by ffmpeg stays stable at around 5%

Tested another musicbot (https://github.com/jagrosh/MusicBot) and it didnt have the same problem, so it is not the pi that is bottlenecking.

Waester avatar Feb 09 '17 16:02 Waester

considering py 3.5 is outdated now I'm going to close this issue.

BabyBoySnow avatar Oct 20 '23 17:10 BabyBoySnow