tests: add stack usage metrics#17706
Conversation
|
this might still have some DEVELHELP related issues. |
310e099 to
14c4bd9
Compare
4cbe89d to
4ebc158
Compare
|
Mmmh, the metric collection fails when an application runs multiple threads with the same name (or, restarts one of them). :( I'm trying to come up with a solution that doesn't require the metrics collection script to deal with metric specific cases, like, Would creating a list make sense, if there's multiple entries? that would look like this: (note the multiple "used" entries for t1 and t2) |
|
OK, I went with the threads being a list: this needs a fix to the metrics script so lists get concatenated. |
|
results after the murdock scripts have been updated Details{
"metrics": {
"tests/malloc_thread_safety": {
"native:gnu": {
"threads": [
{
"name": "t1",
"stack_size": 4096,
"stack_used": 860
},
{
"name": "t2",
"stack_size": 4096,
"stack_used": 860
},
{
"name": "t1",
"stack_size": 4096,
"stack_used": 472
},
{
"name": "t2",
"stack_size": 4096,
"stack_used": 472
},
{
"name": "idle",
"stack_size": 8192,
"stack_used": 600
},
{
"name": "main",
"stack_size": 12288,
"stack_used": 2508
}
]
}
},
"tests/thread_cooperation": {
"native:gnu": {
"threads": [
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2508
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2412
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2412
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2412
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2412
},
{
"name": "thread",
"stack_size": 8192,
"stack_used": 2412
},
{
"name": "idle",
"stack_size": 8192,
"stack_used": 436
},
{
"name": "main",
"stack_size": 12288,
"stack_used": 2612
}
]
}
}
}
} |
7161055 to
c64a776
Compare
6f741e1 to
3e8362f
Compare
|
I think this is good to go! |
maribu
left a comment
There was a problem hiding this comment.
Code looks good to me and test output was provided. Please squash the style nitpick right in.
This commit adds a module that can print stack metrics in the format as understood by CI.
- activate THREAD_CREATE_STACKTEST also if test_utils_print_stack_usage is used - make thread_measure_stack_free() available unconditionally - if DEVELHELP is active, call test_utils_print_stack_usage() on any thread exit - if DEVELHELP is active, call test_utils_print_stack_usage() after main for the idle thread, if that is used
fe3e733 to
2a13f07
Compare
|
Thanks! |
|
|
|
on it |
|
Hm. The pthread threads' stack is too small for the printing of the stack sizes :/ |
DISABLE_MODULE then? |
|
Using fmt if available, don't print anything if the stack is too small: #17891 |
Contribution description
This PR adds a module that, when enabled, will make threads print their stack usage on exit, in a format that the CI's metrics collection understands (and is somewhat human readable).
Example:
Details
This has some impact, the printing itself uses printf. Also, the actual stack data fields are kept per-thread, so 8 bytes more per thread. That means unfortunately some tests for some small-ram boards fall over the cliff.
Testing procedure
CI should be fine.
Issues/PRs references