Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nix caching #1082

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

feat: add nix caching #1082

wants to merge 3 commits into from

Conversation

shyim
Copy link
Contributor

@shyim shyim commented Mar 28, 2024

  • Added caching for devenv up and devenv shell
  • Replaced nix develop with just invoking the user shell, therefore we use still the normal shell
  • Fixed some warnings while cargo build
  • Find a solution for enterShell hooks when not calling bash anymore
  • Add a --no-cache flag to skip caching
  • Improve code style 🙈

Fixes #1079

No cache:

❯ time devenv shell -- whoami
shyim

________________________________________________________
Executed in    6.61 secs      fish           external
   usr time   27.40 millis   47.00 micros   27.35 millis
   sys time   20.56 millis  845.00 micros   19.72 millis

Cached environment execution:

❯ time devenv shell -- whoami
shyim

________________________________________________________
Executed in   37.70 millis    fish           external
   usr time   19.73 millis   30.00 micros   19.70 millis
   sys time   13.26 millis  517.00 micros   12.75 millis

Native without devenv

❯ time whoami
shyim

________________________________________________________
Executed in    5.89 millis    fish           external
   usr time    1.76 millis    0.03 millis    1.73 millis
   sys time    2.52 millis    1.02 millis    1.50 millis

@shyim shyim marked this pull request as draft March 28, 2024 17:11
@domenkozar
Copy link
Member

Why don't we use print_dev_env function when we know it's cached?

This also needs to respect imports in devenv.yaml when calculating the hash.

@shyim
Copy link
Contributor Author

shyim commented Apr 1, 2024

print_dev_env is called by direnv and direnv does his own caching 🤔
I am not sure if we want to ditch the caching of direnv completely, as it right now works fine 🤔. and we would at least have ~30ms latency switching between projects as devenv needs to be called

@domenkozar
Copy link
Member

print_dev_env is called by direnv and direnv does his own caching 🤔 I am not sure if we want to ditch the caching of direnv completely, as it right now works fine 🤔. and we would at least have ~30ms latency switching between projects as devenv needs to be called

Could you explain the goal of this PR? Then it makes it easier to discuss possible implementations :)

@shyim
Copy link
Contributor Author

shyim commented Apr 1, 2024

Make devenv shell and devenv up faster on existing projects without any changes. When merging the direnv caching is possible, it would be nice to have one place of caching.

@domenkozar
Copy link
Member

So kind of like direnv caching without direnv?

@shyim
Copy link
Contributor Author

shyim commented Apr 2, 2024

Yes excactly

@domenkozar
Copy link
Member

I'll tackle this shortly, it's important to get back to blazing fast :)

@shyim
Copy link
Contributor Author

shyim commented Apr 19, 2024

further random idea: Could we get from one nix eval back all environment variables + the process startup script.

Instead of right now doing three nix commands, we could do only one 🤔

@domenkozar
Copy link
Member

That's actually what I'm exploring, we'd need to reimplement print-dev-env in Rust and then we got it all.

Will post results as soon as I get something working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move nix caching from direnv plugin to devenv cli
2 participants