memory accounting: blame the parent instead of the child
svn: r12853
This commit is contained in:
parent
ab115fb6e4
commit
45e4684e4f
|
@ -312,7 +312,7 @@
|
|||
;; time limit
|
||||
(when sec
|
||||
(let ([t (current-thread)])
|
||||
(thread (lambda () (sleep sec) (set! r 'time) (kill-thread t)))))
|
||||
(thread (lambda () (unless (sync/timeout sec t) (set! r 'time)) (kill-thread t)))))
|
||||
(set! r (with-handlers ([void (lambda (e) (list raise e))])
|
||||
(call-with-values thunk (lambda vs (list* values vs))))))
|
||||
;; The thread might be killed by the timer thread, so don't let
|
||||
|
|
|
@ -57,19 +57,19 @@ or indirectly). If @scheme[cust] is not strictly subordinate to
|
|||
|
||||
@defproc[(custodian-memory-accounting-available?) boolean?]{
|
||||
|
||||
Returns @scheme[#t] if PLT Scheme is compiled with support for
|
||||
per-custodian memory accounting, @scheme[#f] otherwise.
|
||||
|
||||
@margin-note{Memory accounting is normally available in PLT Scheme 3m,
|
||||
which is the main variant of PLT Scheme, and not normally available in
|
||||
PLT Scheme CGC.}}
|
||||
PLT Scheme CGC.}
|
||||
|
||||
Returns @scheme[#t] if PLT Scheme is compiled with support for
|
||||
per-custodian memory accounting, @scheme[#f] otherwise.}
|
||||
|
||||
@defproc[(custodian-require-memory [limit-cust custodian?]
|
||||
[need-amt exact-nonnegative-integer?]
|
||||
[stop-cust custodian?]) void?]{
|
||||
|
||||
Registers a require check if PLT Scheme is compiled with support for
|
||||
per-custodian memory accounting, otherwise the
|
||||
Registers a required-memory check if PLT Scheme is compiled with
|
||||
support for per-custodian memory accounting, otherwise the
|
||||
@exnraise[exn:fail:unsupported].
|
||||
|
||||
If a check is registered, and if PLT Scheme later reaches a state after
|
||||
|
@ -81,8 +81,8 @@ trigger some shutdown, then @scheme[stop-cust] is shut down.}
|
|||
[limit-amt exact-nonnegative-integer?]
|
||||
[stop-cust custodian? limit-cust]) void?]{
|
||||
|
||||
Registers a limit check if PLT Scheme is compiled with support for
|
||||
per-custodian memory accounting, otherwise the
|
||||
Registers a limited-memory check if PLT Scheme is compiled with
|
||||
support for per-custodian memory accounting, otherwise the
|
||||
@exnraise[exn:fail:unsupported].
|
||||
|
||||
If a check is registered, and if PLT Scheme later reaches a state
|
||||
|
@ -93,7 +93,10 @@ after garbage collection (see @secref["gc-model"]) where
|
|||
@margin-note{A custodian's limit is checked only after a garbage
|
||||
collection, except that it may also be checked during
|
||||
certain large allocations that are individually larger
|
||||
than the custodian's limit.}
|
||||
than the custodian's limit. A single garbage collection
|
||||
may shut down multiple custodians, even if shutting down
|
||||
only one of the custodians would have reduced memory use
|
||||
for other custodians.}
|
||||
|
||||
For reliable shutdown, @scheme[limit-amt] for
|
||||
@scheme[custodian-limit-memory] must be much lower than the total
|
||||
|
|
|
@ -801,7 +801,9 @@ object is reachable from two custodians where neither is an ancestor
|
|||
of the other, an object is arbitrarily charged to one of the other,
|
||||
and the choice can change after each collection; objects reachable
|
||||
from both a custodian and its descendant, however, are reliably
|
||||
charged to the descendant. Reachability for per-custodian accounting
|
||||
does not include weak references, references to threads managed by
|
||||
non-descendant custodians, references to non-descendant custodians, or
|
||||
references to custodian boxes for non-descendant custodians.
|
||||
charged to the custodian and not to the descendants, unless the
|
||||
custodian can reach the objects only through a descendant custodian or
|
||||
a descendant's thread. Reachability for per-custodian accounting does
|
||||
not include weak references, references to threads managed by other
|
||||
custodians, references to other custodians, or references to custodian
|
||||
boxes for other custodians.
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
Version 4.1.3.6
|
||||
Memory accounting changed to bias charges to parent instead of children
|
||||
|
||||
Version 4.1.3.3
|
||||
Added compile-context-preservation-enabled
|
||||
Added exception-backtrace support for x86_84+JIT
|
||||
|
|
|
@ -312,7 +312,7 @@ main.@LTO@: $(XSRCDIR)/main.c
|
|||
$(CC) $(CFLAGS) -c $(XSRCDIR)/main.c -o main.@LTO@
|
||||
|
||||
gc2.@LTO@: $(srcdir)/gc2.c $(srcdir)/newgc.c $(srcdir)/gc2.h \
|
||||
$(srcdir)/newgc.h $(srcdir)/blame_the_child.c \
|
||||
$(srcdir)/newgc.h $(srcdir)/mem_account.c \
|
||||
$(srcdir)/sighand.c \
|
||||
$(srcdir)/vm_osx.c $(srcdir)/vm_mmap.c $(srcdir)/vm_osk.c $(srcdir)/vm.c\
|
||||
$(srcdir)/vm_memalign.c $(srcdir)/alloc_cache.c \
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*****************************************************************************/
|
||||
/* blame-the-child accounting */
|
||||
/* memory accounting */
|
||||
/*****************************************************************************/
|
||||
#ifdef NEWGC_BTC_ACCOUNT
|
||||
|
||||
#include "../src/schpriv.h"
|
||||
/* BTC_ prefixed functions are called by newgc.c */
|
||||
/* btc_ prefixed functions are internal to blame_the_child.c */
|
||||
/* btc_ prefixed functions are internal to mem_account.c */
|
||||
|
||||
static const int btc_redirect_thread = 511;
|
||||
static const int btc_redirect_custodian = 510;
|
||||
|
@ -430,13 +430,7 @@ static void BTC_do_accounting(NewGC *gc)
|
|||
if(owner_table[i])
|
||||
owner_table[i]->memory_use = 0;
|
||||
|
||||
/* the end of the custodian list is where we want to start */
|
||||
while(SCHEME_PTR1_VAL(box)) {
|
||||
cur = (Scheme_Custodian*)SCHEME_PTR1_VAL(box);
|
||||
box = cur->global_next;
|
||||
}
|
||||
|
||||
/* walk backwards for the order we want */
|
||||
/* walk forward for the order we want (blame parents instead of children) */
|
||||
while(cur) {
|
||||
int owner = custodian_to_owner_set(gc, cur);
|
||||
|
||||
|
@ -448,7 +442,7 @@ static void BTC_do_accounting(NewGC *gc)
|
|||
GCDEBUG((DEBUGOUTF, "Propagating accounting marks\n"));
|
||||
propagate_accounting_marks(gc);
|
||||
|
||||
box = cur->global_prev; cur = box ? SCHEME_PTR1_VAL(box) : NULL;
|
||||
box = cur->global_next; cur = box ? SCHEME_PTR1_VAL(box) : NULL;
|
||||
}
|
||||
|
||||
gc->in_unsafe_allocation_mode = 0;
|
|
@ -93,7 +93,7 @@ inline static int is_master_gc(NewGC *gc) {
|
|||
/* particular collector you want. */
|
||||
/*****************************************************************************/
|
||||
|
||||
/* This turns on blame-the-child automatic memory accounting */
|
||||
/* This turns on automatic memory accounting */
|
||||
/* #define NEWGC_BTC_ACCOUNT */
|
||||
/* #undef NEWGC_BTC_ACCOUNT */
|
||||
|
||||
|
@ -1365,11 +1365,11 @@ inline static void reset_pointer_stack(void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* BLAME THE CHILD */
|
||||
/* MEMORY ACCOUNTING */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef NEWGC_BTC_ACCOUNT
|
||||
# include "blame_the_child.c"
|
||||
# include "mem_account.c"
|
||||
#else
|
||||
# define clean_up_thread_list() /* */
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user