mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-08 07:56:16 -05:00
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