Skip to content

UPSTREAM PR #17558: abstract env var names so they're insensitive on windows and sensitive on other operating systems#50

Open
loci-dev wants to merge 3 commits intomainfrom
loci/pr-17558-env_var_case_insensitive_windows
Open

UPSTREAM PR #17558: abstract env var names so they're insensitive on windows and sensitive on other operating systems#50
loci-dev wants to merge 3 commits intomainfrom
loci/pr-17558-env_var_case_insensitive_windows

Conversation

@loci-dev
Copy link
Copy Markdown

Note

Source pull request: nushell/nushell#17558

Apparently, there are still edge cases for case-insensitive env vars in Windows, so someone pointed me a different way to try and do it. This PR represents that way. All env vars (not just path) will be treated case-insensitive on Windows and case-sensitive on all other operating systems. Since this does the sensitivity checking for us, I removed (commented out for now) the get_env_var_insensitive function. I realize that windows is case-preserving and not really case-insensitive but this seemed like the best option for now.

Let me know if this is a bad idea.

Release notes summary - What our users need to know

Tasks after submitting

@loci-review
Copy link
Copy Markdown

loci-review Bot commented Feb 15, 2026

Overview

Analysis of 39,976 functions in Nushell (3,004 modified, 5,224 new, 5,218 removed, 26,530 unchanged) reveals mixed performance impact from environment variable refactoring across three commits implementing case-insensitive handling on Windows. Binary target.aarch64-unknown-linux-gnu.release.nu shows +0.248% power consumption (+2,294 nJ). Changes introduce EnvName wrapper type replacing O(n) linear scans with O(1) HashMap lookups, achieving correctness improvements with acceptable performance trade-offs.

Function Analysis

Major Regressions (Job Control System):

  • Mailbox::clear(): Response time 4,128ns → 26,628ns (+545%, +22,500ns), throughput stable at 69ns. Regression in child functions (BTreeMap/HashMap clear operations) due to PipelineData complexity with EnvName type.
  • Mailbox::recv_timeout(): Response time 11,208ns → 54,010ns (+382%, +42,802ns), throughput stable at 273ns. MPSC channel operations affected by PipelineData handling changes.
  • Mailbox::try_recv(): Response time 11,462ns → 54,260ns (+373%, +42,798ns), throughput stable at 108ns. Similar pattern to recv_timeout with unchanged source code.

Major Improvements (Command System):

  • Alias::run(): Response time 24,963ns → 417ns (-98%, -24,546ns), throughput stable at 94ns. Optimized error propagation benefits guard function despite no source changes.
  • Predeclaration::run(): Response time 24,891ns → 2,393ns (-90%, -22,498ns). Reduced environment variable lookup overhead in call hierarchy.
  • BlockCommand::run(): Response time 24,918ns → 2,422ns (-90%, -22,496ns). Faster error handling infrastructure.

Hot-Path Optimization:

  • type_compatible(): Response time 856ns → 297ns (-65%, -559ns), throughput 207ns → 101ns (-51%, -106ns). Performance-critical function in IR execution pipeline shows compiler optimization success.

Direct Optimization:

  • get_editor(): Response time 24,544ns → 22,450ns (-9%, -2,094ns), throughput 530ns → 245ns (-54%, -285ns). Refactored from get_env_vars() to targeted get_env_var() calls, eliminating unnecessary HashMap allocation.

Other analyzed functions in error handling, type comparison, and compiler-generated code showed minor changes with limited practical impact.

Additional Findings

Job control regressions (373-545%) occur in non-critical paths outside primary hot paths (IR execution, pipeline flow, parser, REPL loop). The 42-43µs absolute increases are acceptable for cleanup operations. Error handling shows net positive impact: guard functions improve 90-98% (executing frequently) while diagnostic functions regress 128-176% (executing rarely). The architectural refactoring successfully optimizes primary use cases while accepting minor secondary system regressions, justified by cross-platform correctness requirements.

🔎 Full breakdown: Loci Inspector.
💬 Questions? Tag @loci-dev.

@loci-dev loci-dev force-pushed the main branch 6 times, most recently from 1c6453c to 9e52565 Compare February 22, 2026 03:27
@loci-dev loci-dev force-pushed the main branch 5 times, most recently from 410f1b0 to 1e109b2 Compare March 3, 2026 03:25
@loci-dev loci-dev force-pushed the main branch 10 times, most recently from 6e93079 to 68fe8e6 Compare March 11, 2026 03:20
@loci-dev loci-dev force-pushed the main branch 2 times, most recently from 5184682 to 8d99fe1 Compare March 12, 2026 03:23
@loci-dev loci-dev force-pushed the main branch 8 times, most recently from d6c3b3e to aa2e4e6 Compare March 18, 2026 03:30
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