diff --git a/runtime/src/listener_thread.c b/runtime/src/listener_thread.c index 90a7929b..d12c90d8 100644 --- a/runtime/src/listener_thread.c +++ b/runtime/src/listener_thread.c @@ -14,6 +14,8 @@ #include "http_session_perf_log.h" extern thread_local int thread_id; +extern bool first_request_comming; +time_t t_start; extern void http_session_copy(struct http_session *dest, struct http_session *source); /////////////////xiaosu for test////////////////// struct http_session *g_session = NULL; @@ -208,6 +210,11 @@ on_client_request_arrival(int client_socket, const struct sockaddr *client_addre static void on_client_request_receiving(struct http_session *session) { + if (first_request_comming == false){ + t_start = time(NULL); + first_request_comming = true; + } + /* Read HTTP request */ int rc = http_session_receive_request(session, (void_star_cb)listener_thread_register_http_session); if (likely(rc == 0)) { diff --git a/runtime/src/main.c b/runtime/src/main.c index ab8712b6..a0e46be2 100644 --- a/runtime/src/main.c +++ b/runtime/src/main.c @@ -35,7 +35,7 @@ uint32_t runtime_first_worker_processor = 1; 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; +bool first_request_comming = false; thread_local int thread_id = -1; enum RUNTIME_SIGALRM_HANDLER runtime_sigalrm_handler = RUNTIME_SIGALRM_HANDLER_BROADCAST; @@ -69,18 +69,23 @@ runtime_allocate_available_cores() pretty_print_key_value("Core Count (Online)", "%u\n", runtime_total_online_processors); - /* If more than two cores are available, leave core 0 free to run OS tasks */ - if (runtime_total_online_processors > 2) { - runtime_first_worker_processor = 2; - max_possible_workers = runtime_total_online_processors - 2; - } else if (runtime_total_online_processors == 2) { - runtime_first_worker_processor = 1; - max_possible_workers = runtime_total_online_processors - 1; + char* first_core_id = getenv("SLEDGE_FIRST_COREID"); + + if (first_core_id != NULL) { + runtime_first_worker_processor = atoi(first_core_id); } else { - panic("Runtime requires at least two cores!"); + /* If more than two cores are available, leave core 0 free to run OS tasks */ + if (runtime_total_online_processors > 2) { + runtime_first_worker_processor = 2; + max_possible_workers = runtime_total_online_processors - 2; + } else if (runtime_total_online_processors == 2) { + runtime_first_worker_processor = 1; + max_possible_workers = runtime_total_online_processors - 1; + } else { + panic("Runtime requires at least two cores!"); + } } - /* Number of Workers */ char *worker_count_raw = getenv("SLEDGE_NWORKERS"); if (worker_count_raw != NULL) { @@ -520,7 +525,7 @@ main(int argc, char **argv) } runtime_boot_timestamp = __getcycles(); - t_start = time(NULL); + //t_start = time(NULL); for (int tenant_idx = 0; tenant_idx < tenant_config_vec_len; tenant_idx++) { tenant_config_deinit(&tenant_config_vec[tenant_idx]);