mbox

[bug#43340,0/5] Speed up archive export/import

Message ID 20200911144049.14632-1-ludo@gnu.org
Headers show

Message

Ludovic Courtès Sept. 11, 2020, 2:40 p.m. UTC
Hi!

This patch series goes on top of <https://issues.guix.gnu.org/43285>.
It addresses the performance issue described at:

  https://lists.gnu.org/archive/html/guix-devel/2020-09/msg00073.html

Specifically, it implements option #4 (spawning ‘guix authenticate’
once for the whole session, instead of spawning it every time a
store item needs to be signed or authenticated), achieving a ~15x
speedup, which is not bad.  :-)

There’s way more C++ code than I would like, and it’s probably not
pretty code (I always end up typing things like “C++ list append”
in a search engine to find the obscure incantation that does that).
There’s now a query/reply protocol between the daemon and ‘guix
authenticate’.  Nothing fancy, but it allows for strings that contain
whitespace or newlines, which is necessary here.

That’s it!

Ludo’.

Ludovic Courtès (5):
  daemon: Generalize 'HookInstance' to 'Agent'.
  daemon: Isolate signing and signature verification functions.
  daemon: Move 'Agent' to libutil.
  daemon: Spawn 'guix authenticate' once for all.
  authenticate: Cache the ACL and key pairs.

 guix/scripts/authenticate.scm | 163 ++++++++++++++++++++++++++--------
 nix/libstore/build.cc         | 146 +++++-------------------------
 nix/libstore/local-store.cc   | 103 +++++++++++++++++----
 nix/libutil/util.cc           |  84 ++++++++++++++++++
 nix/libutil/util.hh           |  25 ++++++
 tests/guix-authenticate.sh    |  45 ++++++----
 tests/store.scm               |   8 +-
 7 files changed, 372 insertions(+), 202 deletions(-)

Comments

Mathieu Othacehe Sept. 12, 2020, 7:12 a.m. UTC | #1
Hey Ludo,

>> Specifically, it implements option #4 (spawning ‘guix authenticate’
>> once for the whole session, instead of spawning it every time a
>> store item needs to be signed or authenticated), achieving a ~15x
>> speedup, which is not bad.  :-)

Woo, congrats!

> Below is the new Gantt chart for:
>
>   perf timechart record guix archive --export -r $(guix build coreutils -d) -v3 >/tmp/dump
>
> Most of the work happens in ‘guix authenticate’.

I never used the "timechart" sub-command but it sounds really
nice. Regarding the option you chose, I think it's the more appropriate
right now. It's very delicate to dedicate time and effort to tweak
guix-daemon and how we use it, having in mind that we'd like to get rid
of it.

However, the potential short term gains can be so huge, that for now
it's the best thing to do. I should just do like you, and dive into it
to see what can be done for contention and locking when using
'build-paths' RPC via Cuirass.

In the meantime, a short review that I hope to complete next week.

Thanks for your efforts,

Mathieu
Ludovic Courtès Sept. 13, 2020, 1:07 p.m. UTC | #2
Hi!

Mathieu Othacehe <othacehe@gnu.org> skribis:

>>> Specifically, it implements option #4 (spawning ‘guix authenticate’
>>> once for the whole session, instead of spawning it every time a
>>> store item needs to be signed or authenticated), achieving a ~15x
>>> speedup, which is not bad.  :-)
>
> Woo, congrats!

To be clear, it’s 15x on the pathological case where we send only small
store items; the difference is obviously less significant if few store
items are exported or if the store items are large.  Now, I expect it to
make a noticeable difference on the typical build farm workload.

>> Below is the new Gantt chart for:
>>
>>   perf timechart record guix archive --export -r $(guix build coreutils -d) -v3 >/tmp/dump
>>
>> Most of the work happens in ‘guix authenticate’.
>
> I never used the "timechart" sub-command but it sounds really
> nice. Regarding the option you chose, I think it's the more appropriate
> right now. It's very delicate to dedicate time and effort to tweak
> guix-daemon and how we use it, having in mind that we'd like to get rid
> of it.

Yeah.

> However, the potential short term gains can be so huge, that for now
> it's the best thing to do. I should just do like you, and dive into it
> to see what can be done for contention and locking when using
> 'build-paths' RPC via Cuirass.

Yup, makes sense!

> In the meantime, a short review that I hope to complete next week.

Thanks for your feedback!

Ludo’.