期刊文献+

基于优化的CAS算法实现线程安全的HashMap 被引量:2

Thread-safe HashMap Structure Based on Optimized CAS Algorithm
下载PDF
导出
摘要 HashMap内存数据结构存在相当广泛的应用场景,通过Hash函数的Key直接获取对应的值,能够确保搜索的时间复杂度为O(1)。HashMap数据结构存在哈希冲突与线程安全问题,悲观锁机制实现线程安全的方法存在很大的性能开销。本文提出了基于优化的CAS算法,实现线程安全的哈希映射数据结构,内部采用数组、链表和红黑树实现了高并发环境下读写操作。通过增加版本戳避免CAS算法的ABA问题,CAS算法实现的无锁方式避免了锁竞争的开销,使用红黑树来优化链表,确保大规模数据集的检索时间复杂度保持O(logn)。支持多线程扩容操作,在执行效率方面有良好的表现。通过大规模的并发压力测试,验证了该数据结构在性能上有稳定的提升。 HashMap data structure is widely used in the industry. The Hash function directly reads the corresponding value through the input key, which ensures that the time complexity of the search algorithm is O(1). There are hash conflicts and thread safety issues in the HashMap. The pessimistic locking mechanism implements thread safety methods with great performance overhead. This paper proposes a HashMap structure based on optimized CAS algorithm to implement thread safety. The internal use of arrays, linked lists, red-black trees. Achieves read and write efficiency in high-concurrency environments. The CAS algorithm implements lock-free mode to avoid the overhead of lock competition. Red-black trees are used to optimize the linked list, ensuring that the time complexity remains O(logn) when the data set is large. Supports multi-thread expansion operations in a lock-free state, and concurrent processing reduces the time overhead of capacity expansion. Through large-scale concurrent testing, it is verified that the data structure has a stable improvement in performance.
作者 吴恩慈 WU En-ci(Shanghai Qiyu Information Technology Co., Ltd., Shanghai 200120)
出处 《软件》 2019年第6期185-190,共6页 Software
关键词 无锁机制 分段锁 CAS算法优化 红黑树 线程安全 Lock-free Segment Lock Optimized CAS Red-black Tree Thread-safe
  • 相关文献

参考文献12

二级参考文献94

  • 1赵艳红,费洪晓.一个基于改进的反序分词词典的中文分词算法[J].深圳职业技术学院学报,2004,3(4):28-31. 被引量:2
  • 2罗智勇,宋柔.现代汉语通用分词系统中歧义切分的实用技术[J].计算机研究与发展,2006,43(6):1122-1128. 被引量:19
  • 3张李义,李亚子.基于反序词典的中文逆向最大匹配分词系统设计[J].现代图书情报技术,2006(8):42-45. 被引量:12
  • 4Chai L, Gao Q, Panda D K. Understanding the impact of multi core architecture in cluster computing: A case study with InteI Dual Core system//Proceedings of the CCGrid'07. Rio de Janeiro, Brazil, 2007:471 -478.
  • 5Tang H, Shen K, Yang T. Program transformation and runtime support for threaded MPI execution on shared memory machines. ACM Transactions on Programming Languages and Systems, 2000, 22(4): 673- 700.
  • 6Demaine E D. A threads only MPI implementation for the development of parallel programs//Proceedings of the Ilth In ternational Symposium on High Performance Computing Sys terns. Winnipeg, Manitoba, Canada, 1997:153-163.
  • 7Prakash S, Bagrodia R. MPI -SIM: Using parallel simulation to evaluate MPI programs//Proceedings of the Winter Simula tion. Los Aamitos, CA, USA, 1998:467- 474.
  • 8Saini S, Naraikin A et al. Early performance evaluation of a Nehalem" cluster using scientific and engineering applications//Proceedings of the SC'09. New York, USA, 2009, Article 21,12 pages.
  • 9Diaz Martin J C, Rico Gallego J A et al. An MPI -1 corn pliant thread based implementation//Proceedings o{ the EuroPVM/ MP1 2009. Berlin, Heidelberg, 2009:327- 328.
  • 10Sade Y, Sagiv S, Shaham R. Optimizing C multithreaded memory management using thread local storage//Proceedings of the CC'05. Berlin, Heidelberg, 2005:137-155.

共引文献72

同被引文献10

引证文献2

二级引证文献2

相关作者

内容加载中请稍等...

相关机构

内容加载中请稍等...

相关主题

内容加载中请稍等...

浏览历史

内容加载中请稍等...
;
使用帮助 返回顶部