savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.4k stars 128 forks source link

Abnormally high CPU spikes on Remote URL Playlists #2475

Closed ItsMitchh closed 2 years ago

ItsMitchh commented 2 years ago

Posting this as per our discussion on Slack.

Describe the bug When attempting to queue or have a single Remote URL playlist (seen below), CPU usage seems to spike up considerably, myself and @Vaalyn was able to reproduce this consistently on two different dev machines. CPU usage graph below from a single station image

To Reproduce remote_url = mksafe(buffer(buffer=20., input.http("http://stream03.dghost.com.br:8180/stream")))

Expected behavior CPU usage should remain within reasonable limits and not spike this hard.

Version details Ubuntu 20.04 Rolling Release v.2.1.0

Install method .deb from GH release: https://github.com/AzuraCast/AzuraCast/blob/main/util/docker/stations/setup/liquidsoap.sh#L24-L30 Common issues Can't decode or encode in some audio format? Check if you have installed the correct dependencies

toots commented 2 years ago

Thanks for this report, I am looking at it rn. Any chance you could post some logs in log level 4?

toots commented 2 years ago

I can confirm. ~2% CPU usage on my machine with 2.0.6, ~30% (!) with 2.1.x, will fix as soon as I can put my finger on this.

toots commented 2 years ago

I was able to trace it down to a bogus resource allocation of the decoder buffer which ended up re-creating the samplerate converter on each frame. This has been fixed and the fix should be in all rolling branches and main now.