|
9 | 9 |
|
10 | 10 | (define limit-dots " ... ") |
11 | 11 |
|
12 | | -;; (listof (U blame? (cons blame? blame-party) #f)) profile-samples |
| 12 | +;; using dynamic-require, to also work on versions that don't have it |
| 13 | +(define space-efficient-key |
| 14 | + (dynamic-require '(lib "racket/contract/combinator") |
| 15 | + 'space-efficient-contract-continuation-mark-key |
| 16 | + (lambda _ #f))) |
| 17 | + |
| 18 | +;; (listof (U (vector (U blame? (cons blame? blame-party)) boolean?) #f)) |
| 19 | +;; profile-samples |
13 | 20 | ;; -> contract-profile? |
| 21 | +;; boolean denotes whether the sampled contract was space-efficient |
14 | 22 | (define (correlate-contract-samples contract-samples time+samples) |
15 | 23 | ;; car of time+samples is total time, car of each sample is thread id |
16 | 24 | ;; for now, we just assume a single thread. fix this eventually. |
|
26 | 34 | ;; If the sampler was stopped after recording a contract sample, but |
27 | 35 | ;; before recording the corresponding time sample, the two lists may |
28 | 36 | ;; be of different lengths. That's ok, just drop the extra sample. |
29 | | - (for/list ([-blame (in-list contract-samples)] |
30 | | - [s (in-list samples)] |
31 | | - #:when -blame) |
| 37 | + (for/list ([c-s (in-list contract-samples)] |
| 38 | + [s (in-list samples)] |
| 39 | + #:when c-s) |
| 40 | + (match-define `#(,-blame ,space-efficient?) c-s) |
32 | 41 | ;; In some cases, blame information is missing a party, in which. |
33 | 42 | ;; case the contract system provides a pair of the incomplete blame |
34 | 43 | ;; and the missing party. We combine the two here. |
35 | 44 | (define blame |
36 | 45 | (if (pair? -blame) |
37 | 46 | (blame-add-missing-party (car -blame) (cdr -blame)) |
38 | 47 | -blame)) |
39 | | - (contract-sample blame s))) |
| 48 | + (contract-sample blame space-efficient? s))) |
40 | 49 | (define all-blames |
41 | 50 | (set->list (for/set ([c-s (in-list live-contract-samples)]) |
42 | 51 | (define b (contract-sample-blame c-s)) |
|
172 | 181 | #:defaults ([boundary-view-key-file #'#f]))) |
173 | 182 | ... |
174 | 183 | body:expr ...) |
175 | | - #`(let ([sampler (create-sampler (current-thread) 0.005 (current-custodian) |
176 | | - (list contract-continuation-mark-key))]) |
| 184 | + #`(let ([sampler (create-sampler |
| 185 | + (current-thread) 0.005 (current-custodian) |
| 186 | + (list contract-continuation-mark-key |
| 187 | + (or space-efficient-key |
| 188 | + ;; won't be found, so we'll just get `#f`s |
| 189 | + (gensym))))]) |
177 | 190 | (begin0 (begin body ...) |
178 | 191 | (let () |
179 | 192 | (sampler 'stop) |
|
193 | 206 | ;; (contract-profile (for/fold ([acc 0]) |
194 | 207 | ;; ([i (in-range 10000000)]) |
195 | 208 | ;; (+ acc (vector-ref v 0) (vector-ref w 0)))) |
196 | | - (and (not (empty? s)) (vector-ref (car s) 0)))) |
| 209 | + (and (not (empty? s)) (car s)))) |
197 | 210 | (analyze-contract-samples |
198 | 211 | contract-samples |
199 | 212 | samples |
|
0 commit comments