jetify-com / devbox-install-action

31 stars 15 forks source link

Action execution duration #29

Open tomshabtay opened 7 months ago

tomshabtay commented 7 months ago

Running the action is taking about 20 seconds to complete. does it sound reasonable? any suggestions how to make it faster?

Looking at the log, this the longest part of the action:

2024-01-18T09:55:27.9214877Z info: downloading installer (https://install.determinate.systems/nix/tag/v0.16.0/nix-installer-x86_64-linux)
2024-01-18T09:55:28.8724733Z `nix-installer` needs to run as `root`, attempting to escalate now via `sudo`...
2024-01-18T09:55:28.9186794Z   2024-01-18T09:55:28.916990Z  INFO nix_installer::plan: Step: Create directory `/nix`
2024-01-18T09:55:28.9188510Z     at src/plan.rs:191
2024-01-18T09:55:28.9189042Z 
2024-01-18T09:55:28.9190155Z   2024-01-18T09:55:28.918585Z  INFO nix_installer::plan: Step: Provision Nix
2024-01-18T09:55:28.9191175Z     at src/plan.rs:191
2024-01-18T09:55:28.9191827Z 
2024-01-18T09:55:31.3899558Z   2024-01-18T09:55:31.389678Z  INFO nix_installer::plan: Step: Create build users (UID 30001-30032) and group (GID 30000)
2024-01-18T09:55:31.3900841Z     at src/plan.rs:191
2024-01-18T09:55:31.3901250Z 
2024-01-18T09:55:32.1014458Z   2024-01-18T09:55:32.101007Z  INFO nix_installer::plan: Step: Configure Nix
2024-01-18T09:55:32.1015516Z     at src/plan.rs:191
2024-01-18T09:55:32.1015909Z 
2024-01-18T09:55:32.2438890Z   2024-01-18T09:55:32.243630Z  INFO nix_installer::plan: Step: Create directory `/etc/tmpfiles.d`
2024-01-18T09:55:32.2440316Z     at src/plan.rs:191
2024-01-18T09:55:32.2440849Z 
2024-01-18T09:55:32.2442779Z   2024-01-18T09:55:32.243648Z  INFO nix_installer::plan: Step: Configure Nix daemon related settings with systemd
2024-01-18T09:55:32.2444014Z     at src/plan.rs:191
2024-01-18T09:55:32.2444492Z 
2024-01-18T09:55:33.0706393Z   2024-01-18T09:55:33.069496Z  INFO nix_installer::plan: Step: Remove directory `/nix/temp-install-dir`
2024-01-18T09:55:33.0719670Z     at src/plan.rs:191
2024-01-18T09:55:33.0720331Z 
2024-01-18T09:55:33.7938019Z Nix was installed successfully!
2024-01-18T09:55:33.7939600Z To get started using Nix, open a new shell or run `. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh`
2024-01-18T09:55:33.7940646Z 
2024-01-18T09:55:33.8858102Z ##[group]Run actions/cache/restore@v3
2024-01-18T09:55:33.8858677Z with:
2024-01-18T09:55:33.8859522Z   path: ~/.cache/devbox
~/.cache/nix
~/.local/state/nix
~/.nix-defexpr
~/.nix-profile
/nix/store
/nix/var/nix

2024-01-18T09:55:33.8860950Z   key: Linux-devbox-nix-store-9f117df80d478816ab1b9c40e8371c3827dab54e3df60c446479af6a63cc098f
2024-01-18T09:55:33.8861991Z   enableCrossOsArchive: false
2024-01-18T09:55:33.8862533Z   fail-on-cache-miss: false
2024-01-18T09:55:33.8863043Z   lookup-only: false
2024-01-18T09:55:33.8863486Z env:
2024-01-18T09:55:33.8863886Z   latest_version: 0.8.5
2024-01-18T09:55:33.8864366Z ##[endgroup]
2024-01-18T09:55:35.3614918Z Received 88080384 of 317438014 (27.7%), 83.9 MBs/sec
2024-01-18T09:55:36.3667546Z Received 313243710 of 317438014 (98.7%), 149.1 MBs/sec
2024-01-18T09:55:36.3837454Z Cache Size: ~303 MB (317438014 B)
2024-01-18T09:55:36.3884767Z [command]/home/runner/.local/bin/tar -xf /home/runner/work/_temp/124f78eb-9458-4929-9ce4-21731be5f070/cache.tzst -P -C /home/runner/work/xxxxxxxxxx --use-compress-program unzstd
2024-01-18T09:55:37.3645564Z Received 317438014 of 317438014 (100.0%), 100.7 MBs/sec
2024-01-18T09:55:45.1834989Z Cache restored successfully
2024-01-18T09:55:45.2338284Z Cache restored from key: Linux-devbox-nix-store-9f117df80d478816ab1b9c40e8371c3827dab54e3df60c446479af6a63cc098f

I tried changing the input skip-nix-installation to false which fail the action, I guess this variable can help in case the github runner already has nix installed.

adding the devbox.json just in case:

{
  "packages": {
    "helmfile":                         "0.159.0",
    "kubernetes-helm":                  "3.13.2",
    "kubernetes-helmPlugins.helm-diff": "3.8.1",
    "kubernetes-helmPlugins.helm-s3":   "0.15.1",
    "kubectl":                          "1.28.4"
  }
}

Thanks!

LucilleH commented 6 months ago

20s sounds reasonable 🤔 . The bulk of the time is probably taken by installing Nix + packages.

I tried changing the input skip-nix-installation to false which fail the action, I guess this variable can help in case the github runner already has nix installed.

Correct

dephiros commented 5 months ago

I noticed that install-nix-action is able to complete ~4s: https://github.com/cachix/install-nix-action/actions/runs/8198580795/job/22422336858 Maybe we can see what optimization that they use there?

LucilleH commented 5 months ago

@dephiros I think for install-nix-action, the 4s is just installing Nix without any packages. Based on the screenshot it looks like ours also took around 5s (from 09:55:27 to 09:55:33). The rest of ~12s was spent on restoring the nix store cache from GitHub. Perhaps there's something we can do to optimize that cache restoration part 🤔

dephiros commented 5 months ago

cc @kalbasit