Skip to content

benchmark: Use benchmark from Mbed TLS #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 15, 2021

Conversation

Patater
Copy link
Contributor

@Patater Patater commented Jun 9, 2021

We previously used an older copy of benchmark.c and modified it. This
made it difficult to keep up with improvements and bug fixes from Mbed
TLS. For easier maintenance, use the benchmark.c application as-is (no
modifications) from Mbed TLS. The version imported in this commit is
from Mbed TLS v2.25.0.

Update the expected log output to reflect the new benchmarking output
style.

The benchmark application from Mbed TLS has a dependency on
MBEDTLS_TIMING_C, so add that to our application-specific Mbed TLS
configuration file. This will use the alternate implementation of the
Mbed TLS timing module that Mbed OS provides.

As the benchmark application was designed to run on a PC, its stack
usage is pretty heavy. Configure the main stack to be 32 KiB to
accommodate this.

Fixes #297

@Patater Patater changed the base branch from master to development June 9, 2021 16:08
@Patater
Copy link
Contributor Author

Patater commented Jun 9, 2021

Depends on ARMmbed/mbed-os#14756

@Patater Patater force-pushed the vanilla-benchmark branch from 3f96c4d to 66053ea Compare June 9, 2021 16:15
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 10, 2021

Depends on ARMmbed/mbed-os#14756

It was merged. We got Travis blocked until we sort out the plan (later today).

@Patater Patater force-pushed the vanilla-benchmark branch from 66053ea to 3366156 Compare June 10, 2021 17:39
@Patater Patater requested a review from LDong-Arm June 11, 2021 07:59
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 11, 2021

Travis resumed.

Let's get this in as soon as we can to unblock Mbed OS, we still need to update CI and test.

Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patater Thanks for the fix.

One comment on removing main.cpp.

Also, there's a build error with the Arm Compiler:

In file included from ../../../../benchmark.c:46:
In file included from ../../../../mbed-os/connectivity/mbedtls/./include/mbedtls/timing.h:60:
../../../../mbed-os/connectivity/mbedtls/./platform/inc/timing_alt.h:31:20: error: field has incomplete type 'struct timeval'
    struct timeval start;
                   ^
../../../../mbed-os/connectivity/mbedtls/./platform/inc/timing_alt.h:31:12: note: forward declaration of 'struct timeval'
    struct timeval start;
           ^
1 error generated.
ninja: build stopped: subcommand failed.
ERROR: CMake invocation failed!

I'm looking into this now.

And, we'll need to update benchmark.c when we upgrade Mbed TLS in mbed-os. I wonder what's the best way to ensure this happens.

@Patater
Copy link
Contributor Author

Patater commented Jun 11, 2021

we'll need to update benchmark.c when we upgrade Mbed TLS in mbed-os. I wonder what's the best way to ensure this happens.

When we move examples into the mbed-os repo itself, updating Mbed TLS and associated examples will be more straightfoward (can be done in one PR)

Patater added 2 commits June 11, 2021 13:24
We previously used an older copy of benchmark.c and modified it. This
made it difficult to keep up with improvements and bug fixes from Mbed
TLS. For easier maintenance, use the benchmark.c application as-is (no
modifications) from Mbed TLS. The version imported in this commit is
from Mbed TLS v2.25.0.

Update the expected log output to reflect the new benchmarking output
style.

The benchmark application from Mbed TLS has a dependency on
MBEDTLS_TIMING_C, so add that to our application-specific Mbed TLS
configuration file. This will use the alternate implementation of the
Mbed TLS timing module that Mbed OS provides.

As the benchmark application was designed to run on a PC, its stack
usage is pretty heavy. Configure the main stack to be 32 KiB to
accommodate this.

Fixes ARMmbed#297
The current Mbed TLS benchmark application requires MBEDTLS_GENPRIME
(RSA key generation) to be enabled in order to benchmark RSA. Mbed OS
doesn't enable MBEDTLS_GENPRIME by default, so add it to our
application-specific Mbed TLS configuration file.

Update the expected log output to reflect the freshly enabled RSA
benchmarks.
@Patater Patater force-pushed the vanilla-benchmark branch from 3366156 to d70ca8e Compare June 11, 2021 12:25
@Patater
Copy link
Contributor Author

Patater commented Jun 11, 2021

Deleted the old main.cpp, so CLI 1 won't find it.

@LDong-Arm
Copy link
Contributor

When we move examples into the mbed-os repo itself, updating Mbed TLS and associated examples will be more straightfoward (can be done in one PR)

Sounds good. Then we'll be able to extend our import scripts to automate this.

@Patater Patater requested a review from LDong-Arm June 11, 2021 12:37
Copy link
Contributor

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Patater LGTM. The test output matches the log file using mbedhtrun.

The Arm Compiler issue mentioned previously is fixed by ARMmbed/mbed-os#14772, but it doesn't prevent us from merging this PR first which points to the master branch of Mbed OS. Just both of them should be part of the upcoming release.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 15, 2021

Can we merge this now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run-time failure on K66F "ECDSA-x25519 : Public function returned -0x4F80"
3 participants