chore: revert to __getcycles

main
Sean McBride 5 years ago
parent a949cbebe3
commit 0ace3119e6

@ -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 */

@ -1,7 +1,6 @@
/* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */ /* https://github.com/gwsystems/silverfish/blob/master/runtime/libc/libc_backing.c */
#include <runtime.h> #include <runtime.h>
#include <ck_pr.h> #include <ck_pr.h>
#include <util.h>
extern i32 inner_syscall_handler(i32 n, i32 a, i32 b, i32 c, i32 d, i32 e, i32 f); 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 INLINE unsigned long long
env_getcycles(void) env_getcycles(void)
{ {
return util_rdtsc(); return __getcycles();
} }

@ -22,7 +22,6 @@
#include <sandbox_request.h> #include <sandbox_request.h>
#include <software_interrupt.h> #include <software_interrupt.h>
#include <types.h> #include <types.h>
#include <util.h>
/*************************** /***************************
* Shared Process State * * Shared Process State *
@ -84,7 +83,7 @@ listener_thread_main(void *dummy)
while (true) { while (true) {
int request_count = epoll_wait(runtime_epoll_file_descriptor, epoll_events, int request_count = epoll_wait(runtime_epoll_file_descriptor, epoll_events,
LISTENER_THREAD_MAX_EPOLL_EVENTS, -1); LISTENER_THREAD_MAX_EPOLL_EVENTS, -1);
u64 start_time = util_rdtsc(); u64 start_time = __getcycles();
for (int i = 0; i < request_count; i++) { for (int i = 0; i < request_count; i++) {
if (epoll_events[i].events & EPOLLERR) { if (epoll_events[i].events & EPOLLERR) {
perror("epoll_wait"); perror("epoll_wait");

@ -7,7 +7,6 @@
#include <uv.h> #include <uv.h>
#include <libuv_callbacks.h> #include <libuv_callbacks.h>
#include <current_sandbox.h> #include <current_sandbox.h>
#include <util.h>
/** /**
* Takes the arguments from the sandbox struct and writes them into the WebAssembly linear memory * 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: done:
assert(sndsz == curr->request_response_data_length); assert(sndsz == curr->request_response_data_length);
// Get End Timestamp // 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); printf("Function returned in %lu cycles\n", curr->total_time);
#ifndef USE_HTTP_UVIO #ifndef USE_HTTP_UVIO

@ -13,9 +13,9 @@ main(void)
char *d = malloc(MAX_BUF + 1); char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF); int r = read(0, d, MAX_BUF);
// unsigned long long st = util_rdtsc(), en = 0; // unsigned long long st = __getcycles(), en = 0;
// wrk(); // wrk();
// en = util_rdtsc(); // en = __getcycles();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0) if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1); char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF); int r = read(0, d, MAX_BUF);
// unsigned long long st = util_rdtsc(), en = 0; // unsigned long long st = __getcycles(), en = 0;
// wrk(); // wrk();
// en = util_rdtsc(); // en = __getcycles();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0) if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1); char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF); int r = read(0, d, MAX_BUF);
// unsigned long long st = util_rdtsc(), en = 0; // unsigned long long st = __getcycles(), en = 0;
// wrk(); // wrk();
// en = util_rdtsc(); // en = __getcycles();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0) if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1); char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF); int r = read(0, d, MAX_BUF);
// unsigned long long st = util_rdtsc(), en = 0; // unsigned long long st = __getcycles(), en = 0;
// wrk(); // wrk();
// en = util_rdtsc(); // en = __getcycles();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0) if (r < 0)

@ -11,9 +11,9 @@ main(void)
char *d = malloc(MAX_BUF + 1); char *d = malloc(MAX_BUF + 1);
int r = read(0, d, MAX_BUF); int r = read(0, d, MAX_BUF);
// unsigned long long st = util_rdtsc(), en = 0; // unsigned long long st = __getcycles(), en = 0;
// wrk(); // wrk();
// en = util_rdtsc(); // en = __getcycles();
// if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1); // if (r <= 0) printf("%llu\n", en > st ? (en - st)/CPU_CYCS : -1);
if (r < 0) if (r < 0)

Loading…
Cancel
Save