grafts: Record cache lookups for profiling.
* guix/grafts.scm (record-cache-lookup!): New procedure. (with-cache): Use it.
This commit is contained in:
parent
0a3c723e07
commit
6bd3d4fe06
1 changed files with 8 additions and 2 deletions
|
@ -172,10 +172,16 @@ (define (references* items)
|
|||
items))))
|
||||
(remove (cut member <> self) refs)))
|
||||
|
||||
(define record-cache-lookup!
|
||||
(cache-lookup-recorder "derivation-graft-cache"
|
||||
"Derivation graft cache"))
|
||||
|
||||
(define-syntax-rule (with-cache key exp ...)
|
||||
"Cache the value of monadic expression EXP under KEY."
|
||||
(mlet %state-monad ((cache (current-state)))
|
||||
(match (vhash-assoc key cache)
|
||||
(mlet* %state-monad ((cache (current-state))
|
||||
(result -> (vhash-assoc key cache)))
|
||||
(record-cache-lookup! result cache)
|
||||
(match result
|
||||
((_ . result) ;cache hit
|
||||
(return result))
|
||||
(#f ;cache miss
|
||||
|
|
Loading…
Reference in a new issue