Integer sorts in OLAP engines often run on columns whose cardinality $K$ is much smaller than the array length $N$. After a group-by stage the intermediate key column has $K$ bounded by the number of distinct group keys, and even a column-store scan typically operates on dictionary-encoded categorical fields where $K$ never exceeds a few thousand. A comparison sort on such a column still pays $Θ(N \log N)$ comparisons, and a radix sort still pays $Θ(N \cdot B/b)$ byte passes, irrespective of $K$. This paper describes CAFS, an integer sort that does exploit it on x86-64 with AVX2. The algorithm combines a SIMD bucket sized to one cache line, a Chao1 cardinality estimator over 1024 strided samples (kept in a heap-allocated 40 KB open-addressing table), and an adaptive dispatcher backed by a spill safety guard. The hot loop is branchless and uses AVX2 cmpeq together with movemask and tzcnt to locate the matching lane. We benchmarked CAFS on a full-factorial grid of 58 array sizes $N$ from $10^3$ to $3 \cdot 10^7$ with dense $K$ schedules per $N$, producing 592770 timed runs against pdqsort, IPS4o, vqsort, ska_sort, and std::sort. In the $K \ll N$ band the throughput is 1.7 to 3.1x that of pdqsort, 1.7 to 3.5x IPS4o, and 1.2 to 2.3x vqsort. The operational crossover against pdqsort is at $K \approx 1.3 \cdot 10^5$; against ska_sort, $K \approx 8.14 \cdot 10^5$; against vqsort, $K \approx 6.7 \cdot 10^5$; and against IPS4o the curves only converge near $K = N$. Of the five baselines, only vqsort actually overtakes CAFS once the crossover is passed, which makes the vqsort threshold at $K \approx 6.7 \cdot 10^5$ the binding constraint on the operational range of CAFS.


翻译:OLAP引擎中的整数排序通常作用于基数$K$远小于数组长度$N$的列。分组阶段后,中间键列的$K$受不同分组键数量约束;即便是列存储扫描,也通常对字典编码的分类字段(其$K$不超过数千)进行操作。对此类列进行基于比较的排序仍需执行$Θ(N \log N)$次比较,基数排序仍需进行$Θ(N \cdot B/b)$次字节遍历,无论$K$大小如何。本文描述了CAFS——一种在支持AVX2的x86-64架构上利用该特性的整数排序算法。该算法结合了单缓存行大小的SIMD桶、基于1024步长采样(存储于堆分配的40KB开放寻址表中)的Chao1基数估计器,以及带溢出安全保护的自适应调度器。热循环采用无分支设计,使用AVX2 cmpeq结合movemask与tzcnt定位匹配通道。我们在包含58个数组大小$N$(范围$10^3$至$3 \cdot 10^7$)及每个$N$对应密集$K$日程的全因子网格上对CAFS进行基准测试,产生592770次定时运行,并与pdqsort、IPS4o、vqsort、ska_sort和std::sort进行对比。在$K \ll N$区间,其吞吐量为pdqsort的1.7-3.1倍、IPS4o的1.7-3.5倍、vqsort的1.2-2.3倍。CAFS与pdqsort的操作交叉点在$K \approx 1.3 \cdot 10^5$处;与ska_sort在$K \approx 8.14 \cdot 10^5$处;与vqsort在$K \approx 6.7 \cdot 10^5$处;而与IPS4o的曲线仅在$K = N$附近收敛。在五种基准算法中,仅vqsort在越过交叉点后能实际超越CAFS,这使得vqsort阈值$K \approx 6.7 \cdot 10^5$成为CAFS操作范围的约束边界。

0
下载
关闭预览

相关内容

【干货书】算法新解,540页pdf详解基础算法,中英文版本
专知会员服务
204+阅读 · 2022年1月16日
使用 Canal 实现数据异构
性能与架构
20+阅读 · 2019年3月4日
简述多种降维算法
算法与数学之美
11+阅读 · 2018年9月23日
推荐系统算法合集,满满都是干货(建议收藏)
七月在线实验室
17+阅读 · 2018年7月23日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
并行算法演进,从MapReduce到MPI
凡人机器学习
10+阅读 · 2017年11月5日
国家自然科学基金
1+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 6月1日
VIP会员
最新内容
俄乌无人机战争的六大启示
专知会员服务
9+阅读 · 8月3日
《无人机空中监控:通信实验洞察》
专知会员服务
6+阅读 · 8月3日
从采集到决策:美军视角下的战术情报范式重构
《履带式无人地面战车技术发展现状》
专知会员服务
6+阅读 · 8月2日
《无人机脆弱性利用:网络空间力量的新域》
专知会员服务
8+阅读 · 8月1日
美空军如何将人工智能从战场部署至后方机关
专知会员服务
14+阅读 · 7月31日
相关VIP内容
【干货书】算法新解,540页pdf详解基础算法,中英文版本
专知会员服务
204+阅读 · 2022年1月16日
相关资讯
使用 Canal 实现数据异构
性能与架构
20+阅读 · 2019年3月4日
简述多种降维算法
算法与数学之美
11+阅读 · 2018年9月23日
推荐系统算法合集,满满都是干货(建议收藏)
七月在线实验室
17+阅读 · 2018年7月23日
R语言之数据分析高级方法「时间序列」
R语言中文社区
17+阅读 · 2018年4月24日
并行算法演进,从MapReduce到MPI
凡人机器学习
10+阅读 · 2017年11月5日
相关基金
国家自然科学基金
1+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
9+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员