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.

worker_generates_requests_to_local_queue
Xiaosu Lyu 3 years ago
parent b2754acc30
commit 96f78698ce

@ -128,16 +128,19 @@ 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);
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 +172,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 +182,8 @@ http_session_free(struct http_session *session)
{
assert(session);
http_session_deinit(session);
free(session);
//http_session_deinit(session);
//free(session);
}
/**

@ -24,7 +24,7 @@
#include "sandbox_set_as_running_user.h"
#include "scheduler_options.h"
extern thread_local bool get_first_request;
/**
* This scheduler provides for cooperative and preemptive multitasking in a OS process's userspace.
*
@ -109,25 +109,27 @@ done:
static inline struct sandbox *
scheduler_edf_get_next()
{
/* 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;
struct sandbox *global = NULL;
uint64_t global_deadline = global_request_scheduler_peek();
/* Try to pull and allocate from the global queue if earlier
* This will be placed at the head of the local runqueue */
if (global_deadline < local_deadline) {
if (global_request_scheduler_remove_if_earlier(&global, local_deadline) == 0) {
assert(global != NULL);
assert(global->absolute_deadline < local_deadline);
sandbox_prepare_execution_environment(global);
assert(global->state == SANDBOX_INITIALIZED);
sandbox_set_as_runnable(global, SANDBOX_INITIALIZED);
//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;
struct sandbox *global = NULL;
uint64_t global_deadline = global_request_scheduler_peek();
/* Try to pull and allocate from the global queue if earlier
* This will be placed at the head of the local runqueue */
if (global_deadline < local_deadline) {
if (global_request_scheduler_remove_if_earlier(&global, local_deadline) == 0) {
assert(global != NULL);
assert(global->absolute_deadline < local_deadline);
sandbox_prepare_execution_environment(global);
assert(global->state == SANDBOX_INITIALIZED);
sandbox_set_as_runnable(global, SANDBOX_INITIALIZED);
get_first_request = true;
}
}
}
//}
/* Return what is at the head of the local runqueue or NULL if empty */
return local_runqueue_get_next();
}

@ -77,10 +77,10 @@ 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);
assert(session != NULL);
http_session_copy(session, g_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 = g_session;
//assert(session != NULL);
//http_session_copy(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)) {

@ -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;

@ -24,10 +24,13 @@
/* 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;
/* Used to index into global arguments and deadlines arrays */
thread_local int worker_thread_idx;
thread_local bool get_first_request = false;
/* Used to track tenants' timeouts */
thread_local struct priority_queue *worker_thread_timeout_queue;
/***********************

Loading…
Cancel
Save