Skip to content

fix(task): parallelize exec_env loading to fix parallel task execution#7313

Merged
jdx merged 1 commit intomainfrom
fix/parallel-exec-env
Dec 15, 2025
Merged

fix(task): parallelize exec_env loading to fix parallel task execution#7313
jdx merged 1 commit intomainfrom
fix/parallel-exec-env

Conversation

@jdx
Copy link
Copy Markdown
Owner

@jdx jdx commented Dec 15, 2025

Summary

  • Fixes parallel task execution (:::) running sequentially when ASDF-based tools like poetry, yarn, or pipx are configured
  • Changes env_from_tools() to use parallel::parallel() instead of a sequential for loop
  • Significantly improves startup time when multiple tools with exec-env scripts are configured

Root Cause

In src/toolset/mod.rs, env_from_tools() used a sequential for loop with await, causing each tool's exec_env() to run one after another. For ASDF-based tools, exec_env runs bash scripts that can take seconds each, making parallel task execution effectively sequential.

Test plan

  • mise run lint passes
  • mise run test:unit - all 377 tests pass
  • Manual test with multiple ASDF tools that have exec-env scripts

Fixes #5451

🤖 Generated with Claude Code


Note

Runs exec_env for non-system tools concurrently in env_from_tools, improving performance and preserving error isolation.

  • Toolset
    • env_from_tools:
      • Run backend.exec_env concurrently via parallel::parallel for non-System tool requests.
      • Return (key, value, backend_id) tuples; flatten and exclude PATH entries.
      • On errors, log warnings and return empty results per tool; use unwrap_or_default() on the parallel outcome.
      • Minor refactor to precompute work items and reuse backend_id per result.

Written by Cursor Bugbot for commit e60a2d5. This will update automatically on new commits. Configure here.

Previously, env_from_tools() used a sequential for loop with await,
causing each tool's exec_env() to run one after another. For ASDF-based
tools like poetry, yarn, and pipx, exec_env runs bash scripts that can
take seconds each, making parallel task execution (:::) effectively
sequential.

This change uses parallel::parallel() to run all exec_env calls
concurrently, significantly improving startup time when multiple tools
with exec-env scripts are configured.

Fixes #5451

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 15, 2025 12:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes parallel task execution being run sequentially when ASDF-based tools (like poetry, yarn, pipx) are configured by parallelizing the loading of execution environments.

  • Changes env_from_tools() to use parallel::parallel() instead of sequential for loop with await
  • Improves startup time when multiple tools with exec-env scripts are configured

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/toolset/mod.rs
.collect();

let envs = parallel::parallel(items, |(config, this, b, tv)| async move {
let backend_id = b.id().to_string();
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend_id is converted to String eagerly but only used when mapping environment variables. Consider moving this conversion inside the Ok branch at line 705 where it's actually needed to avoid unnecessary allocations when exec_env fails.

Copilot uses AI. Check for mistakes.
@jdx jdx enabled auto-merge (squash) December 15, 2025 12:50
@github-actions
Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 x -- echo 21.0 ± 0.5 20.0 23.1 1.02 ± 0.04
mise x -- echo 20.6 ± 0.7 19.3 27.0 1.00

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 env 20.6 ± 0.4 19.6 23.1 1.00 ± 0.04
mise env 20.6 ± 0.7 19.2 25.3 1.00

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 hook-env 20.8 ± 0.4 19.7 22.0 1.02 ± 0.03
mise hook-env 20.5 ± 0.6 19.1 23.3 1.00

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.7 ls 17.4 ± 0.4 16.4 19.6 1.00
mise ls 18.1 ± 0.6 16.8 21.2 1.04 ± 0.04

xtasks/test/perf

Command mise-2025.12.7 mise Variance
install (cached) 110ms 113ms -2%
ls (cached) 66ms 67ms -1%
bin-paths (cached) 73ms 73ms +0%
task-ls (cached) 447ms ✅ 307ms +45%

✅ Performance improvement: task-ls cached is 45%

@jdx jdx merged commit 3d6af4d into main Dec 15, 2025
30 checks passed
@jdx jdx deleted the fix/parallel-exec-env branch December 15, 2025 12:53
jdx pushed a commit that referenced this pull request Dec 15, 2025
### 🚀 Features

- **(conda)** add dependency resolution for conda packages by @jdx in
[#7280](#7280)
- **(go)** add created_at support to ls-remote --json by @jdx in
[#7305](#7305)
- **(hook-env)** add hook_env.cache_ttl and hook_env.chpwd_only settings
for NFS optimization by @jdx in
[#7312](#7312)
- **(hooks)** add MISE_TOOL_NAME and MISE_TOOL_VERSION to
preinstall/postinstall hooks by @jdx in
[#7311](#7311)
- **(shell_alias)** add shell_alias support for cross-shell aliases by
@jdx in [#7316](#7316)
- **(tool)** add security field to mise tool --json by @jdx in
[#7303](#7303)
- add --before flag for date-based version filtering by @jdx in
[#7298](#7298)

### 🐛 Bug Fixes

- **(aqua)** support cosign v3 bundle verification by @jdx in
[#7314](#7314)
- **(config)** use correct config_root in tera context for hooks by @jdx
in [#7309](#7309)
- **(nu)** fix nushell deactivation script on Windows by @fu050409 in
[#7213](#7213)
- **(python)** apply uv_venv_create_args in auto-venv code path by @jdx
in [#7310](#7310)
- **(shell)** escape exe path in activation scripts for paths with
spaces by @jdx in [#7315](#7315)
- **(task)** parallelize exec_env loading to fix parallel task execution
by @jdx in [#7313](#7313)
- track downloads for python and java by @jdx in
[#7304](#7304)
- include full tool ID in download track by @jdx in
[#7320](#7320)

### 📚 Documentation

- Switch `postinstall` code to be shell-agnostic by @thejcannon in
[#7317](#7317)

### 🧪 Testing

- **(e2e)** disable debug mode by default for windows-e2e by @jdx in
[#7318](#7318)

### New Contributors

- @fu050409 made their first contribution in
[#7213](#7213)
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.

2 participants