reduce calls to current-process-milliseconds on thread swap

Call `current-process-milliseconds` once per swap, instead of twice.
This commit is contained in:
Matthew Flatt 2014-05-12 04:56:10 -06:00
parent 98b91a11e4
commit 1d87c95bf0
2 changed files with 6 additions and 10 deletions

View File

@ -237,6 +237,7 @@ typedef struct Thread_Local_Variables {
struct Scheme_Thread *gc_prep_thread_chain_;
struct Scheme_Thread_Set *scheme_thread_set_top_;
struct Scheme_Current_LWC *scheme_current_lwc_;
intptr_t process_time_at_swap_;
int num_running_threads_;
int swap_no_setjmp_;
int thread_swap_count_;
@ -624,6 +625,7 @@ XFORM_GC_VARIABLE_STACK_THROUGH_THREAD_LOCAL;
#define num_running_threads XOA (scheme_get_thread_local_variables()->num_running_threads_)
#define swap_no_setjmp XOA (scheme_get_thread_local_variables()->swap_no_setjmp_)
#define thread_swap_count XOA (scheme_get_thread_local_variables()->thread_swap_count_)
#define process_time_at_swap XOA (scheme_get_thread_local_variables()->process_time_at_swap_)
#define scheme_did_gc_count XOA (scheme_get_thread_local_variables()->scheme_did_gc_count_)
#define scheme_future_state XOA (scheme_get_thread_local_variables()->scheme_future_state_)
#define scheme_future_thread_state XOA (scheme_get_thread_local_variables()->scheme_future_thread_state_)

View File

@ -175,6 +175,7 @@ THREAD_LOCAL_DECL(static int swap_no_setjmp = 0);
THREAD_LOCAL_DECL(static int thread_swap_count);
THREAD_LOCAL_DECL(int scheme_did_gc_count);
THREAD_LOCAL_DECL(static intptr_t process_time_at_swap);
SHARED_OK static int init_load_on_demand = 1;
@ -2720,11 +2721,7 @@ static void do_swap_thread()
scheme_takeover_stacks(scheme_current_thread);
}
{
intptr_t cpm;
cpm = scheme_get_process_milliseconds();
scheme_current_thread->current_start_process_msec = cpm;
}
scheme_current_thread->current_start_process_msec = process_time_at_swap;
if (scheme_current_thread->return_marks_to) {
stash_current_marks();
@ -2737,6 +2734,7 @@ static void do_swap_thread()
intptr_t cpm;
cpm = scheme_get_process_milliseconds();
scheme_current_thread->accum_process_msec += (cpm - scheme_current_thread->current_start_process_msec);
process_time_at_swap = cpm;
}
swap_target = NULL;
@ -3059,11 +3057,7 @@ static void start_child(Scheme_Thread * volatile child,
}
}
{
intptr_t cpm;
cpm = scheme_get_process_milliseconds();
scheme_current_thread->current_start_process_msec = cpm;
}
scheme_current_thread->current_start_process_msec = process_time_at_swap;
RESETJMP(child);