store: Slightly improve memoization hashing.
* guix/store.scm (open-connection): Call `make-hash-table' with 100. (add-text-to-store): Move TEXT first in ARGS, for better `hash' results. (add-to-store): Likewise, move ST first.
This commit is contained in:
parent
a9ebd9efd0
commit
fce2394e7d
1 changed files with 4 additions and 4 deletions
|
@ -344,8 +344,8 @@ (define* (open-connection #:optional (file %default-socket-path)
|
||||||
(let ((s (%make-nix-server s
|
(let ((s (%make-nix-server s
|
||||||
(protocol-major v)
|
(protocol-major v)
|
||||||
(protocol-minor v)
|
(protocol-minor v)
|
||||||
(make-hash-table)
|
(make-hash-table 100)
|
||||||
(make-hash-table))))
|
(make-hash-table 100))))
|
||||||
(let loop ((done? (process-stderr s)))
|
(let loop ((done? (process-stderr s)))
|
||||||
(or done? (process-stderr s)))
|
(or done? (process-stderr s)))
|
||||||
s))))))))
|
s))))))))
|
||||||
|
@ -478,7 +478,7 @@ (define add-text-to-store
|
||||||
"Add TEXT under file NAME in the store, and return its store path.
|
"Add TEXT under file NAME in the store, and return its store path.
|
||||||
REFERENCES is the list of store paths referred to by the resulting store
|
REFERENCES is the list of store paths referred to by the resulting store
|
||||||
path."
|
path."
|
||||||
(let ((args `(,name ,text ,references))
|
(let ((args `(,text ,name ,references))
|
||||||
(cache (nix-server-add-text-to-store-cache server)))
|
(cache (nix-server-add-text-to-store-cache server)))
|
||||||
(or (hash-ref cache args)
|
(or (hash-ref cache args)
|
||||||
(let ((path (add-text-to-store server name text references)))
|
(let ((path (add-text-to-store server name text references)))
|
||||||
|
@ -503,7 +503,7 @@ (define add-to-store
|
||||||
RECURSIVE? is true, its contents are added, and its permission bits are
|
RECURSIVE? is true, its contents are added, and its permission bits are
|
||||||
kept. HASH-ALGO must be a string such as \"sha256\"."
|
kept. HASH-ALGO must be a string such as \"sha256\"."
|
||||||
(let* ((st (stat file-name #f))
|
(let* ((st (stat file-name #f))
|
||||||
(args `(,basename ,recursive? ,hash-algo ,st))
|
(args `(,st ,basename ,recursive? ,hash-algo))
|
||||||
(cache (nix-server-add-to-store-cache server)))
|
(cache (nix-server-add-to-store-cache server)))
|
||||||
(or (and st (hash-ref cache args))
|
(or (and st (hash-ref cache args))
|
||||||
(let ((path (add-to-store server basename #t recursive?
|
(let ((path (add-to-store server basename #t recursive?
|
||||||
|
|
Loading…
Reference in a new issue