Skip to content

schedstats: revert to 32Bit, and enhance output of schedstats#7048

Merged
kaspar030 merged 3 commits intoRIOT-OS:masterfrom
smlng:enh/ps/schedstats
Sep 28, 2017
Merged

schedstats: revert to 32Bit, and enhance output of schedstats#7048
kaspar030 merged 3 commits intoRIOT-OS:masterfrom
smlng:enh/ps/schedstats

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented May 12, 2017

based on #6975

@smlng smlng added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation State: waiting for other PR State: The PR requires another PR to be merged first labels May 12, 2017
@smlng smlng self-assigned this May 12, 2017
@smlng smlng force-pushed the enh/ps/schedstats branch 2 times, most recently from e6e3ce0 to 1346d3b Compare May 15, 2017 14:12
@smlng smlng mentioned this pull request May 15, 2017
@kaspar030 kaspar030 added the Area: core Area: RIOT kernel. Handle PRs marked with this with care! label May 16, 2017
@kaspar030
Copy link
Copy Markdown
Contributor

As this touches the scheduler, we need to check for impact on context switch times. ping if you need test applications...

@smlng
Copy link
Copy Markdown
Member Author

smlng commented May 16, 2017

@kaspar030 ping 😉 I think this should also be tested for #6975? Because that introduces most of the changes, here I merely get rid of double and replace it by 2 unsigned ints.

@smlng smlng force-pushed the enh/ps/schedstats branch from 1346d3b to df4fb39 Compare May 16, 2017 10:16
@smlng smlng changed the title [WIP] ps: enhance output of schedstats ps: enhance output of schedstats May 16, 2017
@smlng smlng added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 16, 2017
@cgundogan
Copy link
Copy Markdown
Member

needs a rebase

@smlng smlng force-pushed the enh/ps/schedstats branch from df4fb39 to 1e792c4 Compare June 1, 2017 08:38
@smlng smlng changed the title ps: enhance output of schedstats schedstats: revert to 32Bit, and enhance output of schedstats Jun 1, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 1, 2017

partly reverts #6975 back to 32Bit timer, gets rid of float in ps output, and enhances the ps_schedstats tests

@smlng smlng force-pushed the enh/ps/schedstats branch from 1e792c4 to fd2b870 Compare June 1, 2017 08:42
@smlng smlng removed the State: waiting for other PR State: The PR requires another PR to be merged first label Jun 1, 2017
@smlng smlng requested a review from kaspar030 June 1, 2017 08:42
* @param[in] callback The callback functions the will be called
*/
void sched_register_cb(void (*callback)(uint32_t, uint32_t));
void sched_register_cb(void (*callback)(uint64_t, uint32_t));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

First parameter could remain uint32_t as laststart is.

{
int next = (int)arg < NB_THREADS - 1 ? (int)arg + 1 : 0;
msg_t msg;
int next = ((int)arg +1) % NB_THREADS;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

coding style: spaces around +

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oops

msg_t m1, m2;
msg_receive(&m1);
/* generate differents loads per thead */
for (int i = 0; i < 10*(next+1); ++i) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oops, again

for (int i = 0; i < 10*(next+1); ++i) {
_xtimer_now64();
}
xtimer_usleep(XTIMER_BACKOFF*3);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

aargg 😉

@smlng smlng force-pushed the enh/ps/schedstats branch from fd2b870 to cc3173f Compare June 1, 2017 09:02
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 1, 2017

comments addressed

@smlng smlng force-pushed the enh/ps/schedstats branch 4 times, most recently from 31096b7 to d6b670c Compare June 1, 2017 09:26
@vincent-d
Copy link
Copy Markdown
Member

Something is wrong with ratio calculation:

> ps
2017-06-01 11:34:53,398 - INFO #  ps
2017-06-01 11:34:53,412 - INFO # 	pid | name                 | state    Q | pri | stack  ( used) | base addr  | current     | runtime  | switches
2017-06-01 11:34:53,425 - INFO # 	  - | isr_stack            | -        - |   - |   512 (  132) | 0x20000000 | 0x200001c8
2017-06-01 11:34:53,443 - INFO # 	  1 | idle                 | pending  Q |  15 |   256 (  128) | 0x20000744 | 0x200007c4  | 37.3733% |     99389
2017-06-01 11:34:53,462 - INFO # 	  2 | main                 | running  Q |   7 |  1536 (  768) | 0x20000844 | 0x20000c3c  | 65226.2620% |      4078
2017-06-01 11:34:53,482 - INFO # 	  3 | thread               | bl rx    _ |   6 |  1024 (  388) | 0x20000eec | 0x2000122c  | 10.1039% |     41529
2017-06-01 11:34:53,503 - INFO # 	  4 | thread               | bl rx    _ |   6 |  1024 (  388) | 0x200012ec | 0x2000162c  | 12.1230% |     41669
2017-06-01 11:34:53,520 - INFO # 	  5 | thread               | bl rx    _ |   6 |  1024 (  388) | 0x200016ec | 0x20001a2c  | 14.1449% |     41811
2017-06-01 11:34:53,539 - INFO # 	  6 | thread               | bl rx    _ |   6 |  1024 (  388) | 0x20001aec | 0x20001e2c  | 16.1640% |     41953
2017-06-01 11:34:53,559 - INFO # 	  7 | thread               | bl mutex _ |   6 |  1024 (  388) | 0x20001eec | 0x2000222c  |  8.8210% |     42094
2017-06-01 11:34:53,568 - INFO # 	    | SUM                  |            |     |  7424 ( 2968)

(This was on nucleo144-f413)

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 1, 2017

yeah, I there are some artifacts, I'm on it - will mark as WIP for the time being

@smlng smlng added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jun 1, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 1, 2017

I tested with native, where the values seem to be okay and the sum < 100%. However, I also tested on remote-revb, I don't see such huge values as you did, but the sum is constantly > 100% 🙁 weird ...

sys/ps/ps.c Outdated
unsigned runtime_major = (runtime_ticks * 100) / rt_sum;
unsigned runtime_minor = ((runtime_ticks % rt_sum) * 1000) / rt_sum;
/* add trailing zeros */
while(runtime_minor < 100) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

note to self: this shouldn't be necessary

@smlng smlng force-pushed the enh/ps/schedstats branch from 1af2e63 to d2426bc Compare June 2, 2017 09:05
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 2, 2017

some performance results using @kaspar030 bench_msg tool:

branch stats native remote-revb
master no 108000 (100%) 17951 (100%)
master yes 38000 (35%) 12341 (69%)
this PR yes 56000 (52%) 15032 (84%)

@smlng smlng added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 2, 2017

@kaspar030 your review in this one?

core/sched.c Outdated
schedstat *active_stat = &sched_pidlist[active_thread->pid];
if (active_stat->laststart) {
active_stat->runtime_ticks += now - active_stat->laststart;
/* ensure now > laststart, to avoid flawed sum of runtime ticks
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO we can remove this check. It doesn't catch all overflows anyways. Worse, it drops indeterministic periods depending on when the thread got scheduled.
I think that losing 71minute overflows, and documenting that properly, is preferable than this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... losing 71minute overflows ...

It would mean that all running/sleeping periods would be counted module 2**32 xtimer ticks, which is ~71minutes. I doubt that it would have significant impact in ps output, compared to dropping all periods that happen to have an overflow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

mhm, how do you get 71 minutes? Doesn't that depend on the timer frequency - which is 1MHz for many boards but 250kHz for Ardunio Uno, for instance ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I changed the calculation to be more generic, should be cool now 🤓

@smlng smlng force-pushed the enh/ps/schedstats branch from d2426bc to 564f35f Compare June 8, 2017 12:53
core/sched.c Outdated
active_stat->runtime_ticks += now - active_stat->laststart;
}
/* add up runtime, overflow compatible */
active_stat->runtime_ticks += (((uint64_t)now + UINT32_MAX) -
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what does this to compared to the simple difference?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

öhm, actually nothing - I was thinking to complicated, need coffee ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

btw. reverted to simple difference

@smlng smlng force-pushed the enh/ps/schedstats branch from 564f35f to 2b39fe1 Compare June 8, 2017 13:21
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 9, 2017

@kaspar030 addressed your comments, happy?

@smlng smlng force-pushed the enh/ps/schedstats branch from 2b39fe1 to 19351b5 Compare June 9, 2017 08:50
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 16, 2017

@kaspar030 do you mind having a look again?

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 23, 2017

ping @kaspar030. This one is ready, only your ACK is missing.

@aabadie aabadie added this to the Release 2017.07 milestone Jun 23, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jul 2, 2017

long time no see, @kaspar030 anything to add here?

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jul 27, 2017

@kaspar030 still waiting for you to come back here and have a look

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Sep 20, 2017

@kaspar030 this one hangs around for some time now, IIRC you weren't happy with the 64bit changes so why not revert and improve with this one?

@smlng
Copy link
Copy Markdown
Member Author

smlng commented Sep 28, 2017

and another ping @kaspar030, this (re)improves test performance as you wished 😉

@kaspar030 kaspar030 merged commit 5cc8204 into RIOT-OS:master Sep 28, 2017
@smlng smlng deleted the enh/ps/schedstats branch September 28, 2017 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants