google / lyra

A Very Low-Bitrate Codec for Speech Compression
Apache License 2.0
3.84k stars 355 forks source link

decoding supisciously slow on Snapdragon octo-core #63

Open nsornin opened 3 years ago

nsornin commented 3 years ago

Dear android team, thanks for contributing this codec open source

I have benchmarked it on an 1.8Ghz octo-core Snapdragon SDM 450 phone running android 11 and i am very surprised by the difference in performance compared to the benchmark values you are providing for a pixel 4 phone.

This is for a fixed point implementation. 09-20 16:20:41.991 3477 3513 I test : conditioning_only stats for generating 2000 frames of audio, max: 1063 us, min: 816 us, mean: 840 us, stdev: 26.4008. 09-20 16:20:41.991 3477 3513 I test : model_only stats for generating 2000 frames of audio, max: 33525 us, min: 28257 us, mean: 29113 us, stdev: 270.771. 09-20 16:20:41.992 3477 3513 I test : combined_model_and_conditioning stats for generating 2000 frames of audio, max: 34421 us, min: 29105 us, mean: 29953 us, stdev: 270.185.

for a floating point implementation i get: 09-20 17:16:58.356 4829 4966 I test : conditioning_only stats for generating 2000 frames of audio, max: 3619 us, min: 1267 us, mean: 1329 us, stdev: 86.6372. 09-20 17:16:58.356 4829 4966 I test : model_only stats for generating 2000 frames of audio, max: 61199 us, min: 51126 us, mean: 52220 us, stdev: 501.567. 09-20 17:16:58.356 4829 4966 I test : combined_model_and_conditioning stats for generating 2000 frames of audio, max: 62540 us, min: 52488 us, mean: 53549 us, stdev: 519.02.

So basically the decoder runs just slighly faster than real time in fixed point (30msec decode for 40msec audio) and much slower in floating point. Your pixel phone averaged at <10msec float point for the same job so 5x faster. I cannot see that there is such a hardware performance difference between my phone and a pixel 4. From your experience , where should i be looking first ? Are there any compile option i should be carefull about ?

Apart from that I have tested the codec sound quality in many different scenarios and i find it very good , specifically in noisy environment where it outperforms what i have tried so far. If i can get the speed issue fixed i am planning to further test its robustness to typical radio link packet loss patterns.

Any hint is appreciated. Thanks !

aluebs commented 3 years ago

That is weird indeed. Are you running with "-c opt" and "--config=android_arm64"? Else I am not sure why you would be seeing such a bug discrepancy.

yeroro commented 3 years ago

It looks like SDM 450 is significantly slower than the CPU of Pixel 4 or Pixel 5: Pixel 4: https://nanoreview.net/en/soc-compare/qualcomm-snapdragon-855-vs-qualcomm-snapdragon-450 Pixel 5: https://nanoreview.net/en/soc-compare/qualcomm-snapdragon-765g-vs-qualcomm-snapdragon-450

So this might be expected I guess?

nsornin commented 3 years ago

@aluebs thanks for your answer Here is the exact command i use to build under linux using bazel: bazel build android_example:lyra_android_example --config=android_arm64 --copt=-DBENCHMARK --extra_toolchains=@rules_python//python:autodetecting_toolchain_nonstrict --copt=-DUSE_FIXED16

@yeroro :+1: thanks for the link. Effectively that article states that Snap 855 Performs 7.3x better in floating-point computations than 450. This could be coherent with the 5x discrepancy that i am measuring.

aluebs commented 2 years ago

The new Lyra 1.2.0 release is about 5x faster than the previous version, if you would like to try it out.