1. add lock held time for each worker thread and listener thread. 2. print out total requests of each worker

worker_generates_requests_to_local_queue
Xiaosu Lyu 3 years ago
parent 96f78698ce
commit da8dbc4032

@ -8,6 +8,10 @@
#include "runtime.h"
extern uint64_t total_held[1024];
extern uint64_t longest_held[1024];
extern thread_local int thread_id;
/* A linked list of nodes */
struct lock_wrapper {
uint64_t longest_held;
@ -78,4 +82,9 @@ lock_unlock(lock_t *self, lock_node_t *node)
node->time_locked = 0;
if (unlikely(duration > self->longest_held)) { self->longest_held = duration; }
self->total_held += duration;
if (unlikely(duration > longest_held[thread_id])) {
longest_held[thread_id] = duration;
}
total_held[thread_id] += duration;
}

@ -109,7 +109,7 @@ done:
static inline struct sandbox *
scheduler_edf_get_next()
{
//if (get_first_request == false) {
if (get_first_request == false) {
/* Get the deadline of the sandbox at the head of the local queue */
struct sandbox *local = local_runqueue_get_next();
uint64_t local_deadline = local == NULL ? UINT64_MAX : local->absolute_deadline;
@ -129,7 +129,7 @@ scheduler_edf_get_next()
get_first_request = true;
}
}
//}
}
/* Return what is at the head of the local runqueue or NULL if empty */
return local_runqueue_get_next();
}

@ -3,6 +3,7 @@
#include "global_request_scheduler.h"
#include "panic.h"
uint32_t total_global_requests = 0;
/* Default uninitialized implementations of the polymorphic interface */
noreturn static struct sandbox *
uninitialized_add(struct sandbox *arg)
@ -49,6 +50,7 @@ struct sandbox *
global_request_scheduler_add(struct sandbox *sandbox)
{
assert(sandbox != NULL);
total_global_requests++;
return global_request_scheduler.add_fn(sandbox);
}

@ -13,6 +13,7 @@
#include "tenant_functions.h"
#include "http_session_perf_log.h"
extern thread_local int thread_id;
extern void http_session_copy(struct http_session *dest, struct http_session *source);
/////////////////xiaosu for test//////////////////
struct http_session *g_session = NULL;
@ -427,6 +428,7 @@ on_client_socket_epoll_event(struct epoll_event *evt)
noreturn void *
listener_thread_main(void *dummy)
{
thread_id = 200;
struct epoll_event epoll_events[RUNTIME_MAX_EPOLL_EVENTS];
metrics_server_init();

@ -12,6 +12,10 @@
#include "sandbox_functions.h"
#include "runtime.h"
extern thread_local int thread_id;
uint64_t total_held[1024] = {0};
uint64_t longest_held[1024] = {0};
thread_local static struct priority_queue *local_runqueue_minheap;
/**

@ -36,6 +36,7 @@ uint32_t runtime_processor_speed_MHz = 0;
uint32_t runtime_total_online_processors = 0;
uint32_t runtime_worker_threads_count = 0;
time_t t_start;
thread_local int thread_id = -1;
enum RUNTIME_SIGALRM_HANDLER runtime_sigalrm_handler = RUNTIME_SIGALRM_HANDLER_BROADCAST;

@ -9,6 +9,7 @@
#include <threads.h>
#include <unistd.h>
#include <ucontext.h>
#include <inttypes.h>
#include "arch/context.h"
#include "current_sandbox.h"
@ -25,6 +26,11 @@
#include "software_interrupt.h"
#include "software_interrupt_counts.h"
extern uint64_t total_held[1024];
extern uint64_t longest_held[1024];
extern uint32_t total_global_requests;
thread_local _Atomic volatile sig_atomic_t handler_depth = 0;
thread_local _Atomic volatile sig_atomic_t deferred_sigalrm = 0;
@ -226,7 +232,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
double seconds = difftime(t_end, t_start);
double throughput = atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]) / seconds;
uint32_t total_sandboxes_error = atomic_load(&sandbox_state_totals[SANDBOX_ERROR]);
printf("throughput is %f, error request is %u global total request %d time is %f worker %d total requests is %u\n", throughput, total_sandboxes_error, atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]), seconds, worker_thread_idx, total_local_requests);
printf("throughput is %f, error request is %u global total request %d worker %d total requests is %u worker total_held %"PRIu64" longest_held %"PRIu64" listener total_held %"PRIu64" longest_held %"PRIu64" total gr %u\n", throughput, total_sandboxes_error, atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]), worker_thread_idx, total_local_requests, total_held[worker_thread_idx], longest_held[worker_thread_idx], total_held[200], longest_held[200], total_global_requests);
fflush(stdout);
pthread_exit(0);
}

@ -22,6 +22,7 @@
* Worker Thread State *
**************************/
extern thread_local int thread_id;
/* context of the runtime thread before running sandboxes or to resume its "main". */
thread_local struct arch_context worker_thread_base_context;
//thread_local bool get_first_request = false;
@ -51,6 +52,7 @@ worker_thread_main(void *argument)
/* Index was passed via argument */
worker_thread_idx = *(int *)argument;
thread_id = worker_thread_idx;
/* Set my priority */
// runtime_set_pthread_prio(pthread_self(), 2);
pthread_setschedprio(pthread_self(), -20);

Loading…
Cancel
Save