Conversation
jnohlgard
left a comment
There was a problem hiding this comment.
Why is runtime_ticks a double in the first place?
|
How did you verify it's working and which platform did you use? |
|
I tested on cortex-m3 (stm32f2). I assumed it worked before. It must be a leftover of the recent xtimer works. |
| #endif | ||
| #ifdef MODULE_SCHEDSTATISTICS | ||
| double runtime_ticks = sched_pidlist[i].runtime_ticks / (double) xtimer_now() * 100; | ||
| double runtime_ticks = sched_pidlist[i].runtime_ticks / |
There was a problem hiding this comment.
It seems like this only works for the first 2**32 ticks after boot, right? (Now that we're looking at it. :) )
There was a problem hiding this comment.
And ... can we get change this to use uint64_t?
|
| * Scheduler statistics | ||
| */ | ||
| typedef struct { | ||
| unsigned int laststart; /**< Time stamp of the last time this thread was |
There was a problem hiding this comment.
uint64_t would be more semantically correct since _xtimer_now64 returns an uint64_t
core/sched.c
Outdated
|
|
||
| #ifdef MODULE_SCHEDSTATISTICS | ||
| unsigned long time = _xtimer_now(); | ||
| unsigned long long time = _xtimer_now64(); |
There was a problem hiding this comment.
a better name for this variable would be now or something. time() is a POSIX standard function in time.h so it's better to avoid that name for clarity.
|
|
@vincent-d I think you address[ed] all comments, please rebase and squash accordingly; and we give Murdock a try 😉 |
29a1daa to
b43ef8a
Compare
|
squashed |
I think I understand now! |
|
or we don't use float nor double, see my follow up PR #7048. Your PR here already does a lot: use uint64_t and xtimer_now64 and adds a tests! |
|
that's exactly what I meant: revert to double and refine that using #7048 |
Fix xtimer_now() usage and fix columns alignment in ps command when module schedstatistics is used.
b43ef8a to
cfe5eac
Compare
|
Fixed and squashed directly |
|
@smlng do you want to re-ACK ? Otherwise I think we can go. |
|
as @kaspar030 did not object, ACK and GO |
|
Did you just merge 64bit calculations into the scheduler?! I thought adding the "core" flag would lead to more thorough review. |
|
Context switch performance goes down from 26k/sec to 18k/sec with this PR, with enabled schecstatistics... |
| #include <stdio.h> | ||
| #include <inttypes.h> | ||
|
|
||
| #include <shell.h> |
There was a problem hiding this comment.
For future reference: internal includes are marked with #include "header.h" instead of #include <header.h>
So guys, what do we do about it. Ignore it, revert, fix? |
|
@kaspar030 please share your performance test application. And clarify what did you compare:
|
|
I used this: https://github.com/kaspar030/RIOT/tree/add_bench_msg/tests/bench_msg The test sends messages in a loop from the main thread to a second thread, which just receives them in a loop. After one second, it stops and outputs how many messages could be sent. I compared the results of master afgter merging this PR without The results ( (The benchmark result is very unstable on native, probably due to CPUs slowly scaling up. So to get meaningful results, run it on real hardware.) |
|
The module was broken, anyway. We can go back to 32bits knowing that it would work only for the first 32bits ticks. This is a reasonable limitation I guess. |
|
I can confirm @kaspar030 findings that switching performance drops from 60% to 40% using schedstatistics with 64Bit instead of 32Bit compared to performance without stats. Besides other issue with the module, we already that know gathering stats will influence overall performance. Question remains: how to proceed, and is another drop that severe? What about impact of xtimer performance on this one - which can be improved as well as, see #7053? Btw. I get a hardfault on pba-d-01-kw2x when using the stats module, regardless of the changes in this PR - even reverting them completely doesn't help. |
Good point, but only matters if xtimer is run with a timer on a different clock domain than the default. |
Would it be possible to count using a 32bit variable on context switch, but record any overflows? ... and handle the 64bit math on printing? edit All variables being 32bit. |
|
can't we use |
wouldn't you need overflow detection per |
|
ah, right (in a way) - we may need to combine |
Fix xtimer_now() usage and fix columns alignment in ps command when
module schedstatistics is used.