jetify-com / devbox

Instant, easy, and predictable development environments

Home Page:https://www.jetify.com/devbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`devbox shell` is ~4X slower with poetry in packages

justinTM opened this issue · comments

commented

What happened?

first of all: love this project, it's like makefile but not in the 1900's.

however, i noticed it takes ~4X longer to start devbox shells and run devbox scripts when using poetry virtual environments then with poetry removed from packages. i haven't dug into which tool is responsible, but i will go bully the poetry maintainers after this (they're mean anyways).

obviously we're nitpicking less than a second, but i chain together a lot of devbox runs so it multiplies. also devbox lists speed as its third-highest priority on the homepage.

$ time devbox run branch
You can activate the virtual environment by running 'source $VENV_DIR/bin/activate'
copied to keyboard!

real    0m0.173s
user    0m0.069s
sys     0m0.057s

... (best of 5 runs) takes about 0.17s to get the current git branch and copy it to the clipboard.

now we uncomment poetry from packages (best of 5 runs):

$ time devbox run branch
Using virtualenv: /Users/me/git/gl/org/project/.venv
You can activate the virtual environment by running 'source $VENV_DIR/bin/activate'
copied to keyboard!

real    0m0.618s
user    0m0.383s
sys     0m0.157s

Steps to reproduce

Command

No response

devbox.json

// devbox.json
{
  "packages": [
    "git@latest",
    "vim@latest",
    "terraform@1.5.7",
    "docker@latest",
    "awscli@1.31.6",
    "jq@latest",
    "terragrunt@latest",
    // disabling poetry for time testing  "poetry@1.6.1",
    "python@3.11.6",
    "docker-buildx@latest",
    "dive@latest"
  ],
  "env": {
    "VENV_DIR": ".venv"
  },
  "shell": {
    "init_hook": [
    ],
    "scripts": {
      "branch": [
        "git rev-parse --abbrev-ref HEAD | tr -d '\n' | pbcopy && echo copied to keyboard! >&2"
      ],
    }
  }
}

Devbox version

0.9.1

Nix version

No response

What system does this bug occur on?

macOS (Intel)

Debug logs

commented

i think the best way to solve this is enable poetry virtual environment for devbox shell (which i need ipython with my package+deps) but for run scripts skip virtual environment so it doesn't blow up to 4 * N_SCRIPTS times as long to execute.

i will search around for a way to conditionally enable poetry virtualenv only in devbox shell and not in devbox run

I wonder if this would be helped by exposing more hooks in devbox. Right now we only have the init_hook, which runs on everything, but adding additional hooks could give the user more control over what runs on shell vs scripts

commented

@Lagoja that would be great! if i understand correctly, i could have scripts run a different init hook than the devbox shell init hook, if i wanted it that way?