Remove MasterGC thread, performance increase
svn: r15101
This commit is contained in:
parent
2104900bb6
commit
1dc4a93460
|
@ -403,6 +403,17 @@ GC2_EXTERN void GC_construct_child_gc();
|
|||
Creates a new place specific GC and links to the master GC.
|
||||
*/
|
||||
|
||||
GC2_EXTERN void *GC_switch_to_master_gc();
|
||||
/*
|
||||
Switches to the master GC
|
||||
*/
|
||||
|
||||
GC2_EXTERN void GC_switch_back_from_master(void *gc);
|
||||
/*
|
||||
Switches to back to gc from the master GC
|
||||
*/
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
};
|
||||
# endif
|
||||
|
|
|
@ -1745,10 +1745,45 @@ void GC_switch_out_master_gc() {
|
|||
}
|
||||
}
|
||||
|
||||
/* used to initialize a MasterGC Thread, bad idea
|
||||
* scheme_master_fast_path is more performant */
|
||||
void GC_switch_in_master_gc() {
|
||||
GC_set_GC(MASTERGC);
|
||||
restore_globals_from_gc(MASTERGC);
|
||||
}
|
||||
|
||||
/*used in scheme_master_fast_path*/
|
||||
void *GC_switch_to_master_gc() {
|
||||
NewGC *gc = GC_get_GC();
|
||||
/* return if MASTERGC hasn't been constructed yet, allow recursive locking */
|
||||
if (!MASTERGC || gc == MASTERGC) {
|
||||
return MASTERGC;
|
||||
}
|
||||
save_globals_to_gc(gc);
|
||||
|
||||
/*obtain exclusive access to MASTERGC*/
|
||||
mzrt_rwlock_wrlock(MASTERGCINFO->cangc);
|
||||
|
||||
GC_set_GC(MASTERGC);
|
||||
restore_globals_from_gc(MASTERGC);
|
||||
return gc;
|
||||
}
|
||||
|
||||
void GC_switch_back_from_master(void *gc) {
|
||||
/* return if MASTERGC hasn't been constructed yet, allow recursive locking */
|
||||
if (!MASTERGC || gc == MASTERGC) {
|
||||
return;
|
||||
}
|
||||
save_globals_to_gc(MASTERGC);
|
||||
|
||||
/*release exclusive access to MASTERGC*/
|
||||
mzrt_rwlock_unlock(MASTERGCINFO->cangc);
|
||||
|
||||
GC_set_GC(gc);
|
||||
restore_globals_from_gc(gc);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void GC_gcollect(void)
|
||||
|
|
|
@ -2751,14 +2751,9 @@ Scheme_Object *scheme_intern_resolved_module_path_worker(Scheme_Object *o)
|
|||
Scheme_Object *scheme_intern_resolved_module_path(Scheme_Object *o)
|
||||
{
|
||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
mz_proc_thread *self;
|
||||
self = proc_thread_self;
|
||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
||||
int return_msg_type;
|
||||
void *return_payload;
|
||||
pt_mbox_send_recv(scheme_master_proc_thread->mbox, 1, o, self->mbox, &return_msg_type, &return_payload);
|
||||
return (Scheme_Object*) return_payload;
|
||||
}
|
||||
void *return_payload;
|
||||
return_payload = scheme_master_fast_path(1, o);
|
||||
return (Scheme_Object*) return_payload;
|
||||
#endif
|
||||
return scheme_intern_resolved_module_path_worker(o);
|
||||
}
|
||||
|
|
|
@ -261,19 +261,15 @@ static void *place_start_proc(void *data_arg) {
|
|||
|
||||
Scheme_Object *scheme_places_deep_copy_in_master(Scheme_Object *so) {
|
||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
mz_proc_thread *self;
|
||||
self = proc_thread_self;
|
||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
||||
int return_msg_type;
|
||||
void *return_payload;
|
||||
pt_mbox_send_recv(scheme_master_proc_thread->mbox, 5, so, self->mbox, &return_msg_type, &return_payload);
|
||||
return (Scheme_Object*) return_payload;
|
||||
}
|
||||
void *return_payload;
|
||||
return_payload = scheme_master_fast_path(5, so);
|
||||
return (Scheme_Object*) return_payload;
|
||||
#endif
|
||||
return so;
|
||||
}
|
||||
|
||||
#ifdef MZ_PRECISE_GC
|
||||
static void* scheme_master_place_handlemsg(int msg_type, void *msg_payload);
|
||||
static void *master_scheme_place(void *data) {
|
||||
mz_proc_thread *myself;
|
||||
myself = proc_thread_self;
|
||||
|
@ -284,36 +280,65 @@ static void *master_scheme_place(void *data) {
|
|||
void *recv_payload;
|
||||
pt_mbox *origin;
|
||||
Scheme_Object *o;
|
||||
Scheme_Object *copied_o;
|
||||
|
||||
pt_mbox_recv(myself->mbox, &recv_type, &recv_payload, &origin);
|
||||
switch(recv_type) {
|
||||
case 1:
|
||||
copied_o = scheme_places_deep_copy((Scheme_Object *)recv_payload);
|
||||
o = scheme_intern_resolved_module_path_worker(copied_o);
|
||||
pt_mbox_send(origin, 2, (void *) o, NULL);
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
Scheme_Symbol_Parts *parts;
|
||||
parts = (Scheme_Symbol_Parts *) recv_payload;
|
||||
o = (Scheme_Object *)scheme_intern_exact_symbol_in_table_worker(parts->table, parts->kind, parts->name, parts->len);
|
||||
pt_mbox_send(origin, 4, (void *) o, NULL);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
copied_o = scheme_places_deep_copy((Scheme_Object *)recv_payload);
|
||||
pt_mbox_send(origin, 6, (void *) copied_o, NULL);
|
||||
break;
|
||||
}
|
||||
o = scheme_master_place_handlemsg(recv_type, recv_payload);
|
||||
pt_mbox_send(origin, 2, (void *) o, NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void* scheme_master_place_handlemsg(int msg_type, void *msg_payload)
|
||||
{
|
||||
switch(msg_type) {
|
||||
case 1:
|
||||
{
|
||||
Scheme_Object *o;
|
||||
Scheme_Object *copied_o;
|
||||
copied_o = scheme_places_deep_copy((Scheme_Object *)msg_payload);
|
||||
o = scheme_intern_resolved_module_path_worker(copied_o);
|
||||
return o;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
Scheme_Object *o;
|
||||
Scheme_Symbol_Parts *parts;
|
||||
parts = (Scheme_Symbol_Parts *) msg_payload;
|
||||
o = (Scheme_Object *)scheme_intern_exact_symbol_in_table_worker(parts->table, parts->kind, parts->name, parts->len);
|
||||
return o;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
Scheme_Object *copied_o;
|
||||
copied_o = scheme_places_deep_copy((Scheme_Object *)msg_payload);
|
||||
return copied_o;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* scheme_master_fast_path(int msg_type, void *msg_payload) {
|
||||
Scheme_Object *o;
|
||||
void *original_gc;
|
||||
|
||||
original_gc = GC_switch_to_master_gc();
|
||||
o = scheme_master_place_handlemsg(msg_type, msg_payload);
|
||||
GC_switch_back_from_master(original_gc);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
void spawn_master_scheme_place() {
|
||||
mzrt_proc_first_thread_init();
|
||||
|
||||
scheme_master_proc_thread = mz_proc_thread_create(master_scheme_place, NULL);
|
||||
|
||||
//scheme_master_proc_thread = mz_proc_thread_create(master_scheme_place, NULL);
|
||||
scheme_master_proc_thread = ~0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3180,13 +3180,19 @@ Scheme_Object *scheme_current_library_collection_paths(int argc, Scheme_Object *
|
|||
/* places */
|
||||
/*========================================================================*/
|
||||
|
||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
#if defined(MZ_USE_PLACES)
|
||||
# if defined(MZ_PRECISE_GC)
|
||||
typedef struct Scheme_Symbol_Parts {
|
||||
Scheme_Hash_Table *table;
|
||||
int kind;
|
||||
unsigned int len;
|
||||
const char *name;
|
||||
} Scheme_Symbol_Parts;
|
||||
|
||||
void spawn_master_scheme_place();
|
||||
void *scheme_master_fast_path(int msg_type, void *msg_payload);
|
||||
# endif
|
||||
Scheme_Object *scheme_places_deep_copy(Scheme_Object *so);
|
||||
#endif
|
||||
|
||||
typedef struct Scheme_Place {
|
||||
|
@ -3195,8 +3201,6 @@ typedef struct Scheme_Place {
|
|||
} Scheme_Place;
|
||||
|
||||
Scheme_Env *scheme_place_instance_init();
|
||||
void spawn_master_scheme_place();
|
||||
Scheme_Object *scheme_places_deep_copy(Scheme_Object *so);
|
||||
|
||||
/*========================================================================*/
|
||||
/* engine */
|
||||
|
|
|
@ -396,19 +396,14 @@ Scheme_Object *
|
|||
scheme_intern_exact_symbol_in_table(Scheme_Hash_Table *symbol_table, int kind, const char *name, unsigned int len)
|
||||
{
|
||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
mz_proc_thread *self;
|
||||
self = proc_thread_self;
|
||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
||||
int return_msg_type;
|
||||
void *return_payload;
|
||||
Scheme_Symbol_Parts parts;
|
||||
parts.table = symbol_table;
|
||||
parts.kind = kind;
|
||||
parts.len = len;
|
||||
parts.name = name;
|
||||
pt_mbox_send_recv(scheme_master_proc_thread->mbox, 3, &parts, self->mbox, &return_msg_type, &return_payload);
|
||||
return (Scheme_Object*) return_payload;
|
||||
}
|
||||
void *return_payload;
|
||||
Scheme_Symbol_Parts parts;
|
||||
parts.table = symbol_table;
|
||||
parts.kind = kind;
|
||||
parts.len = len;
|
||||
parts.name = name;
|
||||
return_payload = scheme_master_fast_path(3, &parts);
|
||||
return (Scheme_Object*) return_payload;
|
||||
#endif
|
||||
return scheme_intern_exact_symbol_in_table_worker(symbol_table, kind, name, len);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user