DOI QR코드

DOI QR Code

Implementation of Lock-Free shared_ptr and weak_ptr for C++11 multi-thread programming

C++11 멀티스레드 프로그래밍을 위한 Lock-Free shared_ptr와 weak_ptr의 구현

  • Ku, TaeKyun (Dept. of Game Engineering, Korea Polytechnic Univ.) ;
  • Jung, NaiHoon (Dept. of Game & Multimedia Engineering, Korea Polytechnic Univ.)
  • 구태균 (한국산업기술대학교 게임공학과) ;
  • 정내훈 (한국산업기술대학교 게임공학부)
  • Received : 2020.11.11
  • Accepted : 2021.01.29
  • Published : 2021.02.20

Abstract

Multi-thread programming is essential in high performance game programming. But, the widely used C++11 shared_ptr and weak_ptr have malfunction and performance problems in multi-thread environments. In this paper, we propose Lock-Free shared_ptr and weak_ptr, which have higher performance than current error preventing methods. These use a non-blocking algorithm to prevent data race in multi-thread environments. As a result of experimenting in an 8 thread environment, performance has improved up to 7424% in a situation where competition between threads is low, and 3767% in high competition.

고성능이 요구되는 게임 프로그래밍에서 멀티스레드 프로그래밍은 필수이다. 하지만 널리 사용되는 C++11의 shared_ptr와 weak_ptr는 멀티스레드 환경에서 오작동 및 성능 문제를 가지고 있다. 본 논문에서는 기존의 오작동 방지 방법보다 높은 성능을 가지는 Lock-Free shared_ptr와 weak_ptr를 제안한다. 제안하는 두 객체는 논블로킹 알고리즘을 이용하여 멀티스레드에서의 데이터 레이스를 방지하였으며, 8스레드 환경에서 실험한 결과 스레드 사이의 경쟁이 낮은 상황에서 기존의 방법보다 최대 7424% 향상되었고, 경쟁이 높은 상황에서 최대 3767% 향상된 성능을 보여준다.

Keywords

References

  1. Steam Hardware&Software Survey: July 2020, https://store.steampowered.com/hwsurvey/cpus/
  2. INCITS/ISO/IEC, "Information technology-Programming-C++", New York: American National Standards Institute, INCITS/ISO/IEC 14882-2011[2012], pp. 540-565, 2012.
  3. S. Savage, M. Burrows, G. Nelson, P. Sobalvarro, and T. Anderson. "Eraser: A dynamic data race detector for multithreaded programs", ACM Transactions on Computer Systems, 15(4):391-411, 1997. https://doi.org/10.1145/265924.265927
  4. M. Michael, "Hazard pointers: Safe memory reclamation for lock-free objects", IEEE Transactions on Parallel and Distributed Systems, 15 (6): 491-504. 2004. https://doi.org/10.1109/TPDS.2004.8
  5. H. Wen, J. Izraelevitz, W. Cai, H. A. Beadle and M. L. Scott. "Interval-based memory reclamation". ACM SIGPLAN Notices. 2018.
  6. Trevor Alexander Brown, "Reclaiming Memory for lock-free Data Structures: There has to be a Better Way", PODC '15: Proceedings of the 2015 ACM Symposium on Principles of Distributed Computing, July 2015, https://doi.org/10.1145/2767386.2767436
  7. M. Herlihy and N. Shavit. "The Art of Multiprocessor Programming Revised Reprint", Morgan Kaufmann, 2012.
  8. M. Herlihy. "Wait-Free Synchronization". ACM Transactions on Programming anguages and Systems (TOPLAS), 13 (1): 124-149, Jan. 1991.
  9. D. Dechev, P. Pirkelbauer and B. Stroustrup. "Understanding and Effectively Preventing the ABA Problem in Descriptor-based Lock-free Designs". 13th IEEE International Symposium on Object/Component/Service-Oriented Real-Time Distributed Computing, 2010.
  10. Bjarne Stroustrup, "The C++ Programming Language (Fourth Edition)", Addison-Wesley, pp. 990-995, 2013