对比面向数据与面向对象设计,发现前者在多线程下更省缓存、更快。
Impact of Data-Oriented and Object-Oriented Design on Performance and Cache Utilization with Artificial Intelligence Algorithms in Multi-Threaded CPUs
- 用A*算法四版本对比,分单双线程测试数据布局影响
- 多线程时面向数据设计缓存命中率更高,系统调用更少
- 小任务中多线程开销大,单线程反而更快,适合大规模AI场景
多核CPU与主存间性能差距日益扩大,亟需硬件感知的软件设计范式。本研究全面分析了面向数据设计(DOD)与传统面向对象设计(OOD)在多线程环境下的性能表现,重点关注缓存利用率和效率。我们实现了A*搜索算法的四种版本:单线程OOD(ST-OOD)、单线程DOD(ST-DOD)、多线程OOD(MT-OOD)和多线程DOD(MT-DOD)。评估指标包括执行时间、内存占用和CPU缓存未命中次数。多线程测试显示,DOD实现具有显著性能优势,执行更快,系统调用和缓存未命中更少。尽管OOD在内存使用或缓存未命中率百分比上偶有微弱优势,但DOD在数据密集型操作中的效率更为突出。此外,对于像A*这样细粒度的任务,线程管理开销导致单线程版本在两种设计下均显著优于多线程版本。结论表明,即使在简单算法中性能差异看似细微,DOD在关键指标上的持续优势凸显其基础架构优越性,建议用于复杂、大规模的AI与并行计算任务以最大化硬件效率。
原文摘要 · Abstract (English)
The growing performance gap between multi-core CPUs and main memory necessitates hardware-aware software design paradigms. This study provides a comprehensive performance analysis of Data Oriented Design (DOD) versus the traditional Object-Oriented Design (OOD), focusing on cache utilization and efficiency in multi-threaded environments. We developed and compared four distinct versions of the A* search algorithm: single-threaded OOD (ST-OOD), single-threaded DOD (ST-DOD), multi-threaded OOD (MT-OOD), and multi-threaded DOD (MT-DOD). The evaluation was based on metrics including execution time, memory usage, and CPU cache misses. In multi-threaded tests, the DOD implementation demonstrated considerable performance gains, with faster execution times and a lower number of raw system calls and cache misses. While OOD occasionally showed marginal advantages in memory usage or percentage-based cache miss rates, DOD's efficiency in data-intensive operations was more evident. Furthermore, our findings reveal that for a fine-grained task like the A* algorithm, the overhead associated with thread management led to single-threaded versions significantly outperforming their multi-threaded counterparts in both paradigms. We conclude that even when performance differences appear subtle in simple algorithms, the consistent advantages of DOD in critical metrics highlight its foundational architectural superiority, suggesting it is a more effective approach for maximizing hardware efficiency in complex, large-scale AI and parallel computing tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。