1. save the first http session object as a global session without releasing it, reuse it as the following requests' http sessions, this can improve the performance of self workload geneation. 2. print out lock hold time and the longest lock hold time of each worker thread and listener thread

worker_generates_requests_to_global_queue
Xiaosu Lyu 3 years ago
parent 33fecdb247
commit 5ac779f5c4

@ -128,14 +128,23 @@ static inline int
http_session_init_response_body(struct http_session *session)
{
assert(session != NULL);
assert(session->response_body.data == NULL);
assert(session->response_body.size == 0);
assert(session->response_body_written == 0);
int rc = auto_buf_init(&session->response_body);
if (rc < 0) {
auto_buf_deinit(&session->request_buffer);
return -1;
//assert(session->response_body.data == NULL);
//assert(session->response_body.size == 0);
//assert(session->response_body_written == 0);
//int rc = auto_buf_init(&session->response_body);
//if (rc < 0) {
// auto_buf_deinit(&session->request_buffer);
// return -1;
//}
session->response_body.size = 0;
session->response_body_written = 0;
if (session->response_body.data == NULL) {
int rc = auto_buf_init(&session->response_body);
if (rc < 0) {
auto_buf_deinit(&session->request_buffer);
return -1;
}
}
return 0;
@ -169,9 +178,9 @@ http_session_deinit(struct http_session *session)
{
assert(session);
auto_buf_deinit(&session->request_buffer);
auto_buf_deinit(&session->response_header);
auto_buf_deinit(&session->response_body);
//auto_buf_deinit(&session->request_buffer);
//auto_buf_deinit(&session->response_header);
//auto_buf_deinit(&session->response_body);
}
static inline void
@ -179,8 +188,8 @@ http_session_free(struct http_session *session)
{
assert(session);
http_session_deinit(session);
free(session);
//http_session_deinit(session);
//free(session);
}
/**

@ -7,6 +7,9 @@
#include "arch/getcycles.h"
#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 {
@ -78,4 +81,8 @@ 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;
}

@ -77,10 +77,11 @@ current_sandbox_exit()
http_total_increment_request();
/* Allocate http session */
struct http_session *session = http_session_alloc(g_client_socket, (const struct sockaddr *)&g_client_address, tenant, request_arrival_timestamp);
//struct http_session *session = http_session_alloc(g_client_socket, (const struct sockaddr *)&g_client_address, tenant, request_arrival_timestamp);
assert(session != NULL);
http_session_copy(session, g_session);
//assert(session != NULL);
//http_session_copy(session, g_session);
struct http_session *session = g_session;
assert(session->route != NULL);
struct sandbox *sandbox = sandbox_alloc(session->route->module, session, session->route, session->tenant, 1);
if (unlikely(sandbox == NULL)) {

@ -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,9 @@
#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;

@ -148,7 +148,7 @@ sandbox_init(struct sandbox *sandbox, struct module *module, struct http_session
ps_list_init_d(sandbox);
/* Allocate HTTP session structure */
assert(session);
//assert(session);
sandbox->http = session;
sandbox->tenant = tenant;
sandbox->route = route;

@ -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,8 @@
#include "software_interrupt.h"
#include "software_interrupt_counts.h"
extern uint64_t total_held[1024];
extern uint64_t longest_held[1024];
thread_local _Atomic volatile sig_atomic_t handler_depth = 0;
thread_local _Atomic volatile sig_atomic_t deferred_sigalrm = 0;
@ -226,7 +229,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"\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]);
fflush(stdout);
pthread_exit(0);
}

@ -18,6 +18,7 @@
#include "tenant_functions.h"
#include "priority_queue.h"
extern thread_local int thread_id;
/***************************
* Worker Thread State *
**************************/
@ -47,6 +48,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);

Loading…
Cancel
Save