From b9ea871f8d180df58417cafa56a21f60190991eb Mon Sep 17 00:00:00 2001 From: Christoph Kirsch Date: Tue, 18 Jul 2023 10:00:38 +0200 Subject: [PATCH 1/3] Fixing tiny bug in profile output --- selfie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfie.c b/selfie.c index ebaae2db..260c6a02 100644 --- a/selfie.c +++ b/selfie.c @@ -10749,7 +10749,7 @@ void print_instruction_versus_exception_profile(uint64_t* parent_context) { ratio_format_integral_2(get_ic_all(parent_context), ic_count) + 1, ratio_format_fractional_2(get_ic_all(parent_context), ic_count)); printf("%s: %lu instructions per exception, handling %lu exceptions in total", selfie_name, - ec_count, ratio_format_integral_2(get_ic_all(parent_context), ec_count)); + ratio_format_integral_2(get_ic_all(parent_context), ec_count), ec_count); } println(); } From 2f8503fb3b640de5d77b1025f1675b7c63a8f89c Mon Sep 17 00:00:00 2001 From: Christoph Kirsch Date: Tue, 18 Jul 2023 11:23:26 +0200 Subject: [PATCH 2/3] Introducing slowdown factor --- selfie.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/selfie.c b/selfie.c index 260c6a02..c91f766b 100644 --- a/selfie.c +++ b/selfie.c @@ -10721,10 +10721,12 @@ void print_instruction_versus_exception_profile(uint64_t* parent_context) { uint64_t ec_count; uint64_t* context; - printf("%s: %lu(%lu.%.2lu%%) executed instructions", selfie_name, + printf("%s: %lu executed instructions [%lu.%.2lu%% share, factor %lu.%.2lu]\n", selfie_name, get_ic_all(parent_context), percentage_format_integral_2(get_total_number_of_instructions(), get_ic_all(parent_context)), - percentage_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context))); + percentage_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context)), + ratio_format_integral_2(get_total_number_of_instructions(), get_ic_all(parent_context)), + ratio_format_fractional_2(get_total_number_of_instructions(), get_ic_all(parent_context))); ic_count = 0; ec_count = 0; @@ -10741,17 +10743,15 @@ void print_instruction_versus_exception_profile(uint64_t* parent_context) { context = get_next_context(context); } - if (ec_count > 0) { + if (ec_count > 0) // assert: get_ic_all(parent_context) > 0 - printf(" [%lu.%.2lu%% overhead, factor %lu.%.2lu]\n", + printf("%s: %lu exceptions handled by %lu instructions each [%lu.%.2lu%% overhead, factor %lu.%.2lu]\n", selfie_name, + ec_count, + ratio_format_integral_2(get_ic_all(parent_context), ec_count), percentage_format_integral_2(ic_count, get_ic_all(parent_context)), percentage_format_fractional_2(ic_count, get_ic_all(parent_context)), ratio_format_integral_2(get_ic_all(parent_context), ic_count) + 1, ratio_format_fractional_2(get_ic_all(parent_context), ic_count)); - printf("%s: %lu instructions per exception, handling %lu exceptions in total", selfie_name, - ratio_format_integral_2(get_ic_all(parent_context), ec_count), ec_count); - } - println(); } void print_profile() { From 84d1a668ea5885d6c72b4179282b697cfba46de8 Mon Sep 17 00:00:00 2001 From: Christoph Kirsch Date: Tue, 18 Jul 2023 16:51:50 +0200 Subject: [PATCH 3/3] Introducing context switching overhead measurement example --- Makefile | 6 +++++- examples/overhead.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 examples/overhead.c diff --git a/Makefile b/Makefile index 213cc5c2..93f4edf3 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,7 @@ selfie-gc-nomain.h: selfie-gc.h # Consider these targets as targets, not files .PHONY: self self-self self-self-check 64-to-32-bit \ whitespace quine escape debug replay \ - emu emu-emu emu-emu-emu emu-vmm-emu os-emu os-vmm-emu \ + emu emu-emu emu-emu-emu emu-vmm-emu os-emu os-vmm-emu overhead \ self-emu self-os-emu self-os-vmm-emu min mob \ gib gclib giblib gclibtest boehmgc cache \ sat brr bzz mon smt beat btor2 all @@ -133,6 +133,10 @@ os-emu: selfie selfie.m os-vmm-emu: selfie selfie.m ./selfie -l selfie.m -m 3 -l selfie.m -y 2 -l selfie.m -y 1 +# Determine overhead of timer interrupts and context switching +overhead: selfie selfie.m + ./selfie -l selfie.m -m 2 -l selfie.m -c examples/overhead.c -y 1 + # Self-compile on emulator self-emu: selfie selfie.m selfie.s ./selfie -l selfie.m -m 3 -c selfie.c -o selfie-emu.m -s selfie-emu.s diff --git a/examples/overhead.c b/examples/overhead.c new file mode 100644 index 00000000..e35f1b8a --- /dev/null +++ b/examples/overhead.c @@ -0,0 +1,10 @@ +// looping for measuring overhead of timer interrupts +// as upper bound on overhead of context switching +uint64_t main() { + uint64_t i; + + i = 0; + + while (i < 1000000000) + i = i + 1; +} \ No newline at end of file