GNU bug report logs - #71941
Broken `map-derivation' procedure

Previous Next

Package: guix;

Reported by: Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>

Date: Thu, 4 Jul 2024 15:06:02 UTC

Severity: normal

Full log


Message #26 received at 71941 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sergio Pastor Pérez <sergio.pastorperez <at> gmail.com>
Cc: Josselin Poiret <dev <at> jpoiret.xyz>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, Mathieu Othacehe <othacehe <at> gnu.org>,
 Tobias Geerinckx-Rice <me <at> tobias.gr>, 71941 <at> debbugs.gnu.org,
 Christopher Baines <guix <at> cbaines.net>,
 Sergio Pastor Pérez <sergio.pastorperez <at> outlook.es>
Subject: Re: bug#71941: Broken `map-derivation' procedure
Date: Tue, 25 Feb 2025 18:27:53 +0100
Sergio Pastor Pérez <sergio.pastorperez <at> gmail.com> skribis:

> Implement caching to speed up computation.
>
> Change-Id: I186e2a62f6655e3b0738dd6e0f628faccd8b855e

Nice!

> +      (let ((cached-drv (hash-ref computed-drvs drv)))
> +        (if cached-drv
> +            cached-drv
> +            (let* ((inputs       (map (cut rewritten-input <> loop)

Two things:

  1. Preferably use ‘hashq-set!’ and ‘hashq-ref’ for the cache, to
     compare derivations according to ‘eq?’;

  2. Instead of rolling your own, perhaps you can use ‘mlambdaq’, which
     also has the advantage of maintaining statistics; you can see them
     by setting GUIX_PROFILING=memoization.

For #2, essentially you would write:

  (define loop
    (mlambdaq (drv)
      contents of the loop…))

  (loop drv)

I *think* that would do the job.

We you able to test this on meaningful cases?

Thanks for your work, and apologies for the delay!

Ludo’.




This bug report was last modified 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.