nushell / nushell/nushell

`highlight_resolved_externals` slows down typing in `nushell` when computer is switched from AC to battery power

Open
#13,166 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:syntax-highlighting performance
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

I've noticed that while using nushell, if I unplug my laptop, typing in the shell becomes very slow and laggy. If I set highlight_resolved_externals to false this issue does not arise.

How to reproduce
  1. Start a nushell session while connected to AC power
  2. Switch to battery power
  3. Type in session
Expected behavior

I expected nushell to remain as responsive as it was on AC power.

Screenshots

No response

Configuration
key value
version 0.94.2
major 0
minor 94
patch 2
branch
commit_hash be8c1dc0066cd1034a6b110a622f47b516bfe029
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-pc-windows-msvc
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-06-03 19:27:48 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash, which
installed_plugins
Additional context

I am running nushell via Windows Terminal (Preview).

Additionally, I feel as if I remember that the highlight_resolved_externals is making a which call each time to resolve those external commands. If that is the case, I realize that this may not be something that can be fixed necessarily, but was wondering if there was any workarounds, for example:

  1. A way to set the variable to false when running on battery power
  2. Supplement the performance of which by caching resolved externals
  3. Changing the behavior of how often which is run? (Seems to be checking the whole command on keystroke)
  4. Allow the externals resolver to be defined manually (Would allow users to define caching manually, use different strategies?)

I am open to any suggestions!

Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the highlight_resolved_externals path and the external-command resolution or which call described in the report. Reproduce the AC-to-battery transition on Windows with highlighting enabled, then determine whether the change should prevent per-keystroke slowdown, cache resolution, or document a workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.