From 0ace3119e6cccb05f592d1faf6384cd5d783dd9f Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Sat, 4 Apr 2020 13:55:37 -0400 Subject: [PATCH] chore: revert to __getcycles --- runtime/include/util.h | 20 -------------------- runtime/src/env.c | 3 +-- runtime/src/runtime.c | 3 +-- runtime/src/sandbox.c | 3 +-- runtime/tests/work/main.c | 4 ++-- runtime/tests/work100k/main.c | 4 ++-- runtime/tests/work10k/main.c | 4 ++-- runtime/tests/work1k/main.c | 4 ++-- runtime/tests/work1m/main.c | 4 ++-- 9 files changed, 13 insertions(+), 36 deletions(-) delete mode 100644 runtime/include/util.h diff --git a/runtime/include/util.h b/runtime/include/util.h deleted file mode 100644 index bb9b1b9..0000000 --- a/runtime/include/util.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef SFRT_UTIL_H -#define SFRT_UTIL_H - -/** - * Get CPU time in cycles using the Intel instruction rdtsc - * @return CPU time in cycles - **/ -static unsigned long long int -util_rdtsc(void) -{ - unsigned long long int cpu_time_in_cycles = 0; - unsigned int cycles_lo; - unsigned int cycles_hi; - __asm__ volatile("rdtsc" : "=a"(cycles_lo), "=d"(cycles_hi)); - cpu_time_in_cycles = (unsigned long long int)cycles_hi << 32 | cycles_lo; - - return cpu_time_in_cycles; -} - -#endif /* SFRT_UTIL_H */ diff --git a/runtime/src/env.c b/runtime/src/env.c index 7e39913..24afe35 100644 --- a/runtime/src/env.c +++ b/runtime/src/env.c @@ -1,7 +1,6 @@ /* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */ #include #include -#include extern i32 inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f); @@ -151,5 +150,5 @@ env_cos(double d) INLINE unsigned long long env_getcycles(void) { - return util_rdtsc(); + return __getcycles(); } diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 7d714d9..9b10d5d 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -22,7 +22,6 @@ #include #include #include -#include /*************************** * Shared Process State * @@ -84,7 +83,7 @@ listener_thread_main(void *dummy) while (true) { int request_count = epoll_wait(runtime_epoll_file_descriptor, epoll_events, LISTENER_THREAD_MAX_EPOLL_EVENTS, -1); - u64 start_time = util_rdtsc(); + u64 start_time = __getcycles(); for (int i = 0; i < request_count; i++) { if (epoll_events[i].events & EPOLLERR) { perror("epoll_wait"); diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 4aa4bea..350f4ba 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -7,7 +7,6 @@ #include #include #include -#include /** * Takes the arguments from the sandbox struct and writes them into the WebAssembly linear memory @@ -140,7 +139,7 @@ current_sandbox_build_and_send_client_response(void) done: assert(sndsz == curr->request_response_data_length); // Get End Timestamp - curr->total_time = util_rdtsc() - curr->start_time; + curr->total_time = __getcycles() - curr->start_time; printf("Function returned in %lu cycles\n", curr->total_time); #ifndef USE_HTTP_UVIO diff --git a/runtime/tests/work/main.c b/runtime/tests/work/main.c index f21e1d2..437e9f7 100644 --- a/runtime/tests/work/main.c +++ b/runtime/tests/work/main.c @@ -13,9 +13,9 @@ main(void) char *d = malloc(MAX_BUF + 1); int r = read(0, d, MAX_BUF); - // unsigned long long st = util_rdtsc(), en = 0; + // unsigned long long st = __getcycles(), en = 0; // wrk(); - // en = util_rdtsc(); + // en = __getcycles(); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); if (r < 0) diff --git a/runtime/tests/work100k/main.c b/runtime/tests/work100k/main.c index 9863b6a..f2aa26a 100644 --- a/runtime/tests/work100k/main.c +++ b/runtime/tests/work100k/main.c @@ -11,9 +11,9 @@ main(void) char *d = malloc(MAX_BUF + 1); int r = read(0, d, MAX_BUF); - // unsigned long long st = util_rdtsc(), en = 0; + // unsigned long long st = __getcycles(), en = 0; // wrk(); - // en = util_rdtsc(); + // en = __getcycles(); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); if (r < 0) diff --git a/runtime/tests/work10k/main.c b/runtime/tests/work10k/main.c index e6f220c..b4d2d15 100644 --- a/runtime/tests/work10k/main.c +++ b/runtime/tests/work10k/main.c @@ -11,9 +11,9 @@ main(void) char *d = malloc(MAX_BUF + 1); int r = read(0, d, MAX_BUF); - // unsigned long long st = util_rdtsc(), en = 0; + // unsigned long long st = __getcycles(), en = 0; // wrk(); - // en = util_rdtsc(); + // en = __getcycles(); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); if (r < 0) diff --git a/runtime/tests/work1k/main.c b/runtime/tests/work1k/main.c index e150be4..aa6fb7f 100644 --- a/runtime/tests/work1k/main.c +++ b/runtime/tests/work1k/main.c @@ -11,9 +11,9 @@ main(void) char *d = malloc(MAX_BUF + 1); int r = read(0, d, MAX_BUF); - // unsigned long long st = util_rdtsc(), en = 0; + // unsigned long long st = __getcycles(), en = 0; // wrk(); - // en = util_rdtsc(); + // en = __getcycles(); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); if (r < 0) diff --git a/runtime/tests/work1m/main.c b/runtime/tests/work1m/main.c index 62e6fff..39ba644 100644 --- a/runtime/tests/work1m/main.c +++ b/runtime/tests/work1m/main.c @@ -11,9 +11,9 @@ main(void) char *d = malloc(MAX_BUF + 1); int r = read(0, d, MAX_BUF); - // unsigned long long st = util_rdtsc(), en = 0; + // unsigned long long st = __getcycles(), en = 0; // wrk(); - // en = util_rdtsc(); + // en = __getcycles(); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); if (r < 0)