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

The ack blocks the thread that ran the task

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
django, python, redis

调研方向

Start at the consumer loop where fetch, execute, and acknowledge are serialized, and compare its stop-and-join handling with the prefetcher. Validate the design on a quiet machine, covering writer shutdown, ack failure ordering, durability trade-offs, and the latency-bound benchmark target.

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

描述

perf real

Each task acknowledgement sits on the critical path of the consumer. The loop fetches a task, runs it, calls acknowledge(), and starts again. Prefetching removed the fetch round trip from that path. The ack still blocks the thread that just ran the task.

Measurement (20,000 echo tasks, one process, one thread, prefetch 128, loaded machine): the ack uses 63 µs of client CPU and 97 µs blocked on the response for each task. The per-task wall time is 318 µs. The ack is thus about half of the loop. The blocked part is pure latency that the worker can use for the next task.

Proposal

Give finished results to an ack writer instead of an inline ack. The consumer puts the completed TaskResult in a queue and immediately picks up the next task. A dedicated thread serializes and acknowledges the results. Prefetch already hides the fetch round trip. This change hides the other one.

Trade-offs that need a decision

  • The durability window becomes slightly wider. A crash between execution and ack already loses the ack today. A queue between the two extends that window by one task. The lease reaper covers the task, but the result of a completed task can be lost. Today the result is written immediately.
  • Shutdown order. The writer must drain before the process exits. It needs the same stop-and-join handling as the prefetcher.
  • It hides latency but does not remove work. The CPU cost stays. On a CPU-saturated host or with several worker threads that already overlap their acks, the gain is smaller. The win applies to latency-bound configurations with one thread.
  • Ordering. Acks do not need an order today. A queue raises the question of what occurs when one ack fails and the next ack succeeds.

Why this issue exists

This is the largest remaining structural item. Prefetch already amortizes the fetch side (the acquire path decreases from a full round trip for each task to 0.008 calls for each task at prefetch 128). The ack is the only per-task round trip that remains. The other option is server-side work, which has a bound. Redis uses 20 to 54 µs for each task, depending on the load of the instance. That is about a tenth to a third of the loop, so the scripts alone cannot close the gap.

Found while validating per-task performance claims. This item needs a design decision, not a patch. The absolute microseconds come from a loaded machine. Measure again on a quiet machine before you commit to a target.

主要语言
Python
星标
19
派生
1
平均合并
14 小时 37 分钟
30 天内合并 PR
22

环境准备

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

从这里开始

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

codingjoe/threadmill 的其他 Issue

查看 codingjoe/threadmill 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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