Adding support to do memory profiling of drr startup that drdr can track.

This commit is contained in:
Robby Findler 2010-06-30 19:28:31 -05:00
parent b4d176466a
commit 896bbfaabb
3 changed files with 48 additions and 10 deletions

View File

@ -106,7 +106,15 @@ If the namespace does not, they are colored the unbound color.
(define (printf . args) (apply fprintf o args)) (define (printf . args) (apply fprintf o args))
(define xref (delay/idle (load-collections-xref))) (define xref (if (getenv "PLTDRXREFDELAY")
(begin
(printf "PLTDRXREFDELAY: using plain delay\n")
(delay (begin
(printf "PLTDRXREFDELAY: loading xref\n")
(begin0
(load-collections-xref)
(printf "PLTDRXREFDELAY: loaded xref\n")))))
(delay/idle (load-collections-xref))))
(define (get-xref) (force xref)) (define (get-xref) (force xref))

View File

@ -1,6 +1,7 @@
#lang scribble/doc #lang scribble/doc
@(require "common.ss" @(require "common.ss"
(for-label compiler/cm)) (for-label compiler/cm
racket/promise))
@title[#:tag "extending-drracket"]{Extending DrRacket} @title[#:tag "extending-drracket"]{Extending DrRacket}
@ -163,4 +164,13 @@ Several environment variables can affect DrRacket's behavior:
@exec{setup-plt} with the @Flag{c} flag, set the environment @exec{setup-plt} with the @Flag{c} flag, set the environment
variable, and then run @exec{setup-plt} again.} variable, and then run @exec{setup-plt} again.}
@item{@indexed-envvar{PLTDRXREFDELAY} : When this environment variable
is set, DrRacket uses an ordinary @scheme[delay] (instead of
@scheme[delay/idle]) delay the computation of the searching
indicies. This means that Check Syntax will start more slowly
the first time, but that the startup performance is more
predictable. In addition, when the environment variable is
set, DrRacket will print out that it is set, and will print
when the index is started loading and when it finishes loading.}
] ]

View File

@ -1,6 +1,8 @@
#lang racket/base #lang racket/base
(require "drracket-test-util.rkt" (require "drracket-test-util.rkt"
racket/gui/base) racket/gui/base
racket/class
framework/test)
;; mem-cnt returns the amount of memory used, iterating (collect-garbage) ;; mem-cnt returns the amount of memory used, iterating (collect-garbage)
;; until the delta is less than 10k or we've done it 20 times. ;; until the delta is less than 10k or we've done it 20 times.
@ -17,12 +19,30 @@
[else [else
(loop new-cmu (- n 1))])))) (loop new-cmu (- n 1))]))))
(fire-up-drscheme-and-run-tests (void (putenv "PLTDRXREFDELAY" "yes"))
(λ ()
(let ([drscheme-frame (wait-for-drscheme-frame)] (define (wait-and-print)
[s (make-semaphore 0)]) (let ([s (make-semaphore 0)])
;; let two rounds of pending events be handled.
(queue-callback (λ () (queue-callback (λ () (semaphore-post s)) #f)) #f) (queue-callback (λ () (queue-callback (λ () (semaphore-post s)) #f)) #f)
(yield s) ;; let two rounds of pending events be handled. (yield s)
;; print out memory use in a fake form to be tracked by drdr
(let ([n (mem-cnt)]) (let ([n (mem-cnt)])
(printf "cpu time: ~a real time: ~a gc time: ~a\n" (printf "cpu time: ~a real time: ~a gc time: ~a\n"
n n n))))) n n n))))
(printf "The printouts below are designed to trick drdr into graphing them;\nthey aren't times, but memory usage.\n")
(fire-up-drscheme-and-run-tests
(λ ()
(let ([drs-frame (wait-for-drscheme-frame)])
(wait-and-print)
(send (send drs-frame get-definitions-text) insert "#lang racket/base\n+")
(set-module-language!)
(test:run-one (lambda () (send (send drs-frame syncheck:get-button) command)))
(wait-for-computation drs-frame)
(wait-and-print))))