Ludovic Courtès writes: > Christopher Baines skribis: > >> This is intended to help with spotting duplication in the object cache, so >> where many keys, for example package records map to the same derivation. This >> represents an opportunity for improved performance if you can reduce this >> duplication in the cache, and better take advantage of the already present >> cache entries. > > Another way to detect this is by looking at ‘add-data-to-store-cache’ > stats: > > $ GUIX_PROFILING="add-data-to-store-cache object-cache" guix build --no-grafts greetd wlgreet du-dust circtools --target=aarch64-linux-gnu -d > /gnu/store/mivzv83wryv9gp5bjncg5m1831dx2xwr-circtools-1.0.0.drv > /gnu/store/4xf7kh9mi0vpvs8m1ak4x8w1rpsdpv6z-du-dust-0.8.6.drv > /gnu/store/ayk54gvlbc1qam6irzf9kaig56dhzni0-wlgreet-0.4.1.drv > /gnu/store/r601i40cii9ic5w1k4hy5c2yngfayh64-greetd-0.9.0.drv > Object Cache: > fresh caches: 22 > lookups: 40435 > hits: 36821 (91.1%) > cache size: 3613 entries > > 'add-data-to-store' cache: > lookups: 4090 > hits: 958 (23.4%) > .drv files: 3062 (74.9%) > Scheme files: 916 (22.4%) > $ GUIX_PROFILING="add-data-to-store-cache object-cache" ./pre-inst-env guix build --no-grafts greetd wlgreet du-dust circtools --target=aarch64-linux-gnu -d > /gnu/store/1wsldmvigjb8w2gk418npbnfznlb0ck1-circtools-1.0.0.drv > /gnu/store/b5c73fawjdvkgy431qxz9l6l9y9a9lhz-du-dust-0.8.6.drv > /gnu/store/zwc7qzsbzf62dgbbzy74lki4hsr406bw-wlgreet-0.4.1.drv > /gnu/store/vjdd23hc82701afb132z1ajcqa7hfd74-greetd-0.9.0.drv > Object Cache: > fresh caches: 22 > lookups: 37942 > hits: 34523 (91.0%) > cache size: 3418 entries > > 'add-data-to-store' cache: > lookups: 3895 > hits: 763 (19.6%) > .drv files: 2957 (75.9%) > Scheme files: 826 (21.2%) > > Ideally, the hit rate there would be 0% and we could remove it. > > If there’s a positive hit rate, it means we keep adding the same .drv > and/or *-builder files to the store, meaning that the object cache was > ineffective. > >> +(define* (report-object-cache-duplication store #:key (threshold 10) >> + (port (current-error-port))) > > Do you have an example output of this? > > How helpful does it look to you in practice? Yep, so here's some output I get from computing all the cross derivations to i586-pc-gnu: value # /gnu/store/92avphfdcrcaxx8m5a6ihmw558bj3np8-subversion-1.14.2 7fcfbe5f9280> cached 4174 times example keys: - # - # - # "/bin/svn"> - # "/bin/svn"> So it's not immediately obvious what the issue is, but if you search for "/bin/svn", then you find the file-append calls in svn-fetch, so there's a couple of new file-append records added to the cache for each svn-fetch. value /gnu/store/qi1km3qlv5hdsql6h3ibwvz6v4z8lqbz-ld-wrapper.in cached 755 times example keys: - #< file: "/home/chris/Projects/Guix/guix/gnu/packages/ld-wrapper.in" absolute: # name: "ld-wrapper.in" recursive?: #t select?: #> - #< file: "/home/chris/Projects/Guix/guix/gnu/packages/ld-wrapper.in" absolute: # name: "ld-wrapper.in" recursive?: #t select?: #> - #< file: "/home/chris/Projects/Guix/guix/gnu/packages/ld-wrapper.in" absolute: # name: "ld-wrapper.in" recursive?: #t select?: #> - #< file: "/home/chris/Projects/Guix/guix/gnu/packages/ld-wrapper.in" absolute: # name: "ld-wrapper.in" recursive?: #t select?: #> Similar to file-append, it's not immediately obvious where all these local-file's are coming from, but searching for ld-wrapper.in suggests make-ld-wrapper. My thinking here is that maybe it's worth not caching everything in the object cache. Particularly for file-append, I'm not sure what the cache is actually doing. As for local-file, given there's lower level caching, maybe it's worth leaning on that and not caching local-file either. I tried this out, and it seemed to not make performance worse at least, and it did remove the duplication from the cache. Other things that show up include: value # /gnu/store/lkmwq399jllig2a5r323v6y9nflpn6gn-binutils-cross-i586-pc-gnu-2.38 7fcfbd358000> cached 1228 times example keys: - # - # - # - #