Page 451 - 《软件学报》2025年第12期
P. 451
5832 软件学报 2025 年第 36 卷第 12 期
5. repeat
6. key ← R n .tuple[location].key
7. index ← (Hash(key) OR key)
8. numaid ← get_numa_id(thread k )
9. pht numaid [index] ← R.tuple[location] OR pv numaid [index] ← R.tuple[location].payload
10. i ← i + 1, location ← i + start
11. until i > R_slice_length k
12. end for
13. for i ← 1 to N do
14. for j ← 1 to N do
15. if j = i then
16. continue
17. end if
18. memcpy(pht j + start j , pht i + start j , R_slice_length j )
19. end for
20. end for
21. probe 阶段
22. for thread k in all threads do
23. start ← startoffset k in S 表
24. i ← 1, location ← i + start
25. sum ← 0
26. repeat
27. key ← S.tuple[location].key
28. index ← (Hash(key) OR key)
29. numaid ← get_numa_id(thread k )
30. sum ← sum + (pht numaid [index].payload OR pv numaid [index])
31. until i > S_slice_length k
32. end for
33. return sum
综上所述, 为减少连接操作中跨 NUMA 访问代价, 需要权衡哈希表/向量创建阶段和探测阶段的代价. NUMA
分区内的创建或探测提高了 NUMA 访问的局部性, 但需要付出跨 NUMA 复制、多入口探测或数据预处理代价.
总体性能需要评估总体代价, 连接的综合性能受 NUMA 延迟、哈希/向量探测延迟、cache 效率等多种因素影响.
2.3 NUMA 集群连接实现技术
当跨 NUMA 访问延迟较高时, 可以将 NUMA-aware 存储与 NUMA-conscious 连接相结合, 即将 CPU 平台看
作 NUMA SN (shared nothing, 无共享) 集群架构. 通过存储模型上 NUMA-aware 的优化策略实现 NUMA 计算的
本地化, 通过存储引擎与计算引擎的协同设计 (co-design) 方法提高 NUMA-conscious 连接算法性能. 当两个连接
表均为大表时, 采用基于 PK-FK 的连接键协同分区策略, 按 NUMA 节点数量 radix 基数分区, 将 R 表和 S 表分布
在不同的 NUMA 节点上, 保证 R 表与 S 表相同的连接键在相同的 NUMA 分区, 实现 NUMA 分区上的本地化连
接操作. 当 R 表非常小而 S 表较大时, S 表可以采用 Radix 分区、范围分区、分块分区等方法分布在不同的 NUMA
节点存储. R 表采用全复制方法创建各 NUMA 节点上的数据副本, 实现 NUMA 节点内 S 表数据子集上的并行连

