Optimize environment computation and/or improve cache hit rates

Abierto
#2,644 0 comentarios 5 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
go
Área
build-system

Línea de trabajo

Start by tracing the Devbox shell environment computation and cache-key generation; the issue’s debug output points to nix print-dev-env, but does not name Devbox source files or tests. Compare how package order affects the cache key and identify the relevant tests before making changes. Done means reordering packages without changing versions does not trigger an unnecessary recomputation, with tests covering that behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

feature triage
What problem are you trying to solve?

I've started using devbox for a project with a fair amount of packages. Python, Node, Docker, Terraform, Yarn, etc. Whenever the package list changes, it takes a non-trivial amount of time to run 'devbox shell'. At my current project size, something around 20-30s. It seems this will just increase the more I use devbox for packages.

I ran with DEVBOX_DEBUG=1 and see this:

time=2025-07-02T22:36:35.280-07:00 level=DEBUG source=go.jetify.com/devbox/internal/nix/nix.go:84 msg="nix command starting" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/path/to/myproject/.devbox/gen/flake"                                                                   
⣻ Computing the Devbox environment...                                                              
time=2025-07-02T22:36:57.969-07:00 level=DEBUG source=go.jetify.com/devbox/internal/nix/nix.go:84 msg="nix command exited" cmd.args="nix --extra-experimental-features ca-derivations --option experimental-features 'nix-command flakes fetch-closure' print-dev-env --json path:/path/to/myproject/.devbox/gen/flake" cmd.path=/run/current-system/sw/bin/nix cmd.pid=41301 cmd.code=0 cmd
✓ Computed the Devbox environment.                                                                 
What solution would you like?

It seems the big problem is the print-dev-env command. I'm not sure what would be involved in trying to optimize that. I'm not too familiar with Nix internals.

But while trying to figure out what was wrong, I noticed simply reordering the packages (no version changes) in devbox.json was enough to cause devbox to recompute the environment.

Unless I'm missing something, I feel like the order of packages shouldn't really matter. So there's probably an separate, smallish optimization possible here - cache results based on a sorted list of the packages list. That won't fix the first issue though.

Alternatives you've considered

I'm not sure what alternatives are possible, aside from not using devbox.

Lenguaje dominante
Go
Estrellas
12.4k
Forks
358
Merge medio
17 h 12 min
PR fusionados (30 d)
31

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de jetify-com/devbox

Todos los issues de jetify-com/devbox

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.