Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: master
...
compare: gc_ms2_sf
Checking mergeability… Don't worry, you can still create the pull request.
  • 8 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Oct 30, 2010
@chromatic chromatic Experimenting with sweep-free GC MS2
git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49734 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
2493ae6
@chromatic chromatic [GC] Tidied and headerized; no functional changes.
git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49735 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
e2d170b
@chromatic chromatic [GC] Added GC list for constant PMCs.
Because constant PMCs only get swept away during global destruction, they don't
need to be swept at all--on creation, they get stored in a constant-specific
list for safekeeping.

git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49736 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
78bd0fe
@chromatic chromatic [GC] Added GC list for constant STRINGs.
git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49737 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
6d103db
@chromatic chromatic [GC] Removed constant PMCs from memory statistics.
Because constant PMC memory is unreclaimable, there's little point in running
the GC to attempt to free this memory.  This should improve GC throughput
somewhat.

git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49738 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
c44a54b
@chromatic chromatic [GC] Removed constant STRINGs from memory stats.
git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49739 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
da47f8b
@chromatic chromatic [GC] Skip system stack tracing of constant GCables.
As they're already on the right list, they don't need marking from the
imprecise marker.

git-svn-id: https://svn.parrot.org/parrot/branches/gc_ms2_sf@49740 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
7245c69
Commits on Nov 17, 2010
@bacek bacek Merge branch 'gc_ms2_faster_list' into gc_ms2_sf
Conflicts:
	src/gc/gc_ms2.c
8407c2b
Showing with 76 additions and 42 deletions.
  1. +76 −42 src/gc/gc_ms2.c
View
118 src/gc/gc_ms2.c
@@ -45,14 +45,20 @@ alloc, and phase of the Moon. */
typedef struct MarkSweep_GC {
/* Allocator for PMC headers */
struct Pool_Allocator *pmc_allocator;
+
/* Currently allocate objects */
struct Parrot_Pointer_Array *objects;
+
+ /* Currently allocated constant objects */
+ struct Parrot_Pointer_Array *constants;
+
/* During M&S gather new live objects in this list */
struct Parrot_Pointer_Array *new_objects;
/* Allocator for strings */
struct Pool_Allocator *string_allocator;
struct Parrot_Pointer_Array *strings;
+ struct Parrot_Pointer_Array *constant_strings;
/* Fixed-size allocator */
struct Fixed_Allocator *fixed_size_allocator;
@@ -60,16 +66,18 @@ typedef struct MarkSweep_GC {
/* String GC */
struct String_GC string_gc;
- /* Number of allocated objects before trigger gc */
+ /* Number of allocated objects before triggering gc */
size_t gc_threshold;
/* GC blocking */
- UINTVAL gc_mark_block_level; /* How many outstanding GC block
- requests are there? */
- UINTVAL gc_sweep_block_level; /* How many outstanding GC block
- requests are there? */
+ /* number of outstanding mark block requests */
+ UINTVAL gc_mark_block_level;
- UINTVAL num_early_gc_PMCs; /* how many PMCs want immediate destruction */
+ /* number of outstanding sweep block requests */
+ UINTVAL gc_sweep_block_level;
+
+ /* how many PMCs want immediate destruction */
+ UINTVAL num_early_gc_PMCs;
} MarkSweep_GC;
@@ -86,7 +94,7 @@ static void failed_allocation(unsigned int line, unsigned long size);
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static Buffer* gc_ms2_allocate_buffer_header(PARROT_INTERP,
+static Buffer * gc_ms2_allocate_buffer_header(PARROT_INTERP,
SHIM(size_t size))
__attribute__nonnull__(1);
@@ -97,7 +105,7 @@ static void gc_ms2_allocate_buffer_storage(PARROT_INTERP,
__attribute__nonnull__(2);
PARROT_CAN_RETURN_NULL
-static void* gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
+static void * gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
__attribute__nonnull__(1);
PARROT_MALLOC
@@ -110,20 +118,20 @@ static void * gc_ms2_allocate_memory_chunk_zeroed(SHIM_INTERP, size_t size);
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static void* gc_ms2_allocate_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
+static void * gc_ms2_allocate_pmc_attributes(PARROT_INTERP,
+ ARGMOD(PMC *pmc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*pmc);
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static PMC* gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
+static PMC * gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
__attribute__nonnull__(1);
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static STRING* gc_ms2_allocate_string_header(PARROT_INTERP,
- SHIM(UINTVAL flags))
+static STRING * gc_ms2_allocate_string_header(PARROT_INTERP, UINTVAL flags)
__attribute__nonnull__(1);
static void gc_ms2_allocate_string_storage(PARROT_INTERP,
@@ -418,16 +426,16 @@ gc_ms2_compact_memory_pool(PARROT_INTERP)
/*
-=item C<static PMC* gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)>
+=item C<static PMC * gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)>
=item C<static void gc_ms2_free_pmc_header(PARROT_INTERP, PMC *pmc)>
-=item C<static STRING* gc_ms2_allocate_string_header(PARROT_INTERP, UINTVAL
+=item C<static STRING * gc_ms2_allocate_string_header(PARROT_INTERP, UINTVAL
flags)>
=item C<static void gc_ms2_free_string_header(PARROT_INTERP, STRING *s)>
-=item C<static void* gc_ms2_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
+=item C<static void * gc_ms2_allocate_pmc_attributes(PARROT_INTERP, PMC *pmc)>
=item C<static void gc_ms2_free_pmc_attributes(PARROT_INTERP, PMC *pmc)>
@@ -443,7 +451,7 @@ size_t size)>
=item C<static void gc_ms2_reallocate_buffer_storage(PARROT_INTERP, Buffer *str,
size_t size)>
-=item C<static void* gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t
+=item C<static void * gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t
size)>
=item C<static void gc_ms2_free_fixed_size_storage(PARROT_INTERP, size_t size,
@@ -456,7 +464,7 @@ Functions for allocating/deallocating various objects.
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static void*
+static void *
gc_ms2_allocate_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
{
ASSERT_ARGS(gc_ms2_allocate_pmc_attributes)
@@ -489,7 +497,7 @@ gc_ms2_free_pmc_attributes(PARROT_INTERP, ARGMOD(PMC *pmc))
PARROT_CAN_RETURN_NULL
-static void*
+static void *
gc_ms2_allocate_fixed_size_storage(PARROT_INTERP, size_t size)
{
ASSERT_ARGS(gc_ms2_allocate_fixed_size_storage)
@@ -529,6 +537,7 @@ gets stats based on enum which
=cut
*/
+
static size_t
gc_ms2_get_gc_info(PARROT_INTERP, Interpinfo_enum which)
{
@@ -561,7 +570,7 @@ void
Parrot_gc_ms2_init(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_ms2_init)
- struct MarkSweep_GC *self;
+ MarkSweep_GC *self;
/* We have to transfer ownership of memory to parent interp
* in threaded parrot */
@@ -625,18 +634,20 @@ Parrot_gc_ms2_init(PARROT_INTERP)
if (interp->parent_interpreter && interp->parent_interpreter->gc_sys) {
/* This is a "child" interpreter. Just reuse parent one */
- self = (MarkSweep_GC*)interp->parent_interpreter->gc_sys->gc_private;
+ self = (MarkSweep_GC *)interp->parent_interpreter->gc_sys->gc_private;
}
else {
self = mem_allocate_zeroed_typed(MarkSweep_GC);
self->pmc_allocator = Parrot_gc_pool_new(interp,
sizeof (pmc_alloc_struct));
- self->objects = Parrot_pa_new(interp);
+ self->objects = Parrot_pa_new(interp);
+ self->constants = Parrot_pa_new(interp);
self->string_allocator = Parrot_gc_pool_new(interp,
sizeof (string_alloc_struct));
- self->strings = Parrot_pa_new(interp);
+ self->strings = Parrot_pa_new(interp);
+ self->constant_strings = Parrot_pa_new(interp);
self->fixed_size_allocator = Parrot_gc_fixed_allocator_new(interp);
@@ -669,7 +680,9 @@ gc_ms2_finalize(PARROT_INTERP)
Parrot_gc_str_finalize(interp, &self->string_gc);
Parrot_pa_destroy(interp, self->objects);
+ Parrot_pa_destroy(interp, self->constants);
Parrot_pa_destroy(interp, self->strings);
+ Parrot_pa_destroy(interp, self->constant_strings);
Parrot_gc_pool_destroy(interp, self->pmc_allocator);
Parrot_gc_pool_destroy(interp, self->string_allocator);
Parrot_gc_fixed_allocator_destroy(interp, self->fixed_size_allocator);
@@ -683,7 +696,7 @@ gc_ms2_finalize(PARROT_INTERP)
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static PMC*
+static PMC *
gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
{
ASSERT_ARGS(gc_ms2_allocate_pmc_header)
@@ -695,12 +708,17 @@ gc_ms2_allocate_pmc_header(PARROT_INTERP, UINTVAL flags)
/* Increase used memory. Not precisely accurate due Pool_Allocator paging */
++interp->gc_sys->stats.header_allocs_since_last_collect;
-
- interp->gc_sys->stats.memory_allocated += sizeof (PMC);
- interp->gc_sys->stats.mem_used_last_collect += sizeof (PMC);
-
ptr = (pmc_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- ptr->ptr = Parrot_pa_insert(interp, self->objects, ptr);
+
+ if (flags & PObj_constant_FLAG) {
+ ptr->ptr = Parrot_pa_insert(interp, self->constants, ptr);
+ }
+ else {
+ /* only reclaimable PMCs count toward memory limits */
+ ptr->ptr = Parrot_pa_insert(interp, self->objects, ptr);
+ interp->gc_sys->stats.memory_allocated += sizeof (PMC);
+ interp->gc_sys->stats.mem_used_last_collect += sizeof (PMC);
+ }
return &ptr->pmc;
}
@@ -715,7 +733,10 @@ gc_ms2_free_pmc_header(PARROT_INTERP, ARGFREE(PMC *pmc))
if (pmc) {
if (PObj_on_free_list_TEST(pmc))
return;
- Parrot_pa_remove(interp, self->objects, PMC2PAC(pmc)->ptr);
+ if (PObj_constant_TEST(pmc))
+ Parrot_pa_remove(interp, self->constants, PMC2PAC(pmc)->ptr);
+ else
+ Parrot_pa_remove(interp, self->objects, PMC2PAC(pmc)->ptr);
PObj_on_free_list_SET(pmc);
Parrot_pmc_destroy(interp, pmc);
@@ -733,7 +754,7 @@ gc_ms2_free_pmc_header(PARROT_INTERP, ARGFREE(PMC *pmc))
=item C<static void gc_ms2_mark_pmc_header(PARROT_INTERP, PMC *pmc)>
-mark as grey
+Mark PMC as grey
=cut
@@ -753,9 +774,9 @@ gc_ms2_mark_pmc_header(PARROT_INTERP, ARGIN(PMC *pmc))
/* mark it live */
PObj_live_SET(pmc);
+ /* there should be no constant PMCs to move here */
Parrot_pa_remove(interp, self->objects, item->ptr);
item->ptr = Parrot_pa_insert(interp, self->new_objects, item);
-
}
@@ -783,7 +804,7 @@ gc_ms2_is_pmc_ptr(PARROT_INTERP, ARGIN_NULLOK(void *ptr))
=item C<gc_ms2_free_string_header()>
-=item C<static Buffer* gc_ms2_allocate_buffer_header(PARROT_INTERP, size_t
+=item C<static Buffer * gc_ms2_allocate_buffer_header(PARROT_INTERP, size_t
size)>
=item C<static void gc_ms2_free_buffer_header(PARROT_INTERP, Buffer *s, size_t
@@ -795,8 +816,8 @@ Allocate/free string/buffer headers.
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static STRING*
-gc_ms2_allocate_string_header(PARROT_INTERP, SHIM(UINTVAL flags))
+static STRING *
+gc_ms2_allocate_string_header(PARROT_INTERP, UINTVAL flags)
{
ASSERT_ARGS(gc_ms2_allocate_string_header)
MarkSweep_GC *self = (MarkSweep_GC *)interp->gc_sys->gc_private;
@@ -808,11 +829,18 @@ gc_ms2_allocate_string_header(PARROT_INTERP, SHIM(UINTVAL flags))
/* Increase used memory. Not precisely accurate due Pool_Allocator paging */
++interp->gc_sys->stats.header_allocs_since_last_collect;
- interp->gc_sys->stats.memory_allocated += sizeof (STRING);
- interp->gc_sys->stats.mem_used_last_collect += sizeof (STRING);
ptr = (string_alloc_struct *)Parrot_gc_pool_allocate(interp, pool);
- ptr->ptr = Parrot_pa_insert(interp, self->strings, ptr);
+
+ if (flags & PObj_constant_FLAG) {
+ ptr->ptr = Parrot_pa_insert(interp, self->constant_strings, ptr);
+ }
+ else {
+ /* only reclaimable STRINGs count toward memory limits */
+ ptr->ptr = Parrot_pa_insert(interp, self->strings, ptr);
+ interp->gc_sys->stats.memory_allocated += sizeof (STRING);
+ interp->gc_sys->stats.mem_used_last_collect += sizeof (STRING);
+ }
ret = &ptr->str;
memset(ret, 0, sizeof (STRING));
@@ -848,7 +876,7 @@ gc_ms2_free_string_header(PARROT_INTERP, ARGFREE(STRING *s))
PARROT_MALLOC
PARROT_CAN_RETURN_NULL
-static Buffer*
+static Buffer *
gc_ms2_allocate_buffer_header(PARROT_INTERP, SHIM(size_t size))
{
ASSERT_ARGS(gc_ms2_allocate_buffer_header)
@@ -860,7 +888,7 @@ static void
gc_ms2_free_buffer_header(PARROT_INTERP, ARGFREE(Buffer *s), SHIM(size_t size))
{
ASSERT_ARGS(gc_ms2_free_buffer_header)
- gc_ms2_free_string_header(interp, (STRING*)s);
+ gc_ms2_free_string_header(interp, (STRING *)s);
}
@@ -1080,8 +1108,11 @@ gc_ms2_mark_and_sweep(PARROT_INTERP, UINTVAL flags)
/* destroy the rest */
if (flags & GC_finish_FLAG) {
- gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->objects);
gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->new_objects);
+ gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->objects);
+ gc_ms2_destroy_pmc_pool(interp, self->pmc_allocator, self->constants);
+ gc_ms2_sweep_string_pool(interp, self->string_allocator,
+ self->constant_strings);
}
/* Replace objects with new_objects. Ignoring "constant" one */
@@ -1127,7 +1158,7 @@ gc_ms2_sweep_pmc_pool(PARROT_INTERP,
if (PObj_live_TEST(pmc))
PObj_live_CLEAR(pmc);
- else if (!PObj_constant_TEST(pmc)) {
+ else {
Parrot_pa_remove(interp, list, PMC2PAC(pmc)->ptr);
Parrot_pmc_destroy(interp, pmc);
@@ -1195,7 +1226,7 @@ gc_ms2_sweep_string_pool(PARROT_INTERP,
if (PObj_live_TEST(obj))
PObj_live_CLEAR(obj);
- else if (!PObj_constant_TEST(obj)) {
+ else {
Parrot_pa_remove(interp, list, STR2PAC(obj)->ptr);
if (Buffer_bufstart(obj) && !PObj_external_TEST(obj))
Parrot_gc_str_free_buffer_storage(interp, &self->string_gc, obj);
@@ -1237,6 +1268,9 @@ gc_ms2_is_ptr_owned(PARROT_INTERP, ARGIN_NULLOK(void *ptr),
if (PObj_is_live_or_free_TESTALL(obj))
return 0;
+ if (PObj_constant_TEST(obj))
+ return 0;
+
return 1;
}

No commit comments for this range

Something went wrong with that request. Please try again.