remove atomic variables

remove_atomic_varaibles_for_RR_localqueue
Xiaosu Lyu 3 years ago
parent c12a1f6dcd
commit 8119f438d5

@ -29,7 +29,7 @@ static inline void
http_route_total_increment_request(struct http_route_total *rm) http_route_total_increment_request(struct http_route_total *rm)
{ {
#ifdef HTTP_ROUTE_TOTAL_COUNTERS #ifdef HTTP_ROUTE_TOTAL_COUNTERS
atomic_fetch_add(&rm->total_requests, 1); //atomic_fetch_add(&rm->total_requests, 1);
#endif #endif
} }
@ -37,12 +37,12 @@ static inline void
http_route_total_increment(struct http_route_total *rm, int status_code) http_route_total_increment(struct http_route_total *rm, int status_code)
{ {
#ifdef HTTP_ROUTE_TOTAL_COUNTERS #ifdef HTTP_ROUTE_TOTAL_COUNTERS
if (status_code >= 200 && status_code <= 299) { /*if (status_code >= 200 && status_code <= 299) {
atomic_fetch_add(&rm->total_2XX, 1); atomic_fetch_add(&rm->total_2XX, 1);
} else if (status_code >= 400 && status_code <= 499) { } else if (status_code >= 400 && status_code <= 499) {
atomic_fetch_add(&rm->total_4XX, 1); atomic_fetch_add(&rm->total_4XX, 1);
} else if (status_code >= 500 && status_code <= 599) { } else if (status_code >= 500 && status_code <= 599) {
atomic_fetch_add(&rm->total_5XX, 1); atomic_fetch_add(&rm->total_5XX, 1);
} }*/
#endif #endif
} }

@ -177,7 +177,7 @@ http_session_set_response_header(struct http_session *session, int status_code)
{ {
assert(session != NULL); assert(session != NULL);
assert(status_code >= 200 && status_code <= 599); assert(status_code >= 200 && status_code <= 599);
http_total_increment_response(status_code); //http_total_increment_response(status_code);
/* We might not have actually matched a route */ /* We might not have actually matched a route */
if (likely(session->route != NULL)) { http_route_total_increment(&session->route->metrics, status_code); } if (likely(session->route != NULL)) { http_route_total_increment(&session->route->metrics, status_code); }

@ -60,7 +60,7 @@ static inline void
module_acquire(struct module *module) module_acquire(struct module *module)
{ {
assert(module->reference_count < UINT32_MAX); assert(module->reference_count < UINT32_MAX);
atomic_fetch_add(&module->reference_count, 1); //atomic_fetch_add(&module->reference_count, 1);
return; return;
} }
@ -158,8 +158,8 @@ module_entrypoint(struct module *module)
static inline void static inline void
module_release(struct module *module) module_release(struct module *module)
{ {
assert(module->reference_count > 0); //assert(module->reference_count > 0);
atomic_fetch_sub(&module->reference_count, 1); //atomic_fetch_sub(&module->reference_count, 1);
return; return;
} }

@ -55,6 +55,6 @@ static inline void
sandbox_process_scheduler_updates(struct sandbox *sandbox) sandbox_process_scheduler_updates(struct sandbox *sandbox)
{ {
if (tenant_is_paid(sandbox->tenant)) { if (tenant_is_paid(sandbox->tenant)) {
atomic_fetch_sub(&sandbox->tenant->remaining_budget, sandbox->last_state_duration); //atomic_fetch_sub(&sandbox->tenant->remaining_budget, sandbox->last_state_duration);
} }
} }

@ -48,7 +48,7 @@ static inline void
sandbox_state_totals_increment(sandbox_state_t state) sandbox_state_totals_increment(sandbox_state_t state)
{ {
#ifdef SANDBOX_STATE_TOTALS #ifdef SANDBOX_STATE_TOTALS
atomic_fetch_add(&sandbox_state_totals[state], 1); //atomic_fetch_add(&sandbox_state_totals[state], 1);
#endif #endif
} }
@ -56,7 +56,7 @@ static inline void
sandbox_state_totals_decrement(sandbox_state_t state) sandbox_state_totals_decrement(sandbox_state_t state)
{ {
#ifdef SANDBOX_STATE_TOTALS #ifdef SANDBOX_STATE_TOTALS
if (atomic_load(&sandbox_state_totals[state]) == 0) panic("Underflow of %s\n", sandbox_state_stringify(state)); //if (atomic_load(&sandbox_state_totals[state]) == 0) panic("Underflow of %s\n", sandbox_state_stringify(state));
atomic_fetch_sub(&sandbox_state_totals[state], 1); //atomic_fetch_sub(&sandbox_state_totals[state], 1);
#endif #endif
} }

@ -15,5 +15,6 @@ sandbox_total_initialize()
static inline uint64_t static inline uint64_t
sandbox_total_postfix_increment() sandbox_total_postfix_increment()
{ {
return atomic_fetch_add(&sandbox_total, 1) + 1; //return atomic_fetch_add(&sandbox_total, 1) + 1;
return 1;
} }

@ -56,7 +56,7 @@ static inline void
software_interrupt_counts_deferred_sigalrm_replay_increment() software_interrupt_counts_deferred_sigalrm_replay_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_deferred_sigalrm_replay[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_deferred_sigalrm_replay[worker_thread_idx], 1);
#endif #endif
} }
@ -64,7 +64,7 @@ static inline void
software_interrupt_counts_sigalrm_kernel_increment() software_interrupt_counts_sigalrm_kernel_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_sigalrm_kernel[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_sigalrm_kernel[worker_thread_idx], 1);
#endif #endif
} }
@ -72,7 +72,7 @@ static inline void
software_interrupt_counts_sigalrm_thread_increment() software_interrupt_counts_sigalrm_thread_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_sigalrm_thread[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_sigalrm_thread[worker_thread_idx], 1);
#endif #endif
} }
@ -80,7 +80,7 @@ static inline void
software_interrupt_counts_sigfpe_increment() software_interrupt_counts_sigfpe_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_sigfpe[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_sigfpe[worker_thread_idx], 1);
#endif #endif
} }
@ -88,7 +88,7 @@ static inline void
software_interrupt_counts_sigsegv_increment() software_interrupt_counts_sigsegv_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_sigsegv[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_sigsegv[worker_thread_idx], 1);
#endif #endif
} }
@ -96,7 +96,7 @@ static inline void
software_interrupt_counts_sigusr_increment() software_interrupt_counts_sigusr_increment()
{ {
#ifdef LOG_SOFTWARE_INTERRUPT_COUNTS #ifdef LOG_SOFTWARE_INTERRUPT_COUNTS
atomic_fetch_add(&software_interrupt_counts_sigusr[worker_thread_idx], 1); //atomic_fetch_add(&software_interrupt_counts_sigusr[worker_thread_idx], 1);
#endif #endif
} }

@ -40,7 +40,7 @@ admissions_control_add(uint64_t admissions_estimate)
{ {
#ifdef ADMISSIONS_CONTROL #ifdef ADMISSIONS_CONTROL
assert(admissions_estimate > 0); assert(admissions_estimate > 0);
atomic_fetch_add(&admissions_control_admitted, admissions_estimate); //atomic_fetch_add(&admissions_control_admitted, admissions_estimate);
#ifdef LOG_ADMISSIONS_CONTROL #ifdef LOG_ADMISSIONS_CONTROL
debuglog("Runtime Admitted: %lu / %lu\n", admissions_control_admitted, admissions_control_capacity); debuglog("Runtime Admitted: %lu / %lu\n", admissions_control_admitted, admissions_control_capacity);

@ -141,7 +141,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
/* Signals should not nest */ /* Signals should not nest */
assert(handler_depth == 0); assert(handler_depth == 0);
atomic_fetch_add(&handler_depth, 1); //atomic_fetch_add(&handler_depth, 1);
ucontext_t *interrupted_context = (ucontext_t *)interrupted_context_raw; ucontext_t *interrupted_context = (ucontext_t *)interrupted_context_raw;
struct sandbox *current_sandbox = current_sandbox_get(); struct sandbox *current_sandbox = current_sandbox_get();
@ -175,7 +175,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
global_timeout_queue_process_promotions(); global_timeout_queue_process_promotions();
} }
propagate_sigalrm(signal_info); propagate_sigalrm(signal_info);
atomic_fetch_add(&deferred_sigalrm, 1); //atomic_fetch_add(&deferred_sigalrm, 1);
} }
break; break;
@ -200,7 +200,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
software_interrupt_counts_sigfpe_increment(); software_interrupt_counts_sigfpe_increment();
if (likely(current_sandbox && current_sandbox->state == SANDBOX_RUNNING_USER)) { if (likely(current_sandbox && current_sandbox->state == SANDBOX_RUNNING_USER)) {
atomic_fetch_sub(&handler_depth, 1); //atomic_fetch_sub(&handler_depth, 1);
current_sandbox_trap(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION); current_sandbox_trap(WASM_TRAP_ILLEGAL_ARITHMETIC_OPERATION);
} else { } else {
panic("Runtime SIGFPE\n"); panic("Runtime SIGFPE\n");
@ -212,7 +212,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
software_interrupt_counts_sigsegv_increment(); software_interrupt_counts_sigsegv_increment();
if (likely(current_sandbox && current_sandbox->state == SANDBOX_RUNNING_USER)) { if (likely(current_sandbox && current_sandbox->state == SANDBOX_RUNNING_USER)) {
atomic_fetch_sub(&handler_depth, 1); //atomic_fetch_sub(&handler_depth, 1);
current_sandbox_trap(WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY); current_sandbox_trap(WASM_TRAP_OUT_OF_BOUNDS_LINEAR_MEMORY);
} else { } else {
panic("Runtime SIGSEGV\n"); panic("Runtime SIGSEGV\n");
@ -227,9 +227,10 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
/* calculate the throughput */ /* calculate the throughput */
time_t t_end = time(NULL); time_t t_end = time(NULL);
double seconds = difftime(t_end, t_start); double seconds = difftime(t_end, t_start);
double throughput = atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]) / seconds; //double throughput = atomic_load(&sandbox_state_totals[SANDBOX_COMPLETE]) / seconds;
double throughput = total_local_requests / seconds;
uint32_t total_sandboxes_error = atomic_load(&sandbox_state_totals[SANDBOX_ERROR]); uint32_t total_sandboxes_error = atomic_load(&sandbox_state_totals[SANDBOX_ERROR]);
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", 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]); 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); fflush(stdout);
pthread_exit(0); pthread_exit(0);
@ -251,7 +252,7 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void
} }
} }
atomic_fetch_sub(&handler_depth, 1); //atomic_fetch_sub(&handler_depth, 1);
return; return;
} }

Loading…
Cancel
Save