-
Notifications
You must be signed in to change notification settings - Fork 897
Introduce wolfCrypt_Init warmup, WOLFCRYPT_WARMUP #9203
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
base: master
Are you sure you want to change the base?
Conversation
🛟 Devin Lifeguard found 1 likely issues in this PR
@gojimmypi |
7b2733a
to
ced7361
Compare
a62db85
to
037e0a1
Compare
037e0a1
to
a31556d
Compare
Jenkins retest this please For AgentOfflineException: Unable to create live FilePath for wolf-linux-cloud-node-[n]; wolf-linux-cloud-node-[n] was marked offline: Connection was broken |
🛟 Devin Lifeguard found 1 likely issues in this PR
@gojimmypi |
a31556d
to
5895591
Compare
Jenkins retest this please. For AgentOfflineException: Unable to create live FilePath for wolf-linux-cloud-node-[n]; wolf-linux-cloud-node-[n] was marked offline: Connection was broken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this pull request. I think that pre-gaming the heap allocation almost should be something an application does on an individual basis due to the wide range of use cases the wolfSSL library could be in. Rather than something that the library does. For example if the application has long standing RNG and AES structs then the application would allocate those near program startup to keep them near the edge of the available heap.
I've given this a lot of thought, and I tend to agree with you. Still, there's value in this for many targets. I'm considering something that's not specific to any given platform, available to everyone, but not baked into
I'm not certain this is an application feature, rather something like a FreeRTOS semaphore that gets allocated and used forever in RNG. But you are right: perhaps RNG and AES are never used in the application, so why init. |
Description
Adds a
wolfCrypt_Init()
warmup, disabled by default, enable withWOLFCRYPT_WARMUP
.Reason
The random number generator and AES functions were observed allocating long term (perhaps permanent?) heap memory. This PR "warms up" wolfCrypt by calling some sample code early, ensuring (hoping?) any heap allocations are at the edge of the heap and not in the middle.
A long term heap allocation in the middle of the heap, say after reading a large object such as a certificate, may interfere with the long term maximum memory availability.
This PR also makes the wolfcrypt test result more pretty.
Background
I've been optimizing wolfssl for small embedded targets. Some time ago, I introduced a heap discrepancy alert in the wolfcrypt tests. It was intended to find memory leaks after repeatedly running the tests, for example #8506
See the wolfcrypt/test/test.c around line 154 for the
PRINT_HEAP_CHECKPOINT
implementation forWOLFSSL_ESPIDF
targets.There's been a nagging reminder in the tests:
As it only occurs on the first pass of these tests, I did not consider it a memory leak. Still, it's not pretty. But until recently "not pretty" did not warrant attention. Until today when considering the location of the heap object.
Update
Initially this was on-for-everyone. Turns out the initial footprint was unacceptably increased (See Arduino failure). I've updated the PR to be opt-in-only, instead.
Also made these recommended changes after message from
PRB-multi-test-script/7178
:Fixes zd# n/a
Testing
How did you test?
Tested on Espressif ESP32 embedded target and the usual:
Checklist