[optimization] Grafting is too slow

  • Open
  • quality assurance status badge
Details
3 participants
  • Lars-Dominik Braun
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 23 Oct 2020 15:07
(name . Lars-Dominik Braun)(address . ldb@leibniz-psychology.org)
875z71ccq0.fsf_-_@gmail.com
Hello Lars,

Lars-Dominik Braun <ldb@leibniz-psychology.org> writes:

Toggle quote (10 lines)
> Hi Maxim,
>
>> Judging from the above, it seems this issue has been resolved.
> grafting is still a performance issue imo. Compare for example:
>
> $ time guix environment --ad-hoc --search-paths r-learnr
> guix environment --ad-hoc --search-paths r-learnr 5,90s user 0,09s system 210% cpu 2,844 total
> $ time guix environment --ad-hoc --search-paths r-learnr --no-grafts
> guix environment --ad-hoc --search-paths r-learnr --no-grafts 2,03s user 0,08s system 164% cpu 1,277 total

I'm opening a new issue to track optimizing the grafting code, since
it's independent of environments (grafts are applied anytime a
derivation is built, AFAICT). Grafting is inherently IO-bound, since it
must scan all the built artifacts of a grafted package (from its
dependency that was 'replaced' all the way up), if I understood
correctly. "info (guix) Security Updates" gives some information.

Perhaps we could benchmark how fast our code currently is for grafting,
and compare it with the fastest sed-like utility out there, as a
starting point, to have an idea of how much there is to gain from
optimization.

Maxim
L
L
Ludovic Courtès wrote on 23 Oct 2020 23:17
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87lffwk5fm.fsf@gnu.org
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (16 lines)
> Lars-Dominik Braun <ldb@leibniz-psychology.org> writes:
>
>> Hi Maxim,
>>
>>> Judging from the above, it seems this issue has been resolved.
>> grafting is still a performance issue imo. Compare for example:
>>
>> $ time guix environment --ad-hoc --search-paths r-learnr
>> guix environment --ad-hoc --search-paths r-learnr 5,90s user 0,09s system 210% cpu 2,844 total
>> $ time guix environment --ad-hoc --search-paths r-learnr --no-grafts
>> guix environment --ad-hoc --search-paths r-learnr --no-grafts 2,03s user 0,08s system 164% cpu 1,277 total
>
> I'm opening a new issue to track optimizing the grafting code, since
> it's independent of environments (grafts are applied anytime a
> derivation is built, AFAICT). Grafting is inherently IO-bound,

What is slow above is not grafting itself: it’s determining what to
graft that takes CPU time.

I had reopened the initial bug at https://issues.guix.gnu.org/41702;
should we close this one?

Thanks,
Ludo’.
M
M
Maxim Cournoyer wrote on 25 Oct 2020 03:33
(name . Ludovic Courtès)(address . ludo@gnu.org)
87o8kr2fx7.fsf@gmail.com
Hello!

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

Toggle quote (21 lines)
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> Lars-Dominik Braun <ldb@leibniz-psychology.org> writes:
>>
>>> Hi Maxim,
>>>
>>>> Judging from the above, it seems this issue has been resolved.
>>> grafting is still a performance issue imo. Compare for example:
>>>
>>> $ time guix environment --ad-hoc --search-paths r-learnr
>>> guix environment --ad-hoc --search-paths r-learnr 5,90s user 0,09s system 210% cpu 2,844 total
>>> $ time guix environment --ad-hoc --search-paths r-learnr --no-grafts
>>> guix environment --ad-hoc --search-paths r-learnr --no-grafts 2,03s user 0,08s system 164% cpu 1,277 total
>>
>> I'm opening a new issue to track optimizing the grafting code, since
>> it's independent of environments (grafts are applied anytime a
>> derivation is built, AFAICT). Grafting is inherently IO-bound,
>
> What is slow above is not grafting itself: it’s determining what to
> graft that takes CPU time.

On my system, grafting seems IO rather than CPU bound, I'm guessing
because of the need to scan all the files for strings to replace in the
graft process.

Toggle quote (3 lines)
> I had reopened the initial bug at https://issues.guix.gnu.org/41702;
> should we close this one?

Many optimizations were made in the above issue that were not related to
the grafting process, so to me a fresh entry such as this one is clearer
to follow. That said, feel free to proceed as you see fit, being the
issue "owner" :-).

Thanks,

Maxim
L
L
Ludovic Courtès wrote on 25 Oct 2020 17:43
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87wnzedzof.fsf@gnu.org
Hi!

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

Toggle quote (16 lines)
>>>> $ time guix environment --ad-hoc --search-paths r-learnr
>>>> guix environment --ad-hoc --search-paths r-learnr 5,90s user 0,09s system 210% cpu 2,844 total
>>>> $ time guix environment --ad-hoc --search-paths r-learnr --no-grafts
>>>> guix environment --ad-hoc --search-paths r-learnr --no-grafts 2,03s user 0,08s system 164% cpu 1,277 total
>>>
>>> I'm opening a new issue to track optimizing the grafting code, since
>>> it's independent of environments (grafts are applied anytime a
>>> derivation is built, AFAICT). Grafting is inherently IO-bound,
>>
>> What is slow above is not grafting itself: it’s determining what to
>> graft that takes CPU time.
>
> On my system, grafting seems IO rather than CPU bound, I'm guessing
> because of the need to scan all the files for strings to replace in the
> graft process.

Yes, you’re right of course. But I think in the example above Lars was
reporting the run time of the ‘guix’ command when the graft itself is
already built. Just the extra code to compute the graft derivation (not
actually building them) leads to x2 wall-clock time or so.

Toggle quote (8 lines)
>> I had reopened the initial bug at https://issues.guix.gnu.org/41702;
>> should we close this one?
>
> Many optimizations were made in the above issue that were not related to
> the grafting process, so to me a fresh entry such as this one is clearer
> to follow. That said, feel free to proceed as you see fit, being the
> issue "owner" :-).

Alright, thanks!

Ludo’.
L
L
Lars-Dominik Braun wrote on 26 Oct 2020 08:56
(name . Ludovic Courtès)(address . ludo@gnu.org)
20201026075634.GA5916@zpidnp36
Hi,

Toggle quote (4 lines)
> Yes, you’re right of course. But I think in the example above Lars was
> reporting the run time of the ‘guix’ command when the graft itself is
> already built. Just the extra code to compute the graft derivation (not
> actually building them) leads to x2 wall-clock time or so.
yes, Ludo is right. The numbers I reported are with grafts already built, warm caches and
local socket communication. So we’re only seeing the CPU-bound computation
here. Sorry for the confusion. I should have been more specific in the other
issue.

Cheers,
Lars
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEyk+M9DfXR4/aBV/UQhN3ARo3hEYFAl+WgQUACgkQQhN3ARo3
hEbM3QwAqkNwd2/libncB6AJcuCh/kqAE/CWUP/CvwN1y59QwuVTDkWbXtmmhPnz
hCpA68lx3TlWsolyh9Xe5ZIPJXH/qWjjq9q9iTE+SkUqVLz/oLKfiFC+YjzL/GhQ
8AkWlm7QwujRi/ZKsYvfpsJRjzNfvnKPhfiWO7xuwBP8T42Lv9XOQy7tNlM7hD8K
DHIAeB0UwXS29duVuQ1heyZ/qPPGOQfVCb4YbMjHfuTyV1CssAQG9UUhQgyV3CQM
aJOv1wlLT73fGnLcDslgBWEQxLiMiFhuyLKd6J2mWRnYeQVlRlS0Teq3BqBsiXpl
LUzC2w/lH89NckNRb33WjJo7xYtvov2ov9X69dxH7Fza7xEHU9QPZjHNKhd0tvrZ
Ccydf+MwzPlFYCFAH9wbtbYfsKPuI11B/iR5+qOkMsj31r2/9LLlGTQWrjcFHQNh
TrN882zyb40bOxOJ5dkcb9oJGDZLZI0tDIAatAlOvumjGmGdKxxvZ8ybxWi+N9kU
+bPyXs+b
=RKCG
-----END PGP SIGNATURE-----


?