[PATCH] system: vm: Auto-detect if inputs should be registered.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 12 May 2019 02:50
(name . guix-patches)(address . guix-patches@gnu.org)
87d0kov6kx.fsf@gmail.com
Hello!

The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be
removed and its value computed automatically, since the operating-system
definition is available in its context. When the operating-system definition
does not contain the GUIX-SERVICE-TYPE, do not register the closure in the
database of Guix, as it takes time and doesn't serve a purpose.

The time saving is close to 2 minutes on my machine for every test using
a very minimal OS configuration and building it with `guix system
docker-image my-config.scm'.

Thank you,

Maxim
L
L
Ludovic Courtès wrote on 12 May 2019 23:31
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 35692@debbugs.gnu.org)
87a7frtl5i.fsf@gnu.org
Hi Maxim,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (6 lines)
> The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be
> removed and its value computed automatically, since the operating-system
> definition is available in its context. When the operating-system definition
> does not contain the GUIX-SERVICE-TYPE, do not register the closure in the
> database of Guix, as it takes time and doesn't serve a purpose.

That’s clever!

Toggle quote (4 lines)
> The time saving is close to 2 minutes on my machine for every test using
> a very minimal OS configuration and building it with `guix system
> docker-image my-config.scm'.

Neat.

Toggle quote (4 lines)
>>From 59d78c066727d5c3df22a6e269025ae7e058b45c Mon Sep 17 00:00:00 2001
> From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
> Date: Tue, 16 Apr 2019 17:15:02 -0400
> Subject: [PATCH] system: vm: Auto-detect if inputs should be registered.
^
I’d just write “vm:” here.

Toggle quote (8 lines)
> The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be
> removed and its value computed automatically, since the operating-system
> definition is available in its context. When the operating-system definition
> does not contain the GUIX-SERVICE-TYPE, do not register the closure in the
> database of Guix, as it takes time and doesn't serve a purpose.
>
> * gnu/system/vm.scm (use-modules): Add (gnu services base).

Nitpick: We don’t usually document ‘use-modules’ changes here.

Toggle quote (10 lines)
> (system-docker-image): Remove the REGISTER-CLOSURES? argument, as well as its
> associate documentation in the docstring.
> [has-guix-service-type?] Add predicate and use it to compute the value of the
> REGISTER-CLOSURE? argument of the INITIALIZE procedure.

> +(define (has-guix-service-type? os)
> + (find (lambda (service)
> + (eq? (service-kind service) guix-service-type))
> + (operating-system-services os)))

Please add a docstring and make sure there are not tabs. :-)

Otherwise LGTM, thank you!

Ludo’.
M
M
Maxim Cournoyer wrote on 14 May 2019 05:09
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 35692-done@debbugs.gnu.org)
87sgth7mvo.fsf@gmail.com
Hello!

Ludovic Courtès <ludo@gnu.org> writes:

[...]

Toggle quote (7 lines)
>>>From 59d78c066727d5c3df22a6e269025ae7e058b45c Mon Sep 17 00:00:00 2001
>> From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
>> Date: Tue, 16 Apr 2019 17:15:02 -0400
>> Subject: [PATCH] system: vm: Auto-detect if inputs should be registered.
> ^
> I’d just write “vm:” here.

Done.

Toggle quote (10 lines)
>> The argument REGISTER-CLOSURE? of the SYSTEM-DOCKER-IMAGE procedure can be
>> removed and its value computed automatically, since the operating-system
>> definition is available in its context. When the operating-system definition
>> does not contain the GUIX-SERVICE-TYPE, do not register the closure in the
>> database of Guix, as it takes time and doesn't serve a purpose.
>>
>> * gnu/system/vm.scm (use-modules): Add (gnu services base).
>
> Nitpick: We don’t usually document ‘use-modules’ changes here.

OK. I've removed it.

Toggle quote (14 lines)
>> (system-docker-image): Remove the REGISTER-CLOSURES? argument, as well as its
>> associate documentation in the docstring.
>> [has-guix-service-type?] Add predicate and use it to compute the value of the
>> REGISTER-CLOSURE? argument of the INITIALIZE procedure.
>
>> +(define (has-guix-service-type? os)
>> + (find (lambda (service)
>> + (eq? (service-kind service) guix-service-type))
>> + (operating-system-services os)))
>
> Please add a docstring and make sure there are not tabs. :-)

> Otherwise LGTM, thank you!

No, thanks to you for tirelessly reviewing many contributions while also
producing a mind boggling amount of new code/features :-).

I noticed that this change was breaking tests/guix-system.sh. The reason
was that the HAS-GUIX-SERVICE predicate could return a service type as a
truthy value, which was unwieldy when passed to environments which lack
the service definition. The solution is to ensure that the predicate
return booleans values, using (not (not ...)).

I've also slightly improved the commit message and some docstrings, and pushed as
commit d03de6be0aa2e2889314b5ed9a8867375363d79f.

Thank you!

Maxim
Closed
?