From af75e21ac47f8b20746bb540139dd2a8eefa8c11 Mon Sep 17 00:00:00 2001 From: FritzFlorian Date: Thu, 23 Jan 2020 10:53:10 +0100 Subject: [PATCH] Add benchmark results from running on x86 and arm32. --- app/context_switch/CMakeLists.txt | 4 ++-- app/context_switch/deboost.context/CMakeLists.txt | 1 + app/context_switch/fiber_call.cpp | 9 --------- app/context_switch/measurements/asm32.txt | 19 +++++++++++++++++++ app/context_switch/measurements/plot.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ app/context_switch/measurements/x86_64.txt | 21 +++++++++++++++++++++ 6 files changed, 102 insertions(+), 11 deletions(-) delete mode 100644 app/context_switch/fiber_call.cpp create mode 100644 app/context_switch/measurements/asm32.txt create mode 100644 app/context_switch/measurements/plot.py create mode 100644 app/context_switch/measurements/x86_64.txt diff --git a/app/context_switch/CMakeLists.txt b/app/context_switch/CMakeLists.txt index 0722218..99f4482 100644 --- a/app/context_switch/CMakeLists.txt +++ b/app/context_switch/CMakeLists.txt @@ -4,7 +4,7 @@ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME STREQUAL "Lin SET(SWITCH_ASSEMBLY "custom_stack_callback_x86_64.s") SET(FIBER_ASSEMBLY "fiber_call_x86_64.s" "fiber_continue_x86_64.s") elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(SWITCH_ASSEMBLY "custom_stack_callback_arm32.s" fiber_call.h fiber_call.cpp) + SET(SWITCH_ASSEMBLY "custom_stack_callback_arm32.s" fiber_call.h context_switcher.cpp) SET(FIBER_ASSEMBLY "fiber_call_arm32.s" "fiber_continue_arm32.s") else () MESSAGE(FATAL_ERROR "Platform (${CMAKE_SYSTEM_PROCESSOR} on ${CMAKE_SYSTEM_NAME}) not supported! Please see Readme for instructions to port.") @@ -14,7 +14,7 @@ endif () add_executable(context_switch main.cpp ${SWITCH_ASSEMBLY} - fiber_call.h fiber_call.cpp + fiber_call.h ${FIBER_ASSEMBLY}) # Example for adding the library to your app (as a cmake project dependency) diff --git a/app/context_switch/deboost.context/CMakeLists.txt b/app/context_switch/deboost.context/CMakeLists.txt index f16c2fb..3a87e38 100644 --- a/app/context_switch/deboost.context/CMakeLists.txt +++ b/app/context_switch/deboost.context/CMakeLists.txt @@ -71,6 +71,7 @@ target_include_directories(fcontext PRIVATE include/fcontext INTERFACE include) +set_property(TARGET fcontext PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE) set_target_properties(fcontext PROPERTIES FOLDER Deps ${IOS_GENERAL_PROPERTIES}) install(TARGETS fcontext DESTINATION lib) diff --git a/app/context_switch/fiber_call.cpp b/app/context_switch/fiber_call.cpp deleted file mode 100644 index 210b738..0000000 --- a/app/context_switch/fiber_call.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "fiber_call.h" - -namespace pls { -namespace internal { -namespace base { - -} -} -} diff --git a/app/context_switch/measurements/asm32.txt b/app/context_switch/measurements/asm32.txt new file mode 100644 index 0000000..3603100 --- /dev/null +++ b/app/context_switch/measurements/asm32.txt @@ -0,0 +1,19 @@ +Output on the banana pi + +Base +Function Call : 4975613, 4.97561 +Simple Loop : 1269267, 1.26927 +Longjmp +Stack Switching : 11255742, 11.25574 +Full Continuation: 54504045, 54.50404 +Jump Continuation: 128717262, 128.71727 +Boost +FContext Fast : 51930723, 51.93073 +FContext Clean : 57454099, 57.45410 +FContext CallCC : 101296455, 101.29646 +Custom +Custom Fast Call : 23745875, 23.74588 + + +Used stack size about 92 bytes. + diff --git a/app/context_switch/measurements/plot.py b/app/context_switch/measurements/plot.py new file mode 100644 index 0000000..9881cc2 --- /dev/null +++ b/app/context_switch/measurements/plot.py @@ -0,0 +1,59 @@ +import numpy as np +from matplotlib import pyplot as plt + +labels = ['loop overhead', + 'function call', + 'stack switching', + 'setjmp + stack switching', + 'fcontext switch, return', + 'fcontext create, switch, return', + 'pseudo callcc', + 'custom' + ] + +call_color = (0.3, 0.1, 0.4, 0.6) +setjmp_color = (0.3, 0.3, 0.4, 0.6) +fcontext_color = (0.3, 0.6, 0.4, 0.6) +custom_color = (0.3, 1.0, 0.4, 0.6) +colors = [ + call_color, + call_color, + setjmp_color, + setjmp_color, + fcontext_color, + fcontext_color, + fcontext_color, + custom_color +] + +dataX86 = np.array([ + 0.55, + 2.79, + 5.60, + 14.93, + 9.51, + 11.00, + 18.66, + 7.86, +]) +dataARM32 = np.array([ # TODO: Run and fill in data...damn that laptop crash + 1.26, + 4.97, + 11.25, + 54.50, + 51.93, + 57.45, + 101.29, + 23.74, +]) +data = dataARM32 + +assert (len(labels) == len(data), "Must fill in all data!") +xAxis = np.array(range(0, len(labels))) + +plt.bar(xAxis, data, color=colors) +plt.xticks(xAxis, labels, rotation=90) +plt.ylabel('runtime in ns') +plt.subplots_adjust(bottom=0.5, top=0.98) + +plt.show() diff --git a/app/context_switch/measurements/x86_64.txt b/app/context_switch/measurements/x86_64.txt new file mode 100644 index 0000000..2374d21 --- /dev/null +++ b/app/context_switch/measurements/x86_64.txt @@ -0,0 +1,21 @@ +Output on my x86_64 laptop: +- Ubuntu 18.04.3 LTS +- Core i7-8550U CPU @1.80 GHz (turbo boost/frequency scaling disabled) +- Results of best run using nice -20 + +Base +Function Call : 2796349, 2.79635 +Simple Loop : 557062, 0.55706 +Longjmp +Stack Switching : 5602146, 5.60215 +Full Continuation: 14935945, 14.93594 +Jump Continuation: 33523215, 33.52322 +Boost +FContext Fast : 9517573, 9.51757 +FContext Clean : 11006061, 11.00606 +FContext CallCC : 18661906, 18.66191 +Custom +Custom Fast Call : 7860666, 7.86067 + + +Used stack size about 32 bytes. -- libgit2 0.26.0