From f42ddd28538c55e601fa247590a95c8422a17e52 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 15 Aug 2020 19:29:32 -0600 Subject: [PATCH] cs: scale GC trigger by number of running places Since all places share the same pool of memory, scale the amount of memory allowed before trigger a (minor) GC by the number of running processes. --- racket/src/cs/rumble/memory.ss | 6 ++++++ racket/src/cs/rumble/place.ss | 2 ++ 2 files changed, 8 insertions(+) diff --git a/racket/src/cs/rumble/memory.ss b/racket/src/cs/rumble/memory.ss index f87b996525..8bbe41e757 100644 --- a/racket/src/cs/rumble/memory.ss +++ b/racket/src/cs/rumble/memory.ss @@ -32,6 +32,12 @@ (define (set-reachable-size-increments-callback! proc) (set! reachable-size-increments-callback proc)) +(define allocating-places 1) +(define (collect-trip-for-allocating-places! delta) + (with-global-lock + (set! allocating-places (+ allocating-places delta)) + (collect-trip-bytes (* allocating-places (* 8 1024 1024))))) + ;; Replicate the counting that `(collect)` would do ;; so that we can report a generation to the notification ;; callback diff --git a/racket/src/cs/rumble/place.ss b/racket/src/cs/rumble/place.ss index c68ee51123..bf8a9d1dad 100644 --- a/racket/src/cs/rumble/place.ss +++ b/racket/src/cs/rumble/place.ss @@ -81,6 +81,7 @@ (define (fork-place thunk finish-proc) (do-prepare-for-place) (fork-thread (lambda () + (collect-trip-for-allocating-places! +1) (init-virtual-registers) (place-registers (vector-copy place-register-inits)) (root-thread-cell-values (make-empty-thread-cell-values)) @@ -93,6 +94,7 @@ (thunk) 0))]) (finish-proc result) + (collect-trip-for-allocating-places! -1) (do-destroy-place))))) ;; Must be called within an engine, used for memory accounting: (define (current-place-roots)