MP3 Decoder cpu usage

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

MP3 Decoder cpu usage

Postby shabtronic » Thu Dec 19, 2019 4:25 am

Hi folks

I'm just playing around with vTaskGetRunTimeStats, and noticed the mp3 decoder is taking a fair chunk of the cpu usage.

I'm assuming the percentage stats are for both cores combined?

I'm running at 240mhz and I'm getting the following in a release build:

Task Name,Count,Percentage.

DisplayTask 49360006 24
IDLE0 28193852 13
IDLE1 51624214 25
Tmr Svc 108215 <1
esp_periph 673339 <1
tiT 222317 <1
eventTask 19 <1
ipc1 27443 <1
wifi 80810 <1
el-DspProcessor 3382366 1
el-DspInput 2564051 1
ipc0 23721 <1
el-i2s-out 4072345 2
el-i2s-in 4188545 2
el-mp3Decoder 54327737 26
el-PlayFatStream 2369882 1
main 989639 <1
esp_timer 100 <1


el-mp3Decoder 54327737 26% - I guess that's both cores - so mp3 decoder is taking up 50% of 1 core at 240mhz - sounds a little slow - previously I've work on a ARM7 core and mp3 took up around 40mhz - I know you can't compared cpu's and systems e.t.c..

Any ideas where my cpu power is going :)

Shabby

mikemoy
Posts: 626
Joined: Fri Jan 12, 2018 9:10 pm

Re: MP3 Decoder cpu usage

Postby mikemoy » Thu Dec 19, 2019 2:53 pm

Its not off both cores. You can further prove that by pinning it to either core 0 or core 1.
Also, Core 0 (IDLE0 13) is 100%-13% = 87% idle time.
Also, Core 1 (IDLE1 25) is 100%-25% = 75% idle time.

So you can see it's still pretty much spending most of its time twiddling its fingers waiting for something do to. :D

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: MP3 Decoder cpu usage

Postby shabtronic » Thu Dec 19, 2019 6:07 pm

sweeeet - I hope that's correct!! I thought 50% of 1 core for mp3 decode - even with float precision would be a little heavy :)

Thanks a lot for clearing that up!

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: MP3 Decoder cpu usage

Postby shabtronic » Thu Dec 19, 2019 9:36 pm

I've now checked this again, and I think my initial interpretation was correct. I modified vTaskGetRunTimeStats to dump out float percentages and sorted the results in a stl vec list and then
dumped it out via printf. You can see both cores sum to 50%

I'm using ESP Timer as the stats menuconfig setting.

wonder what is going on here?

Code: Select all

CoreID  CPU %         Name            Counter

0         0.0                   ipc0        23609
0         0.0              esp_timer          165
0         0.0              eventTask           18
0         0.1                Tmr Svc       213415
0         0.4                   main      1044498
0         0.4             esp_periph      1148741
0         1.1            el-DspInput      3258728
0         1.7        el-DspProcessor      4853202
0         2.0             el-i2s-out      5938200
0         2.2              el-i2s-in      6306547
0         4.5           el-FatReader     13123428
0        13.4         el-flacDecoder     39281883
0        24.2                  IDLE0     70659451
// core zero sums to roughly 50%
1         0.0                   ipc1        27399
1         0.0                   wifi        80848
1         2.0                  IDLE1      5945890
1        47.9            DisplayTask    139905869
// core one sums roughly to 50%
flac decoder is taking 13.4% overall - which would be 26.8% of core zero

and in this run

Code: Select all

CoreID  CPU %         Name            Counter
0         0.0                   ipc0        23621
0         0.0              esp_timer           17
0         0.0              eventTask           18
0         0.1                Tmr Svc        47718
0         0.4             esp_periph       328556
0         1.1           el-FatReader       893900
0         1.2            el-DspInput       937313
0         1.6                   main      1257980
0         1.7        el-DspProcessor      1343979
0         2.1             el-i2s-out      1668628
0         2.3              el-i2s-in      1878145
0        16.0                  IDLE0     12780879
0        21.6          el-mp3Decoder     17281307

1         0.0                   ipc1        27402
1         0.1                   wifi        80864
1         4.1                  IDLE1      3289757
1        45.7            DisplayTask     36604502
mp3 decode is taking 21.6x2 = 43.2% of core zero!

this looks like legit results because my DisplayTask I know is def taking up 90% of core one, because it's a crappy I2C SH1106 - and spends most of its time in the I2C data blit.

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: MP3 Decoder cpu usage

Postby shabtronic » Fri Dec 20, 2019 2:52 am

And the culprit was - allowing spi-ram/ps-ram to be used recklessly :)
Turning off spi-ram gets me much more realistic usage:

Since vTaskGetRunTimeStats does actually divide the % by the number of cores - I re modified that function to spit out core % rather than cpu %:

Code: Select all

CoreID  Core %        Name            Counter
0         0.10               Tmr Svc         1002
0         0.52            esp_periph         5318
0         1.22             el-i2s-in        12408
0         1.28          el-FatReader        13047
0         1.32           el-DspInput        13427
0         1.70            el-i2s-out        17397
0         2.15          el-DspOutput        21951
0        25.13         el-mp3Decoder       256455
0        66.59                 IDLE0       679564

1         2.33                 IDLE1        23782
1        97.67           DisplayTask       996719
Seems it's best to tightly control spi-ram usage :)

houhaiyan
Posts: 5
Joined: Thu May 30, 2019 2:08 am

Re: MP3 Decoder cpu usage

Postby houhaiyan » Mon Jan 20, 2020 11:44 am

can you give me the your used music ? and tell me the example you used.

User avatar
shabtronic
Posts: 49
Joined: Sun Nov 03, 2019 1:33 pm

Re: MP3 Decoder cpu usage

Postby shabtronic » Tue Jan 21, 2020 7:53 am

I'm afraid not - the mp3/flac player I wrote only plays random files from the sd-card every time. It's like a "discovery" shuffle system - I wrote it so I could never actually select a track - just Prev/Next from a random list sized 1024 tracks. I wrote it this way because I have some many audio files I've never listened to - and thought a fixed random shuffle player would force me to listen to the stuff I've never heard :)

I can tell you this tho:

1) 99.9% of my mp3 were 44.1khz
2) 99.9% of my flac files were 48khz 16bit.

Hope that helps!

Who is online

Users browsing this forum: No registered users and 37 guests