Fix performance measurements

This commit is contained in:
Sparchatus 2022-05-09 09:36:04 +00:00
parent 8642c075ea
commit b2c12e8c15
16 changed files with 22 additions and 7 deletions

View File

@ -23,6 +23,10 @@
extern coreid_t my_core_id; extern coreid_t my_core_id;
extern rpc_handler_t rpc_handlers[RPC_MTYPE_COUNT]; extern rpc_handler_t rpc_handlers[RPC_MTYPE_COUNT];
#ifdef PERFORMANCE_ENABLED
struct performance_context p;
#endif
errval_t do_aos_urpc( errval_t do_aos_urpc(
struct aos_urpc *rpc, uintptr_t msg_type, struct aos_urpc *rpc, uintptr_t msg_type,
struct capref arg_cap, size_t arg_size, uintptr_t arg0, uintptr_t arg1, struct capref arg_cap, size_t arg_size, uintptr_t arg0, uintptr_t arg1,
@ -144,6 +148,12 @@ static void urpc_server_handler(void *arg) {
// tell the other side that we are done // tell the other side that we are done
urpc->meta->call_in_progress = false; urpc->meta->call_in_progress = false;
#ifdef PERFORMANCE_ENABLED
if(msg_type == RPC_MTYPE_NOP) {
perf_add_now(&p, "done");
}
#endif
// Unblock the URPC thread // Unblock the URPC thread
thread_sem_post(&urpc->sem); thread_sem_post(&urpc->sem);
} }
@ -168,7 +178,6 @@ errval_t aos_urpc_get_bootinfo(struct aos_urpc * rpc, struct bootinfo_serialized
return SYS_ERR_OK; return SYS_ERR_OK;
} }
struct performance_context p;
int urpc_server(void *arg) { int urpc_server(void *arg) {
struct aos_urpc_server *urpc = arg; struct aos_urpc_server *urpc = arg;
struct waitset *default_ws = get_default_waitset(); struct waitset *default_ws = get_default_waitset();
@ -201,7 +210,9 @@ int urpc_server(void *arg) {
waitset_chan_trigger_closure(default_ws, &chan, MKCLOSURE(urpc_server_handler, urpc)); waitset_chan_trigger_closure(default_ws, &chan, MKCLOSURE(urpc_server_handler, urpc));
#ifdef PERFORMANCE_ENABLED #ifdef PERFORMANCE_ENABLED
perf_add_now(&p, "triggered_closure"); if(type_nop) {
perf_add_now(&p, "triggered_closure");
}
#endif #endif
// wait until the rpc is handled // wait until the rpc is handled
@ -209,7 +220,6 @@ int urpc_server(void *arg) {
#ifdef PERFORMANCE_ENABLED #ifdef PERFORMANCE_ENABLED
if(type_nop) { if(type_nop) {
perf_add_now(&p, "done");
perf_print(&p); perf_print(&p);
} }
#endif #endif

View File

@ -11,6 +11,7 @@ void perf_init(struct performance_context *c, char *name) {
inline void perf_add_measurement(struct performance_context *c, char *tag, systime_t timestamp) inline void perf_add_measurement(struct performance_context *c, char *tag, systime_t timestamp)
{ {
assert(c->count < PERFORMANCE_MEASUREMENT_COUNT_MAX);
c->measurements[c->count].tag = tag; c->measurements[c->count].tag = tag;
c->measurements[c->count].timestamp = timestamp; c->measurements[c->count].timestamp = timestamp;
c->count++; c->count++;

View File

@ -39,12 +39,15 @@ def read_data(file):
def build_dataseries(measurements, start_tag, end_tag): def build_dataseries(measurements, start_tag, end_tag):
datapoints = [] datapoints = []
measurements = list(filter(lambda m: start_tag == m["tag"] or end_tag == m["tag"], measurements))
started_at = None started_at = None
for m in measurements: for m in measurements:
if started_at is None: if started_at is None:
if m["tag"] == start_tag: if m["tag"] == start_tag:
started_at = m["timestamp"] started_at = m["timestamp"]
elif m["tag"] == end_tag:
print(f"[ERROR] Got end tag without start {end_tag}")
else: else:
if m["tag"] == end_tag: if m["tag"] == end_tag:
datapoints.append(m["timestamp"] - started_at) datapoints.append(m["timestamp"] - started_at)
@ -85,12 +88,11 @@ def main():
# create plots for data series # create plots for data series
for key in dataset: for key in dataset:
d = dataset[key] d = dataset[key]
d.sort()
p.clf() p.clf()
p.title(key) p.title(key)
p.xlabel("datapoint index") p.xlabel("datapoint index")
p.ylabel("duration (cycles)") p.ylabel("duration (cycles)")
p.scatter(range(len(d)), d) p.plot(range(len(d)), d)
p.savefig(os.path.join(out_dir, f"{key}.jpg")) p.savefig(os.path.join(out_dir, f"{key}.jpg"))
p.clf() p.clf()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -253,20 +253,22 @@ app_main(int argc, char *argv[]) {
struct performance_context p; struct performance_context p;
// measure performance measurement performance // measure performance measurement performance
for(size_t i = 0; i < 1000; ++i) { for(size_t i = 0; i < 100; ++i) {
perf_init(&p, "aos_performance"); perf_init(&p, "aos_performance");
perf_add_now(&p, "start"); perf_add_now(&p, "start");
perf_add_now(&p, "done"); perf_add_now(&p, "done");
perf_print(&p); perf_print(&p);
barrelfish_usleep(10000);
} }
// measure URPC performance // measure URPC performance
for(size_t i = 0; i < 1000; ++i) { for(size_t i = 0; i < 100; ++i) {
perf_init(&p, "aos_urpc_nop"); perf_init(&p, "aos_urpc_nop");
perf_add_now(&p, "start"); perf_add_now(&p, "start");
do_aos_urpc(&urpc_to_bsp, RPC_MTYPE_NOP, NULL_CAP, 0, 0, 0, NULL, NULL, NULL, NULL); do_aos_urpc(&urpc_to_bsp, RPC_MTYPE_NOP, NULL_CAP, 0, 0, 0, NULL, NULL, NULL, NULL);
perf_add_now(&p, "done"); perf_add_now(&p, "done");
perf_print(&p); perf_print(&p);
barrelfish_usleep(10000);
} }
#endif #endif