Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

chcpu: a large cpu-list range runs for hours

未关闭
#620 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 7 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
冷清
技术栈
rust

调研方向

从 chcpu 处理 CPU 列表的入口点开始,复现 issue 中描述的大范围行为。issue 没有指定源文件或测试,并且可接受的上限尚未确定。完成的标准是:对于 --enable 和 --disable,超大的范围都能被及时拒绝,而不会进行数小时的迭代或产生过多诊断信息。

由索引模型根据 Issue 内容生成。

描述

chcpu walks every index in a cpu-list range, and the range is bounded only by the integer type, so it is easy to write one that will not finish. On main (7476fce), x86_64, 24 CPUs online:

$ time chcpu --enable 0-400000 >/dev/null 2>&1
real    0m1.658s

$ timeout 60 chcpu --enable 0-4294967295 >/dev/null 2>&1; echo $?
124

That is roughly 241,000 indices per second, so 0-4294967295 needs about five hours.

It is also loud. Every nonexistent index gets its own line on stderr; for the example above, redirected to a file, that is about 130 GB.

--disable takes the same path, and run as root it will offline the CPUs that do exist before it starts working through the ones that do not.

util-linux 2.42.2 rejects the same input immediately:

$ chcpu --enable 0-4294967295
chcpu: invalid CPU number in CPU list: 0-4294967295
$ echo $?
1

I have not worked out what a sensible upper bound would be. There is more than one defensible choice, so it seemed better to raise this than to suggest one. Happy to implement whichever bound gets settled on.

主要语言
Rust
星标
221
派生
60
平均合并
2 天 19 小时
30 天内合并 PR
10

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

uutils/util-linux 的其他 Issue

查看 uutils/util-linux 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。