Skip to content

Echo Server: Simplify benchmarking setup - #757

Draft
cazb2 wants to merge 1 commit into
mainfrom
callumb/benchmark_0
Draft

Echo Server: Simplify benchmarking setup#757
cazb2 wants to merge 1 commit into
mainfrom
callumb/benchmark_0

Conversation

@cazb2

@cazb2 cazb2 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This commit removes a #define that was guarding utilisation information from being captured on x86. From my perspective x86 seems to have the same support as risc-v (pmu not yet supported) thus we make the #defines match.

This commit removes the idle thread setup. seL4 already has an idle thread, and in the benchmark configuration the kernel tracks its utilisation like any other normal thread. Thus we can retrieve identical (if not more accurate) information about idle utilisation from seL4.

This commit removes the total cycles and idle cycles print by ip bench, since we log this in the benchmark pd now. This also simplifies the implementation & reduces the sloc to achieve the same thing.

This commit removes a #define that was guarding utilisation information
from being captured on x86. From my perspective x86 seems to have the
same support as risc-v (pmu not yet supported) thus we make the #defines
match.

This commit removes the idle thread setup. seL4 already has an idle
thread, and in the benchmark configuration the kernel tracks its
utilisation like any other normal thread. Thus we can retrieve identical
(if not more accurate) information about idle utilisation from seL4.

This commit removes the total cycles and idle cycles print by ip bench,
since we log this in the benchmark pd now. This also simplifies the
implementation & reduces the sloc to achieve the same thing.

Signed-off-by: Callum <c.berry@student.unsw.edu.au>
@cazb2
cazb2 force-pushed the callumb/benchmark_0 branch from 370e94a to 8f84f94 Compare July 31, 2026 13:06
@cazb2
cazb2 marked this pull request as ready for review July 31, 2026 13:29
@cazb2

cazb2 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

link to one article discussing how idle time can be calculated,
https://hewlettpackard.github.io/netperf/doc/netperf.html.

With respect to the accuracy of this accounting the kernel provides as an example:
IdleLocalCPUUtilisation: 780 957 224 686
IdleTCBCPUUtilisation: 780 957 224 686
IdleNumberSchedules: 277 266
IdleKernelUtilisation: 756 712 398
This is enough information to determine the duration that the idle thread is scheduled (due to their being no other tasks to run) and the time the kernel runs ("IdleKernelUtilisation") when the idle thread is the current thread. Thus handling of interrupts by the kernel while the idle thread is running can be subtracted to give the true number of cycles the system is doing no useful work at all.

@cazb2
cazb2 requested a review from Courtney3141 August 3, 2026 10:24
@midnightveil

midnightveil commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Those should definitely be three separate commits, and maybe separate PRs.

I'm pretty sure we have an explicit idle thread for a reason - for one, on certain platforms (mostly ARM32 ones to be fair) the kernel WFI turns off the cycle counter's clocks to save power, which affects measurement - for two, I believe it was mentioned as feedback for one of the papers we submitted, that measuring idle cycles in a user thread represents a more accurate measurement of idle time because it represents actually useable time by other threads; whereas using the kernel idle thread has less overhead compared to someone doing real work that requires an extra mode switch to userspace.

@Courtney3141

Copy link
Copy Markdown
Contributor

Yes, we discussed this with Peter yesterday, we don't want to remove the idle thread (it is indeed there for a reason).

This commit removes a #define that was guarding utilisation information from being captured on x86.

This should definitely be a separate PR. Please make one.

strcat(buffer, ibuf);
strcat(buffer, ",");
strcat(buffer, tbuf);
strcpy(buffer, RES(5, 0, 0));

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.

BTW you are supposed to be reporting your CPU utilisation to IPbench here, which it seems that you no longer do...

@terryzbai

Copy link
Copy Markdown
Contributor

This commit removes a #define that was guarding utilisation information from being captured on x86.

This should definitely be a separate PR. Please make one.

I included this in ixgbe driver PR, which reads TSC in idld thread. I can make a separate commit/PR once the ixgbe driver code is fine to get merged.

@cazb2

cazb2 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

I see, maybe there is no choice but to compute idle time based off a user-level idle thread given this was requested in feedback. It's just unfortunate because based off of what I've read about computing idle time in networking benchmarks online, counting the CPUs true idle cycle count is the preferred method. For instance the netperf docs go into a decent amount of detail in how they prioritise different ways of computing idle time, and they only use the user-level idle thread when there is not a more accurate alternative such as an accurate kernel idle thread counter. But, oh well, I guess we are just being conservative about any idle time reported.

If we do want to compute the cycles spent in an idle user-level thread could the current implementation be simplified (reducing a significant amount of C and python code) and potentially made more accurate by using the kernels counters? More specifically, since the kernel counters provide the total utilisation and the kernel utilisation of each TCB, can't we take the difference, which should yield almost the exact number of cycles the idle thread runs in user level? This could avoid inaccuracies associated with not counting cycles to get into the user level loop, assuming idle time is only possible when a loop iteration takes less than a constant #defined amount of cycles, (for example pipeline stalls, cache misses etc could also occur in the idle thread resulting in a longer loop iteration but we might not count these cycles).

@KurtWu10

KurtWu10 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

As a side note, the reported kernel utilisation under smp is not accurate AFAIK (see issue #570).

@cazb2

cazb2 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Oh jeez, it seems like your solution of making the benchmark info core local is clean though? And then the user can combine the data from each core themself? Or is there some edge case where you can't do this?

@KurtWu10

KurtWu10 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I'm not convinced that my fixes are complete; there could be some other holes. Further careful comparisons are desired.

@Courtney3141

Copy link
Copy Markdown
Contributor

If we do want to compute the cycles spent in an idle user-level thread could the current implementation be simplified (reducing a significant amount of C and python code) and potentially made more accurate by using the kernels counters? More specifically, since the kernel counters provide the total utilisation and the kernel utilisation of each TCB, can't we take the difference, which should yield almost the exact number of cycles the idle thread runs in user level? This could avoid inaccuracies associated with not counting cycles to get into the user level loop, assuming idle time is only possible when a loop iteration takes less than a constant #defined amount of cycles, (for example pipeline stalls, cache misses etc could also occur in the idle thread resulting in a longer loop iteration but we might not count these cycles).

Something like this could potentially work, but you would need to arrange something so the echo server client also has access to these values as well as the benchmark PD. Which is possible but would require more code.

@Courtney3141
Courtney3141 marked this pull request as draft August 7, 2026 04:27
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.

5 participants