关于「只追加黑板:读路径无锁、哈希去重与订阅成本」,《并发拓扑耦合与黑板复用》给出的定量结论是什么?
结论:第四章说明只追加黑板为什么读路径不必取锁,示意参数下最优订阅比例约 0.7。
数据口径:书中参数为示意,数据为合成,全部计算由书中程序生成;本书是非个人化经营建议,不提供任何加速比承诺。 第一章说明峰值从何而来,示意参数下峰值在 6.78 个窗口附近。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.7
| A. coupling sweep, 2 min per new note read | |
| c avoided failures read min net min/node-week | |
| 0.0 | 0 1,560 0 0.0 |
| 0.1 | 648 912 1,944 112.2 |
| 0.2 | 810 750 3,216 135.2 |
| 0.3 | 921 639 4,404 148.9 |
| 0.4 | 964 596 5,460 150.4 |
| 0.5 | 1,014 546 6,468 153.5 |
| 0.6 | 1,063 497 7,452 156.7 |
| 0.7 | 1,094 466 8,376 156.7 |
| 0.8 | 1,128 432 9,420 156.5 |
| 0.9 | 1,148 412 10,224 155.2 |
| 1.0 | 1,158 402 11,064 151.8 |
| B. best c | 0.7, net 156.7 min per node-week |
| C. best c when reading costs more or less | |
| 1 min per note: best c | 0.8, net 170.7 |
| 2 min per note: best c | 0.7, net 156.7 |
| 4 min per note: best c | 0.6, net 132.9 |
| 8 min per note: best c | 0.3, net 100.2 |
查看完整验算程序
# Chapter 4. p42: reuse gain saturates, read cost grows, net gain peaks.
# 6 nodes, 26 weeks, 40 topics with Zipf-like relevance (exponent
# 0.5), 400 distinct pitfalls spread over topics by relevance. Each
# node meets 10 pitfall draws a week. Coupling c = subscribed topics /
# all topics; a node subscribes to the most relevant topics first. A
# draw is avoided if the pitfall is already on the board and its topic
# is subscribed; otherwise the node fails once and appends a note.
# Each week a node pays 1 min per subscribed topic plus 2 min for every
# new note in those topics; a failure costs 30 min. All illustrative.
import math
import random
NODES, WEEKS, TOPICS, PITS, DRAWS = 6, 26, 40, 400, 10
FAIL_MIN, TOPIC_MIN = 30.0, 1.0
def setup(rng):
w = [1.0 / (k + 1) ** 0.5 for k in range(TOPICS)]
topic_of = [rng.choices(range(TOPICS), w)[0] for _ in range(PITS)]
pw = [w[t] for t in topic_of]
draws = [[[rng.choices(range(PITS), pw)[0] for _ in range(DRAWS)]
for _ in range(NODES)] for _ in range(WEEKS)]
return topic_of, draws
def run(c, topic_of, draws, entry_min):
subs = set(range(int(round(c * TOPICS))))
board, avoided, fails, reads = set(), 0, 0, []
for week in draws:
new = []
for node in week:
for pit in node:
if pit in board and topic_of[pit] in subs:
avoided += 1
else:
fails += 1
if pit not in board:
new.append(pit)
board.update(new)
seen = 0
for pit in new:
if topic_of[pit] in subs:
seen += 1
for _ in range(NODES):
reads.append(TOPIC_MIN * len(subs) + entry_min * seen)
read_min = math.fsum(reads)
net = avoided * FAIL_MIN - read_min
return avoided, fails, read_min, net / (NODES * WEEKS)
if __name__ == "__main__":
topic_of, draws = setup(random.Random(41142))
grid = [k / 10 for k in range(11)]
print("A. coupling sweep, 2 min per new note read")
print(" c avoided failures read min net min/node-week")
best = None
for c in grid:
a, f, r, net = run(c, topic_of, draws, 2.0)
print(" {:.1f} {:>7,} {:>8,} {:>8,.0f} {:>17.1f}".format(
c, a, f, r, net))
if best is None or net > best[1]:
best = (c, net)
print("B. best c = {:.1f}, net {:.1f} min per node-week".format(*best))
print("C. best c when reading costs more or less")
for em in (1.0, 2.0, 4.0, 8.0):
res = [(run(c, topic_of, draws, em)[3], c) for c in grid]
top = max(res)
print(" {:.0f} min per note: best c = {:.1f}, net {:.1f}".format(
em, top[1], top[0]))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《多核并发操作拓扑耦合、共享黑板无锁通信与跨节点涌现增益母典》第 4 章「只追加黑板:读路径无锁、哈希去重与订阅成本」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-411 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026411,
author = {Fan, Yafu},
title = {Topological Coupling of Concurrent Multi-Core Operations: Lock-Free Blackboard Signalling and Cross-Node Emergent Gains},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}