Skip to content

[FEAT] Make guix package manager detection faster #988

@Dariqq

Description

@Dariqq

While putting fastfetch 2.14 on a slower laptop of mine i noticed that my implementation for package counts for guix is quite slow taking 60-70ms for each of the 3 profiles on my main machine and up to 2-3x that on a slow laptop.

The main cause for this is waiting for guile to return the list of installed packages.

I have taken a look at what is happening behind the scenes:

  • The -I flag of guix package calls the list-installed function from here.
  • Which then uses profile-manifest (from here) to read and parse the manifest of the profile at PROFILE/manifest.

This manifest files currently look like this:

(manifest
 (version 4)
 (packages
  (("emacs"
    "29.3"
    "out"
    "/gnu/store/1bi7n031g6b5b07hvps3gyi0rhi44qkb-emacs-29.3"
    ;; ...
    )
   ("fastfetch"
    "2.14.0"
    "out"
    "/gnu/store/kamkxrxi8mdcfagfg0z4nfranhfn8csb-fastfetch-2.14.0"
    ;; ...
    )
   ("btop"
    "1.3.2"
    "out"
    "/gnu/store/0j1ya0g65nk613lnq56dyhnv4fk8blvb-btop-1.3.2")
   ;; .....
   )))

(Somtimes there is additional information for a package like search paths, propagated packages or provenance information, etc which I have omitted here for clarity)

All that gets displayed using guix package -I are the entries in the packages list.

Would it be possible to parse this file with C instead? Are there any other examples I could look at which do something similiar?

EDIT:
The thing that I tried was using GetNumStrings for "/gnu/store/" but that also catches additional entries from the additional fields that i omitted above. But at least it is a lot faster reducing the total time for packages to 4ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions