Topic: Performance Advisory for Cortex M - Newlib vs Newlib-Nano

I am posting these results as they may be helpful to others building on an embedded Cortex M platform.

I had a working project build with Segger Embedded Studio for a Nordic NRF52840 (64MHz Cortex M).        We switched our build tooling to use cmake/ninja along with the newlib-nano libraries packaged with ARM GCC tools. One thing I noticed is that our TLS handshake in our application went from 3 seconds to about 16 seconds.

Using the built in wolf test functions,  I was able to track down the issue.

While Segger Embedded Studio uses GCC,  they have their own buildsof the C standard libraries.    The wolfcrypt ECC routines are very sensitive to how the C libraries are built.

Results:

I could eventually get *better* performance than the SES custom library but had to use NewLib and not NewLib-nano.    This results in a larger binary but the performance is much better.   


wolf test time:

Segger Embedded Studio w/ custom std libs: 208 seconds
ARM GCC Embedded w/ Newlib-Nano:  608 seconds
ARM GCC Embedded w/ Newlib:  202 seconds
ARM GCC Embedded w/ Newlib &WOLFSSL_SP_ARM_CORTEX_M_ASM :  175 seconds


In addition to using Newlib,  I found the macro WOLFSSL_SP_ARM_CORTEX_M_ASM  helped quite a bit.  (Looks like it has hand tuned ASM routines for SP math).


Apparently newlib is built with speed optimizations and newlib-nano is built with size optimizations.      I was surprised to the stark difference.     I have other math heavy routines and the difference in execution speed is only 5% between -03 and -Os.     It seems that the ECC SP routines have some sensitivity to the C library.


Hope this is helpful to anyone building for a Cortex M MCU.

Share

Re: Performance Advisory for Cortex M - Newlib vs Newlib-Nano

Hi eli.hughes,

Thanks for sharing these findings. I also hope other folks on the Cortex M will see this. The SP WOLFSSL_SP_ARM_CORTEX_M_ASM option is quite impressive for RSA/DH/ECC math speedups because it uses hand written assembly.

I will suggest to marketing we make this into a blog post.

Thanks,
David Garske, wolfSSL

Share