Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Auto GC runs garbage collection during fleek completion generation, adding delay to shell startup #316

Open
trevnels opened this issue Oct 18, 2023 · 0 comments

Comments

@trevnels
Copy link

Describe the bug
When auto_gc is set to true, Nix garbage collection takes place during all invocations of the fleek command, since it is handled inside the root command. This includes fleek completion bash, which is part of the bashrc generated by fleek. This leads to garbage collection taking place during shell initialization, which adds a noticeable delay before the bash prompt is presented. This delay likely depends on CPU and disk performance, number of nix packages installed, etc. For me, it's about half a second.

To Reproduce
Steps to reproduce the behavior:

  • Ensure auto_gc is set to true in .fleek.yml.
  • Open a new terminal, making note of the time it takes for the prompt to be presented.
  • Change auto_gc to false, and apply the configuration change.
  • Open a new shell again - notice that the prompt is presented noticeably faster.

You can also run fleek completion bash manually to reproduce the issue - the command's output will be produced immediately, but the process will block for a while before exiting. The --debug flag will also show that the process blocks while garbage is being collected.

Expected behavior
Garbage collection ran during fleek operations, or at least shell completion generation, should not block the fleek process itself from exiting. Instead, nix-collect-garbage could be ran in a way that allows fleek to exit immediately, while garbage collection can continue in the background. I'm not super familiar with Go, but it looks like replacing cmd.Run with cmd.Start when running nix-collect-garbage here may accomplish this, since processes spawned with cmd.Start without being waited on will allow their parent to exit while continuing to run in the background.

Another approach may be to only collect garbage after changes have been made to packages (i.e. after applying a new config) instead of during every fleek invocation. This would also avoid redundant GC executions in cases where the nix store may not have changed at all.

Environment

  • OS: Universal Blue silverblue-nvidia 38.20231015.0
  • Shell: bash
  • fleek version: 0.10.5
nadavspi added a commit to nadavspi/dotfiles that referenced this issue Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant