engine: 新增 --lock-tag,允许同一 tier 的第二个 runner 拿自己的锁并行

锁本来是按 tier 的(run-x265.lock),这是防两个编码器抢同一单元的正确默认值;
但当单进程吃不满机器时(720p x265 = wpp(12 rows),pools=22 实测 165 fps、整机 73%),
控制面要拆核并行两个 x265:第二个 runner 必须有自己的锁名,否则永远退避在 engine lock busy。
--lock-tag x265-w2 → run-x265-w2.lock,留空 = 旧行为。references/pitfalls.md 补第 13 条。
This commit is contained in:
2026-10-12 17:17:50 +08:00
parent 0287dcd2f6
commit c45cdda983
2 changed files with 21 additions and 1 deletions
+12
View File
@@ -39,3 +39,15 @@
Rule: treat `MemoryError` as a sibling of `OSError` in **every** share helper, and have the
per-item handler delete `<dest>.new.mp4` **unconditionally** - never gate that delete on
`os.path.exists()`, whose answer on this share can be stale.
## 13. 同一 tier 想并发:必须给第二个 runner 自己的锁(2026-10-12)
`--tier x265` 的锁是**每档一把**(`run-x265.lock`),这是防止两个编码器抢同一个单元/输出的正确
默认值。但当一个 x265 进程吃不饱机器时(720p 的 x265 banner 是 `frame threads 3 / wpp(12 rows)`,
实测 `pools=22` 只有 165 fps、整机 73% 忙),控制面会把核拆成两组、让两个 x265 **并行**跑不同文件 ——
这时第二个 runner 拿同一把锁就会一直退避在 "engine lock busy"。
`--lock-tag <tag>` 就是给它的出口:锁文件名变成 `run-<tag>.lock`(留空 = 沿用 tier 名,
行为与以前完全一致)。控制面给 cpu2/cpu3 分别传 `--lock-tag x265-w2` / `x265-w3`。
两个 runner 处理的是**不同文件**,每个 item 的暂存产物都带 PID+tag,所以不会互相覆盖;
`--affinity-mask` 用来让两份负载落在不重叠的核上(实测 2×10 线程 = 244 fps vs 单进程 22 线程 = 165 fps,+48%)。