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.
|
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
|
# ifdef __cplusplus
|
||||||
};
|
};
|
||||||
# endif
|
# 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() {
|
void GC_switch_in_master_gc() {
|
||||||
GC_set_GC(MASTERGC);
|
GC_set_GC(MASTERGC);
|
||||||
restore_globals_from_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
|
#endif
|
||||||
|
|
||||||
void GC_gcollect(void)
|
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)
|
Scheme_Object *scheme_intern_resolved_module_path(Scheme_Object *o)
|
||||||
{
|
{
|
||||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||||
mz_proc_thread *self;
|
void *return_payload;
|
||||||
self = proc_thread_self;
|
return_payload = scheme_master_fast_path(1, o);
|
||||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
return (Scheme_Object*) return_payload;
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return scheme_intern_resolved_module_path_worker(o);
|
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) {
|
Scheme_Object *scheme_places_deep_copy_in_master(Scheme_Object *so) {
|
||||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||||
mz_proc_thread *self;
|
void *return_payload;
|
||||||
self = proc_thread_self;
|
return_payload = scheme_master_fast_path(5, so);
|
||||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
return (Scheme_Object*) return_payload;
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return so;
|
return so;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MZ_PRECISE_GC
|
#ifdef MZ_PRECISE_GC
|
||||||
|
static void* scheme_master_place_handlemsg(int msg_type, void *msg_payload);
|
||||||
static void *master_scheme_place(void *data) {
|
static void *master_scheme_place(void *data) {
|
||||||
mz_proc_thread *myself;
|
mz_proc_thread *myself;
|
||||||
myself = proc_thread_self;
|
myself = proc_thread_self;
|
||||||
|
@ -284,36 +280,65 @@ static void *master_scheme_place(void *data) {
|
||||||
void *recv_payload;
|
void *recv_payload;
|
||||||
pt_mbox *origin;
|
pt_mbox *origin;
|
||||||
Scheme_Object *o;
|
Scheme_Object *o;
|
||||||
Scheme_Object *copied_o;
|
|
||||||
|
|
||||||
pt_mbox_recv(myself->mbox, &recv_type, &recv_payload, &origin);
|
pt_mbox_recv(myself->mbox, &recv_type, &recv_payload, &origin);
|
||||||
switch(recv_type) {
|
o = scheme_master_place_handlemsg(recv_type, recv_payload);
|
||||||
case 1:
|
pt_mbox_send(origin, 2, (void *) o, NULL);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 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() {
|
void spawn_master_scheme_place() {
|
||||||
mzrt_proc_first_thread_init();
|
mzrt_proc_first_thread_init();
|
||||||
|
|
||||||
|
|
||||||
|
//scheme_master_proc_thread = mz_proc_thread_create(master_scheme_place, NULL);
|
||||||
|
scheme_master_proc_thread = ~0;
|
||||||
|
|
||||||
scheme_master_proc_thread = mz_proc_thread_create(master_scheme_place, NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3180,13 +3180,19 @@ Scheme_Object *scheme_current_library_collection_paths(int argc, Scheme_Object *
|
||||||
/* places */
|
/* 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 {
|
typedef struct Scheme_Symbol_Parts {
|
||||||
Scheme_Hash_Table *table;
|
Scheme_Hash_Table *table;
|
||||||
int kind;
|
int kind;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
const char *name;
|
const char *name;
|
||||||
} Scheme_Symbol_Parts;
|
} 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
|
#endif
|
||||||
|
|
||||||
typedef struct Scheme_Place {
|
typedef struct Scheme_Place {
|
||||||
|
@ -3195,8 +3201,6 @@ typedef struct Scheme_Place {
|
||||||
} Scheme_Place;
|
} Scheme_Place;
|
||||||
|
|
||||||
Scheme_Env *scheme_place_instance_init();
|
Scheme_Env *scheme_place_instance_init();
|
||||||
void spawn_master_scheme_place();
|
|
||||||
Scheme_Object *scheme_places_deep_copy(Scheme_Object *so);
|
|
||||||
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
/* engine */
|
/* 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)
|
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)
|
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||||
mz_proc_thread *self;
|
void *return_payload;
|
||||||
self = proc_thread_self;
|
Scheme_Symbol_Parts parts;
|
||||||
if ( scheme_master_proc_thread && scheme_master_proc_thread != proc_thread_self ) {
|
parts.table = symbol_table;
|
||||||
int return_msg_type;
|
parts.kind = kind;
|
||||||
void *return_payload;
|
parts.len = len;
|
||||||
Scheme_Symbol_Parts parts;
|
parts.name = name;
|
||||||
parts.table = symbol_table;
|
return_payload = scheme_master_fast_path(3, &parts);
|
||||||
parts.kind = kind;
|
return (Scheme_Object*) return_payload;
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return scheme_intern_exact_symbol_in_table_worker(symbol_table, kind, name, len);
|
return scheme_intern_exact_symbol_in_table_worker(symbol_table, kind, name, len);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user