[Places] improve small message performance
This commit is contained in:
parent
718b9709bc
commit
49c73d767b
|
@ -481,7 +481,7 @@ GC2_EXTERN void *GC_finish_message_allocator();
|
|||
|
||||
GC2_EXTERN void GC_adopt_message_allocator(void *msg_memory);
|
||||
/*
|
||||
Adopts the message memory captures by the sending place into
|
||||
Adopts the message memory captured by the sending place into
|
||||
the current receiving place's gc
|
||||
*/
|
||||
|
||||
|
@ -491,6 +491,15 @@ GC2_EXTERN intptr_t GC_is_place();
|
|||
Otherwise returns 0;
|
||||
*/
|
||||
|
||||
GC2_EXTERN uintptr_t GC_message_allocator_size(void *msg_memory);
|
||||
/*
|
||||
Returns the total size of all memory allocated by the message allocator
|
||||
*/
|
||||
|
||||
GC2_EXTERN void GC_dispose_message_allocator(void *msg_memory);
|
||||
/*
|
||||
Disposes of small message allocators that were copied by the receiving place
|
||||
*/
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
|
|
@ -1460,6 +1460,46 @@ void GC_adopt_message_allocator(void *param) {
|
|||
free(msgm);
|
||||
}
|
||||
|
||||
uintptr_t GC_message_allocator_size(void *param) {
|
||||
MsgMemory *msgm = (MsgMemory *) param;
|
||||
if (!msgm) { return sizeof(param); }
|
||||
if (msgm->big_pages && msgm->size < 1024) {
|
||||
printf("error message allocators with big pages should be bigger than %u!\n", msgm->size);
|
||||
exit(1);
|
||||
}
|
||||
return msgm->size;
|
||||
}
|
||||
|
||||
void GC_dispose_message_allocator(void *param) {
|
||||
NewGC *gc = GC_get_GC();
|
||||
mpage *tmp;
|
||||
MsgMemory *msgm = (MsgMemory *) param;
|
||||
|
||||
if (msgm->big_pages)
|
||||
{
|
||||
printf("error disposable message allocators should not have big objects!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (msgm->pages)
|
||||
{
|
||||
tmp = msgm->pages;
|
||||
|
||||
if (tmp->next)
|
||||
{
|
||||
printf("error disposable message allocators should not have more than one page!\n");
|
||||
exit(1);
|
||||
}
|
||||
/* free_pages decrements gc->used_pages which is incorrect, since this is an orphaned page
|
||||
* so we use mmu_free_page directly */
|
||||
mmu_free_page(gc->mmu, tmp->addr, round_to_apage_size(tmp->size), MMU_SMALL_GEN0, MMU_NON_PROTECTABLE, &tmp->mmu_src_block);
|
||||
free_mpage(tmp);
|
||||
}
|
||||
free(msgm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* this function resizes generation 0 to the closest it can get (erring high)
|
||||
to the size we've computed as ideal */
|
||||
inline static void resize_gen0(NewGC *gc, uintptr_t new_size)
|
||||
|
|
|
@ -1256,6 +1256,20 @@ Scheme_Object *scheme_places_serialize(Scheme_Object *so, void **msg_memory) {
|
|||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
Scheme_Object *new_so;
|
||||
Scheme_Object *tmp;
|
||||
|
||||
if (SCHEME_INTP(so)) { return so; }
|
||||
switch (so->type) {
|
||||
case scheme_true_type:
|
||||
case scheme_false_type:
|
||||
case scheme_null_type:
|
||||
case scheme_void_type:
|
||||
/* place_bi_channels are allocated in the master and can be passed along as is */
|
||||
case scheme_place_bi_channel_type:
|
||||
return so;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GC_create_message_allocator();
|
||||
new_so = scheme_places_deep_copy(so);
|
||||
tmp = GC_finish_message_allocator();
|
||||
|
@ -1269,8 +1283,30 @@ Scheme_Object *scheme_places_serialize(Scheme_Object *so, void **msg_memory) {
|
|||
Scheme_Object *scheme_places_deserialize(Scheme_Object *so, void *msg_memory) {
|
||||
#if defined(MZ_USE_PLACES) && defined(MZ_PRECISE_GC)
|
||||
Scheme_Object *new_so;
|
||||
|
||||
if (SCHEME_INTP(so)) { return so; }
|
||||
switch (so->type) {
|
||||
case scheme_true_type:
|
||||
case scheme_false_type:
|
||||
case scheme_null_type:
|
||||
case scheme_void_type:
|
||||
/* place_bi_channels are allocated in the master and can be passed along as is */
|
||||
case scheme_place_bi_channel_type:
|
||||
return so;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (GC_message_allocator_size(msg_memory) < 1024) {
|
||||
new_so = scheme_places_deep_copy(so);
|
||||
GC_dispose_message_allocator(msg_memory);
|
||||
}
|
||||
else {
|
||||
#if !defined(SHARED_TABLES)
|
||||
new_so = scheme_places_deserialize_worker(so);
|
||||
#endif
|
||||
GC_adopt_message_allocator(msg_memory);
|
||||
}
|
||||
return new_so;
|
||||
#else
|
||||
return so;
|
||||
|
|
Loading…
Reference in New Issue
Block a user