unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Optimizing union.scm
Date: Sun, 23 Mar 2014 23:55:43 -0400	[thread overview]
Message-ID: <87r45sl074.fsf_-_@yeeloong.lan> (raw)
In-Reply-To: <87siq8r77u.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 23 Mar 2014 21:27:33 +0100")

ludo@gnu.org (Ludovic Courtès) writes:

> Mark H Weaver <mhw@netris.org> skribis:
>
>> I want to optimize it anyway, since it takes over 5 minutes to build
>> my profile, which is a bit painful.
>
> Oh, this much?
>
> I have 140 packages in my profile and it takes less than 30s to build
> it; that’s an SSD though, so that probably makes a big difference.

My profile has 155 packages.  I've looked over union.scm and can see
some extreme wastefulness, most notably in the use of 'others-have-it?'.
I guess this typically does N 'lstat' calls for every file or directory
in every package in the resulting profile that cannot be pruned (due to
being in a directory that's only in one package), where N is the number
of packages in the profile.

I'm fairly sure it is possible to replace those N 'lstat' calls with
something that requires 0 system calls and at most O(log N) time.  The
basic idea would be to iterate over all packages in a breadth-first
manner, as follows:

I think we should readdir the top-level directories of every package,
and merge them together into a single map structure (vhash?) that maps
filenames to sets of packages containing that filename.  We don't even
need to 'lstat' them at this point, all we need are the names.  After
we've read the directories of every package, we then iterate over the
map.  For any unique entries, we simply make a symlink in the new
profile.

For duplicates we'd do conflict resolution, which starts with an
'lstat'.  For directories, the default conflict resolution would simply
create a directory in the new profile and then recurse into that
subdirectory, considering only the packages that contained that
subdirectory.

My guess is that this would speed up profile creation by at least an
order of magnitude, maybe more.

What do you think?

      Mark

  parent reply	other threads:[~2014-03-24  3:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12  7:12 Problems with handicapped 'bash' from glibc package Mark H Weaver
2014-02-12 13:14 ` Ludovic Courtès
2014-02-12 17:39   ` Mark H Weaver
2014-02-12 19:31     ` Andreas Enge
2014-02-12 20:33       ` Ludovic Courtès
2014-02-12 21:33         ` Mark H Weaver
2014-02-13  9:14           ` Andreas Enge
2014-03-23 16:19 ` Ludovic Courtès
2014-03-23 20:19   ` Mark H Weaver
2014-03-23 20:27     ` Ludovic Courtès
2014-03-24  3:31       ` Mark H Weaver
2014-03-28 13:48         ` Ludovic Courtès
2014-03-24  3:55       ` Mark H Weaver [this message]
2014-03-24 13:45         ` Optimizing union.scm Ludovic Courtès
2014-03-25  7:04           ` Mark H Weaver
2014-03-25 17:18             ` Ludovic Courtès
2014-03-25 22:30               ` Mark H Weaver
2014-03-25 22:58                 ` Ludovic Courtès
2014-03-27  7:09                   ` Mark H Weaver
2014-03-27  9:57                     ` Ludovic Courtès
2014-04-02 14:14             ` Optimizing ‘guix package’ Ludovic Courtès
2014-04-02 16:58               ` Mark H Weaver
2014-03-26 23:29   ` Problems with handicapped 'bash' from glibc package Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r45sl074.fsf_-_@yeeloong.lan \
    --to=mhw@netris.org \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).