Skip to content

perf(executor): globally sort bare-** globstar results (#664) - #674

Merged
caomengxuan666 merged 1 commit into
masterfrom
perf/issue664-glob
Oct 16, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
perf/issue664-glob

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

perf(executor): globally sort bare-** globstar results (#664)

What

With globstar on, bare ** over b/ b-a b/a builtins/ builtins.o builtins/x printed depth-first (b b/a b-a builtins builtins/x builtins.o) while GNU prints globally sorted (b b-a b/a builtins builtins.o builtins/x). GNU sorts the FULL result list
(pathexp.c:442 shell_glob_filename + sh_sortglob qsort at :881;
lib/glob/glob.c only enumerates). The old comment claiming
depth-first was GNU's emission order was wrong.

Fix

globstar_expand re-sorts the walked list globally via the existing
globsort_matches (byte order under C/POSIX through
strcoll_posixcmp, live collation otherwise; SORT_NOSORT still
skips). Per-directory walk order untouched. This also closes the
previously noted glob-12 bare-** ordering divergence.

Measured

Correctness slice (no perf claim): match/sort/store split bench for
the 4.1x per-file residual is a separate follow-up.

Verification

  • Repro tree: branch output byte-identical to GNU.
  • glob_diff.sh 34/34 vs GNU (was 33/34 with glob-12 divergent).
  • cargo test --lib 585/585.
  • Full serial failure-set gate vs master: cli_tests 465/0 on both
    legs (the tool's cli_tests NEW-target row is a parse artifact).
    Test-level 1 NEW / 2 DISAPPEARED, all three in the
    known-nondeterministic part_080 coproc family (all pass in
    isolation on branch). No regression.
  • niubash product A/B (niubash pinned 6295367, only rubash [patch]
    switched): failure sets byte-identical (49=49).

Bare ** printed depth-first while GNU sorts the full list
(pathexp.c:442 shell_glob_filename + sh_sortglob qsort at :881).
globstar_expand now re-sorts globally via globsort_matches (byte order
under C/POSIX, live collation otherwise; NOSORT still skips).
Per-directory walk untouched. Closes the glob-12 ordering divergence.

Repro byte-identical to GNU; glob battery 34/34 (was 33/34).
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.

1 participant