Don't use the after-gc-hook for monitoring garbage collection
This seems to be happening not in the thread I expect, so avoid using the hook.
This commit is contained in:
parent
90cec0d8ac
commit
4210699949
1 changed files with 24 additions and 21 deletions
|
|
@ -231,31 +231,34 @@
|
||||||
|
|
||||||
(set-thread-name "gc watcher")
|
(set-thread-name "gc watcher")
|
||||||
|
|
||||||
(add-hook!
|
(let loop ((last-gc-times
|
||||||
after-gc-hook
|
(or (assq-ref (gc-stats) 'times) 0))
|
||||||
(let ((last-gc-time-taken
|
(last-gc-time-taken
|
||||||
(assq-ref (gc-stats) 'gc-time-taken)))
|
(assq-ref (gc-stats) 'gc-time-taken)))
|
||||||
(lambda ()
|
(let* ((stats (gc-stats))
|
||||||
(let* ((stats
|
(gc-times (or (assq-ref stats 'gc-times) 0))
|
||||||
(gc-stats))
|
(gc-time-taken (assq-ref stats 'gc-time-taken)))
|
||||||
(gc-time-taken
|
(when (> gc-times last-gc-times)
|
||||||
|
(let ((gc-time-taken
|
||||||
(assq-ref stats 'gc-time-taken))
|
(assq-ref stats 'gc-time-taken))
|
||||||
(time-since-last
|
(time-since-last
|
||||||
(/ (- gc-time-taken
|
(/ (- gc-time-taken
|
||||||
last-gc-time-taken)
|
last-gc-time-taken)
|
||||||
internal-time-units-per-second)))
|
internal-time-units-per-second))
|
||||||
(when (> time-since-last 0.1)
|
(gcs
|
||||||
|
(- gc-times
|
||||||
|
last-gc-times)))
|
||||||
(format (current-error-port)
|
(format (current-error-port)
|
||||||
"after gc (additional time taken: ~f, times: ~d, heap-allocated-since-gc: ~d, heap size: ~d, heap free: ~d)\n"
|
"~d gc's (time taken: ~f, heap-allocated-since-gc: ~d, heap size: ~d, heap free: ~d)\n"
|
||||||
time-since-last
|
gcs
|
||||||
(assq-ref stats 'gc-times)
|
(/ time-since-last
|
||||||
|
gcs)
|
||||||
(assq-ref stats 'heap-allocated-since-gc)
|
(assq-ref stats 'heap-allocated-since-gc)
|
||||||
(assq-ref stats 'heap-size)
|
(assq-ref stats 'heap-size)
|
||||||
(assq-ref stats 'heap-free-size)))
|
(assq-ref stats 'heap-free-size))))
|
||||||
(set! last-gc-time-taken
|
(sleep 5)
|
||||||
(assq-ref (gc-stats) 'gc-time-taken))))))
|
(loop gc-times
|
||||||
(while #t
|
gc-time-taken)))))
|
||||||
(usleep 100000))))
|
|
||||||
|
|
||||||
;; Provide some visual space between the startup output and the
|
;; Provide some visual space between the startup output and the
|
||||||
;; server starting
|
;; server starting
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue