Browse Source

mark-and-sweep tuning: make trigger count relative to heap size (combined object and string count); change trigger limit parameter and mark-and-sweep recursion depth parameter to fixed constants, as they don't really need to be tunable

pull/1/head
Sami Vaarala 11 years ago
parent
commit
995128215e
  1. 18
      bugs/issue-4c9153eb78579571c5dbad69023ccaede8448e1e.yaml
  2. 22
      bugs/issue-7a87b6453bf151dbc74bc50a2120a9dd2cff215a.yaml
  3. 23
      bugs/issue-8d7eb5e77b10907194dd621e37773b38706eef83.yaml
  4. 18
      bugs/issue-98c9d9f9fc3b25f59c667fcbb3b4ab3c44b0757c.yaml
  5. 18
      bugs/issue-b7340bb790ed608750ce50826956b4c32841906c.yaml
  6. 18
      bugs/issue-e79a3faf60b63a12bc1c6b85fe857e8da980a81d.yaml
  7. 49
      src/duk_heap_markandsweep.c

18
bugs/issue-4c9153eb78579571c5dbad69023ccaede8448e1e.yaml

@ -0,0 +1,18 @@
--- !ditz.rubyforge.org,2008-03-06/issue
title: test compatibility with uglifyjs
desc: ""
type: :task
component: duk
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :unstarted
disposition:
creation_time: 2014-01-15 18:22:48.749538 Z
references: []
id: 4c9153eb78579571c5dbad69023ccaede8448e1e
log_events:
- - 2014-01-15 18:22:48.989556 Z
- sva <sami.vaarala@iki.fi>
- created
- ""

22
bugs/issue-7a87b6453bf151dbc74bc50a2120a9dd2cff215a.yaml

@ -0,0 +1,22 @@
--- !ditz.rubyforge.org,2008-03-06/issue
title: make mark-and-sweep recursion limit a fixed one (it's not in duk_heap.h)?
desc: ""
type: :task
component: duk
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :closed
disposition: :fixed
creation_time: 2014-01-15 20:39:07.522984 Z
references: []
id: 7a87b6453bf151dbc74bc50a2120a9dd2cff215a
log_events:
- - 2014-01-15 20:39:07.690937 Z
- sva <sami.vaarala@iki.fi>
- created
- ""
- - 2014-01-15 20:54:37.822360 Z
- sva <sami.vaarala@iki.fi>
- closed with disposition fixed
- ""

23
bugs/issue-8d7eb5e77b10907194dd621e37773b38706eef83.yaml

@ -3,10 +3,10 @@ title: garbage collection performance tuning
desc: ""
type: :task
component: duk
release: v0.10
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :unstarted
disposition:
status: :closed
disposition: :fixed
creation_time: 2013-12-10 23:56:41.037963 Z
references: []
@ -16,3 +16,20 @@ log_events:
- sva <sami.vaarala@iki.fi>
- created
- ""
- - 2014-01-15 20:27:59.519529 Z
- sva <sami.vaarala@iki.fi>
- commented
- |-
Garbage collection period should be relative to current heap object count and string count,
or perhaps a byte size estimate of these. When reference counting is disabled, the interval
computed from these must be much smaller. Since the trigger counter is decremented on each
allocation, object relative (rather than byte relative) trigger count is probably the most
appropriate.
- - 2014-01-15 20:54:50.806188 Z
- sva <sami.vaarala@iki.fi>
- assigned to release v0.9 from v0.10
- ""
- - 2014-01-15 20:54:55.062145 Z
- sva <sami.vaarala@iki.fi>
- closed with disposition fixed
- ""

18
bugs/issue-98c9d9f9fc3b25f59c667fcbb3b4ab3c44b0757c.yaml

@ -0,0 +1,18 @@
--- !ditz.rubyforge.org,2008-03-06/issue
title: add underscore test cases (whatever is applicable)
desc: ""
type: :task
component: duk
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :unstarted
disposition:
creation_time: 2014-01-15 10:18:48.987548 Z
references: []
id: 98c9d9f9fc3b25f59c667fcbb3b4ab3c44b0757c
log_events:
- - 2014-01-15 10:18:49.163500 Z
- sva <sami.vaarala@iki.fi>
- created
- ""

18
bugs/issue-b7340bb790ed608750ce50826956b4c32841906c.yaml

@ -0,0 +1,18 @@
--- !ditz.rubyforge.org,2008-03-06/issue
title: add a packed string to be evaluated in thread init to allow pure lua built-ins
desc: ""
type: :task
component: duk
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :unstarted
disposition:
creation_time: 2014-01-15 18:12:58.065154 Z
references: []
id: b7340bb790ed608750ce50826956b4c32841906c
log_events:
- - 2014-01-15 18:12:58.225114 Z
- sva <sami.vaarala@iki.fi>
- created
- ""

18
bugs/issue-e79a3faf60b63a12bc1c6b85fe857e8da980a81d.yaml

@ -0,0 +1,18 @@
--- !ditz.rubyforge.org,2008-03-06/issue
title: make Duktape.env non-enumerable to match other props
desc: ""
type: :task
component: duk
release: v0.9
reporter: sva <sami.vaarala@iki.fi>
status: :unstarted
disposition:
creation_time: 2014-01-15 18:32:58.313878 Z
references: []
id: e79a3faf60b63a12bc1c6b85fe857e8da980a81d
log_events:
- - 2014-01-15 18:32:58.489676 Z
- sva <sami.vaarala@iki.fi>
- created
- ""

49
src/duk_heap_markandsweep.c

@ -142,7 +142,7 @@ static void mark_heaphdr(duk_heap *heap, duk_heaphdr *h) {
}
DUK_HEAPHDR_SET_REACHABLE(h);
if (heap->mark_and_sweep_recursion_depth >= heap->mark_and_sweep_recursion_limit) {
if (heap->mark_and_sweep_recursion_depth >= DUK_HEAP_MARK_AND_SWEEP_RECURSION_LIMIT) {
/* log this with a normal debug level because this should be relatively rare */
DUK_DPRINT("mark-and-sweep recursion limit reached, marking as temproot: %p", (void *) h);
DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap);
@ -441,13 +441,13 @@ static void clear_refzero_list_flags(duk_heap *heap) {
* Sweep stringtable
*/
static void sweep_stringtable(duk_heap *heap) {
static void sweep_stringtable(duk_heap *heap, duk_size_t *out_count_keep) {
duk_hstring *h;
int i;
#ifdef DUK_USE_DEBUG
int count_free = 0;
int count_keep = 0;
duk_size_t count_free = 0;
#endif
duk_size_t count_keep = 0;
DUK_DDPRINT("sweep_stringtable: %p", (void *) heap);
@ -457,9 +457,7 @@ static void sweep_stringtable(duk_heap *heap) {
continue;
} else if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) {
DUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h);
#ifdef DUK_USE_DEBUG
count_keep++;
#endif
continue;
}
@ -496,24 +494,26 @@ static void sweep_stringtable(duk_heap *heap) {
}
#ifdef DUK_USE_DEBUG
DUK_DPRINT("mark-and-sweep sweep stringtable: %d freed, %d kept", count_free, count_keep);
DUK_DPRINT("mark-and-sweep sweep stringtable: %d freed, %d kept",
(int) count_free, (int) count_keep);
#endif
*out_count_keep = count_keep;
}
/*
* Sweep heap
*/
static void sweep_heap(duk_heap *heap, int flags) {
static void sweep_heap(duk_heap *heap, duk_int_t flags, duk_size_t *out_count_keep) {
duk_heaphdr *prev; /* last element that was left in the heap */
duk_heaphdr *curr;
duk_heaphdr *next;
#ifdef DUK_USE_DEBUG
int count_free = 0;
int count_keep = 0;
int count_finalize = 0;
int count_rescue = 0;
duk_size_t count_free = 0;
duk_size_t count_finalize = 0;
duk_size_t count_rescue = 0;
#endif
duk_size_t count_keep = 0;
DUK_UNREF(flags);
DUK_DDPRINT("sweep_heap: %p", (void *) heap);
@ -578,9 +578,7 @@ static void sweep_heap(duk_heap *heap, int flags) {
/*
* Plain, boring reachable object.
*/
#ifdef DUK_USE_DEBUG
count_keep++;
#endif
}
if (!heap->heap_allocated) {
@ -649,8 +647,9 @@ static void sweep_heap(duk_heap *heap, int flags) {
#ifdef DUK_USE_DEBUG
DUK_DPRINT("mark-and-sweep sweep objects (non-string): %d freed, %d kept, %d rescued, %d queued for finalization",
count_free, count_keep, count_rescue, count_finalize);
(int) count_free, (int) count_keep, (int) count_rescue, (int) count_finalize);
#endif
*out_count_keep = count_keep;
}
/*
@ -871,6 +870,10 @@ static void assert_valid_refcounts(duk_heap *heap) {
*/
int duk_heap_mark_and_sweep(duk_heap *heap, int flags) {
duk_size_t count_keep_obj;
duk_size_t count_keep_str;
duk_size_t tmp;
/* FIXME: thread selection for mark-and-sweep is currently a hack.
* If we don't have a thread, the entire mark-and-sweep is now
* skipped (although we could just skip finalizations).
@ -879,7 +882,7 @@ int duk_heap_mark_and_sweep(duk_heap *heap, int flags) {
DUK_DPRINT("temporary hack: gc skipped because we don't have a temp thread");
/* reset voluntary gc trigger count */
heap->mark_and_sweep_trigger_counter = heap->mark_and_sweep_trigger_limit;
heap->mark_and_sweep_trigger_counter = DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP;
return DUK_ERR_OK;
}
@ -952,8 +955,8 @@ int duk_heap_mark_and_sweep(duk_heap *heap, int flags) {
#ifdef DUK_USE_REFERENCE_COUNTING
finalize_refcounts(heap);
#endif
sweep_heap(heap, flags);
sweep_stringtable(heap);
sweep_heap(heap, flags, &count_keep_obj);
sweep_stringtable(heap, &count_keep_str);
#ifdef DUK_USE_REFERENCE_COUNTING
clear_refzero_list_flags(heap);
#endif
@ -1059,11 +1062,13 @@ int duk_heap_mark_and_sweep(duk_heap *heap, int flags) {
* Reset trigger counter
*/
/* very simplistic now, should be relative to heap size */
heap->mark_and_sweep_trigger_counter = heap->mark_and_sweep_trigger_limit;
tmp = (count_keep_obj + count_keep_str) / 256;
heap->mark_and_sweep_trigger_counter =
(tmp * DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT) +
DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD;
DUK_DPRINT("garbage collect (mark-and-sweep) finished (trigger reset to %d)",
heap->mark_and_sweep_trigger_counter);
DUK_DPRINT("garbage collect (mark-and-sweep) finished: %d objects kept, %d strings kept, trigger reset to %d",
(int) count_keep_obj, (int) count_keep_str, (int) heap->mark_and_sweep_trigger_counter);
return DUK_ERR_OK;
}

Loading…
Cancel
Save