Skip to content

scheds: add --completions flag for shell completion generation#3495

Open
kobataiwan wants to merge 2 commits intosched-ext:mainfrom
kobataiwan:fix/shell-completions
Open

scheds: add --completions flag for shell completion generation#3495
kobataiwan wants to merge 2 commits intosched-ext:mainfrom
kobataiwan:fix/shell-completions

Conversation

@kobataiwan
Copy link
Copy Markdown

Summary

  • Add a hidden --completions <SHELL> flag to all 16 Rust schedulers and scxcash for distro packaging of shell completions (bash, zsh, fish, elvish, powershell) via clap_complete
  • Document the feature in DEVELOPER_GUIDE.md with batch install example
  • Include scripts/test_completions.sh to validate completions output across all targets

Details

The flag is hidden from --help (intended for distro packagers, not end users) and exits immediately after printing — no kernel, BPF, or root required.

# Distro packaging: generate at install time
scx_bpfland --completions bash > /usr/share/bash-completion/completions/scx_bpfland

Reference: scxtop already has this via a GenerateCompletions subcommand. The schedulers use a simpler hidden flag approach — less invasive, no main() refactor needed.

Targets (16 schedulers + 1 tool)

scx_beerland, scx_bpfland, scx_cake, scx_chaos, scx_cosmos, scx_flash,
scx_lavd, scx_layered, scx_mitosis, scx_p2dq, scx_pandemonium,
scx_rustland, scx_rusty, scx_tickless, scx_wd40, scxcash

Skipped: scx_rlfifo (no clap dependency), scxtop (already done), xtask/vmlinux_docify (internal build tools)

Test plan

  • All 16 targets build cleanly
  • --completions bash/zsh/fish produces valid output and exits 0 on all targets
  • --completions is hidden from --help
  • Binary name is correct in generated output (no copy-paste errors)
  • ValueEnum variants appear in completions (scx_cake profiles)
  • scripts/test_completions.sh passes (110 checks, 0 failures)

Fixes: #1572

@kobataiwan kobataiwan force-pushed the fix/shell-completions branch 2 times, most recently from 8ecf852 to d38ed9d Compare March 31, 2026 12:16
Koba Ko added 2 commits March 31, 2026 20:22
Add a hidden --completions <SHELL> flag to all 16 Rust schedulers and
scxcash so that distros can auto-generate shell completions at package
install time. Supports bash, zsh, fish, elvish, and powershell via
clap_complete.

The flag is hidden from --help (intended for packaging, not end users)
and exits immediately after printing completions — no kernel, BPF, or
root required.

Usage:
  scx_bpfland --completions bash > /usr/share/bash-completion/completions/scx_bpfland

Fixes: sched-ext#1572
Signed-off-by: Koba Ko <koba.taiwan@gmail.com>
Add a Shell Completions section explaining the --completions flag and
a batch install example for all schedulers. Include a test script in
scripts/ that validates completions output across all 16 targets.

Fixes: sched-ext#1572
Signed-off-by: Koba Ko <koba.taiwan@gmail.com>
Copy link
Copy Markdown
Contributor

@hodgesds hodgesds left a comment

Choose a reason for hiding this comment

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

Seems legit

galpt added a commit to galpt/scx that referenced this pull request Apr 8, 2026
Localize the common reserved and shared wake paths with per-CPU DSQ lanes while keeping bounded global fallback for fairness and rescue. Move the hottest monitor-only enqueue and dispatch counters to per-CPU aggregation so the common path depends less on shared accounting, and keep the exported metrics surface stable in userspace aggregation.

Bump scx_flow to 2.2.0 and add hidden --completions <SHELL> support via clap_complete so the scheduler already matches the shell-completion packaging flow from upstream PR sched-ext#3495 without requiring a later compatibility patch.

Validated with cargo fmt/check/clippy -D warnings, the v2.2 benchmark pass, and manual WebGL Aquarium checks at 20000 and 30000 fish.
galpt added a commit to galpt/scx that referenced this pull request Apr 8, 2026
Align the v2.2 branch with upstream review guidance from PR sched-ext#3493 by moving scx_flow from scheds/rust into scheds/experimental. Update the workspace entry and keep the moved package build-clean, including the new hidden --completions support added for compatibility with upstream PR sched-ext#3495.
@htejun htejun enabled auto-merge April 10, 2026 17:25
@sirlucjan
Copy link
Copy Markdown
Collaborator

@kobataiwan Could you rebase on top main? scx_wd40 has been dropped from Cargo.toml/Cargo.lock

@sirlucjan sirlucjan disabled auto-merge April 13, 2026 11:40
Copy link
Copy Markdown
Collaborator

@sirlucjan sirlucjan left a comment

Choose a reason for hiding this comment

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

Could you rebase on top main?

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.

Add subcommands to generate shell completions for Rust schedulers/tools

3 participants