An Empirical Study on C++ Concurrency Constructs

Nowadays concurrent programming is in large demand. The inherent support for concurrency is therefore increasingly important in programming languages. As for C++, an abundance of standard concurrency constructs have been supported since C++11. However, to date there is little work investigating how these constructs are actually used in developing real software. In this paper, we perform an empirical study to investigate the adoption of C++ concurrency constructs in open-source applications, with the goal to provide insightful information for practitioners to use concurrency constructs efficiently. To this end, we analyze 127 open-source applications that adopt C++ concurrency constructs, comprising 34 million lines of C++ code, to conduct the experiment. The experimental results show that: (1) to implement concurrency code, thread-based constructs are significantly more often used than atomics-based constructs and task-based constructs; (2) to manage synchronization, lock-based constructs are significantly more often used than lock-free constructs and blocking constructs; (3) among the key thread-based constructs and task-based constructs (i.e. mutex, promise, and future), there is not a construct significantly more commonly misused than others; (4) small-size applications introduce concurrency constructs more intensively and more quickly than medium-size applications and large-size applications; and (5) an increasing use of standard concurrency constructs does not result in a substantially decreasing use of unstandardized concurrency constructs. Based on these findings, we make actionable suggestions for language designers, developers, and novices to assist them in designing and using C++ concurrency constructs.

[1]  Akif Günes Koru,et al.  Comparing high-change modules and modules with the highest measurement values in two large-scale open-source products , 2005, IEEE Transactions on Software Engineering.

[2]  Premkumar T. Devanbu,et al.  Assert Use in GitHub Projects , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[3]  Peter Sewell,et al.  Mathematizing C++ concurrency , 2011, POPL '11.

[4]  Bertrand Meyer,et al.  Benchmarking Usability and Performance of Multicore Languages , 2013, 2013 ACM / IEEE International Symposium on Empirical Software Engineering and Measurement.

[5]  Bertrand Meyer,et al.  Design of an empirical study for comparing the usability of concurrent programming languages , 2013, Inf. Softw. Technol..

[6]  Bjarne Stroustrup,et al.  C++ Programming Language , 1986, IEEE Softw..

[7]  Martin P. Robillard,et al.  A field study of API learning obstacles , 2011, Empirical Software Engineering.

[8]  Audris Mockus,et al.  An empirical study of goto in C code from GitHub repositories , 2015, ESEC/SIGSOFT FSE.

[9]  Yuming Zhou,et al.  An empirical study on the adoption of C++ templates: Library templates versus user defined templates , 2014, SEKE.

[10]  Brian Demsky,et al.  CDSchecker: checking concurrent data structures written with C/C++ atomics , 2013, OOPSLA.

[11]  Gustavo Pinto,et al.  A large-scale study on the usage of Java's concurrent programming constructs , 2015, J. Syst. Softw..

[12]  Danny Dig,et al.  How do developers use parallel libraries? , 2012, SIGSOFT FSE.

[13]  Lionel C. Briand,et al.  A systematic and comprehensive investigation of methods to build and evaluate fault prediction models , 2010, J. Syst. Softw..

[14]  Emerson R. Murphy-Hill,et al.  Adoption and use of Java generics , 2012, Empirical Software Engineering.

[15]  Marieke Huisman,et al.  How Do Developers Use APIs? A Case Study in Concurrency , 2013, 2013 18th International Conference on Engineering of Complex Computer Systems.

[16]  Gustavo Pinto,et al.  Are Java programmers transitioning to multicore?: a large scale study of java FLOSS , 2011, SPLASH Workshops.

[17]  Shan Lu,et al.  What change history tells us about thread synchronization , 2015, ESEC/SIGSOFT FSE.

[18]  Yuming Zhou,et al.  Examining the Potentially Confounding Effect of Class Size on the Associations between Object-Oriented Metrics and Change-Proneness , 2009, IEEE Transactions on Software Engineering.

[19]  Susmit Sarkar,et al.  Nitpicking c++ concurrency , 2011, PPDP.