Skip to main content

STAMP-Rust: Language and Performance Comparison to C on Transactional Benchmarks

  • 242 Accesses

Part of the Lecture Notes in Computer Science book series (LNCS,volume 13852)

Abstract

Software Transactional Memory has been used as a synchronization mechanism that is easier to use and compose than locking ones. The mechanisms continued relevance in research and application design motivates considerations regarding safer implementations than existing C libraries. In this paper, we study the impact of the Rust programming language on STM performance and code quality. To facilitate the comparison, we manually translated the STAMP benchmark suite to Rust and also generated a version using a state-of-the-art C-to-Rust transpiler. We find that, while idiomatic implementations using safe Rust are generally slower than both C and transpiled code, they guarantee memory safety and improve code quality.

Keywords

  • Software Transactional Memory
  • Memory Safety
  • Parallelism

This project is partially funded by the EU Horizon 2020 Programme under grant agreement No 957269 (EVEREST).

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    Closures in Rust are comparable to Lambda functions in other languages. They can have arguments and capture variables from the outside context. The implications of the latter are not relevant for this paper.

  2. 2.

    The code base for the original STAMP applications can be found on https://github.com/robert-schmidtke/stm.

  3. 3.

    https://github.com/tud-ccc/stamp-rust.

  4. 4.

    This internally uses an atomically reference-counted pointer. When a new value is written by another transaction, the TVars internal pointer is replaced, not changing the contents of the shared pointer.

References

  1. Anderson, B., et al.: Engineering the servo web browser engine using Rust. In: Proceedings of the 38th International Conference on Software Engineering Companion, pp. 81–89. ACM, Austin Texas (2016). https://doi.org/10.1145/2889160.2889229

  2. Astrauskas, V., Müller, P., Poli, F., Summers, A.J.: Leveraging rust types for modular specification and verification. Proc. ACM Program. Lang. 3(OOPSLA), 1–30 (2019). https://doi.org/10.1145/3360573

  3. Bader, D.A., Madduri, K.: Design and implementation of the HPCS graph analysis benchmark on symmetric multiprocessors. In: Bader, D.A., et al. (eds.) HiPC 2005. LNCS, vol. 3769, pp. 465–476. Springer, Heidelberg (2005). https://doi.org/10.1007/11602569_48

    CrossRef  Google Scholar 

  4. Balasubramanian, A., Baranowski, M.S., Burtsev, A., Panda, A., Rakamarić, Z., Ryzhyk, L.: System programming in rust: beyond safety. In: Proceedings of the 16th Workshop on Hot Topics in Operating Systems, pp. 156–161. ACM, Whistler (2017). https://doi.org/10.1145/3102980.3103006

  5. Beadle, H.A., Cai, W., Wen, H., Scott, M.L.: Nonblocking persistent software transactional memory. In: 2020 IEEE 27th International Conference on High Performance Computing, Data, and Analytics (HiPC), pp. 283–293. IEEE, Pune(2020). https://doi.org/10.1109/HiPC50609.2020.00042, https://ieeexplore.ieee.org/document/9406709/

  6. Bergmann, G.: Software Transactional Memory (2022). https://github.com/Marthog/rust-stm. original-date: 2015-09-15T14:45:14Z

  7. Blandy, J., Orendorff, J.: Programming Rust: Fast, Safe Systems Development. O’Reilly Media, Sebastopol, first edition edn. (2017). oCLC: on1019128949

    Google Scholar 

  8. Boyapati, C., Lee, R., Rinard, M.: Ownership types for safe programming: preventing data races and deadlocks. In: Proceedings of the 17th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications - OOPSLA 2002, p. 211. ACM Press, Seattle(2002). https://doi.org/10.1145/582419.582440, http://portal.acm.org/citation.cfm?doid=582419.582440

  9. Boyapati, C., Salcianu, A., Beebee, W., Rinard, M.: Ownership types for safe region-based memory management in real-time Java. In: Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation - PLDI 2003, p. 324. ACM Press, San Diego (2003). https://doi.org/10.1145/781131.781168, http://portal.acm.org/citation.cfm?doid=781131.781168

  10. Bychkov, A., Nikolskiy, V.: Rust language for supercomputing applications. In: Voevodin, V., Sobolev, S. (eds.) RuSCDays 2021. CCIS, vol. 1510, pp. 391–403. Springer, Cham (2021). https://doi.org/10.1007/978-3-030-92864-3_30

    CrossRef  Google Scholar 

  11. Minh, C. C., Chung, J., Kozyrakis, C., Olukotun, K..: STAMP: Stanford transactional applications for multi-processing. In: 2008 IEEE International Symposium on Workload Characterization, pp. 35–46. IEEE, Seattle (2008). https://doi.org/10.1109/IISWC.2008.4636089, http://ieeexplore.ieee.org/document/4636089/

  12. Contributors, C.: C2Rust (2022). https://github.com/immunant/c2rust. original-date: 2018-04-20T00:05:50Z

  13. Correia, A., Felber, P., Ramalhete, P.: Romulus: efficient algorithms for persistent transactional memory. In: Proceedings of the 30th on Symposium on Parallelism in Algorithms and Architectures, pp. 271–282. ACM, Vienna Austria (2018). https://doi.org/10.1145/3210377.3210392

  14. Dice, D., Shalev, O., Shavit, N.: Transactional locking II. In: Hutchison, D., et al. (eds.) DISC 2006. LNCS, vol. 4167, pp. 194–208. Springer, Heidelberg (2006). https://doi.org/10.1007/11864219_14

    CrossRef  Google Scholar 

  15. Dragojević, A., Harris, T.: STM in the small: trading generality for performance in software transactional memory. In: Proceedings of the 7th ACM European Conference on Computer Systems - EuroSys 2012, p. 1. ACM Press, Bern (2012). https://doi.org/10.1145/2168836.2168838, http://dl.acm.org/citation.cfm?doid=2168836.2168838

  16. Emre, M., Schroeder, R., Dewey, K., Hardekopf, B.: Translating C to safer Rust. Proc. ACM Program. Lang. 5(OOPSLA), 1–29 (2021). https://doi.org/10.1145/3485498

  17. Guerraoui, R., Kapalka, M., Vitek, J.: STMBench7: a benchmark for software transactional memory (2006). http://infoscience.epfl.ch/record/89706

  18. Haagdorens, B., Vermeiren, T., Goossens, M.: Improving the performance of signature-based network intrusion detection sensors by multi-threading. In: Hutchison, D., et al. (eds.) WISA 2004. LNCS, vol. 3325, pp. 188–203. Springer, Heidelberg (2005). https://doi.org/10.1007/978-3-540-31815-6_16

    CrossRef  Google Scholar 

  19. Herlihy, M., Moss, J.E.B.: Transactional memory: architectural support for lock-free data structures. In: Proceedings of the 20th Annual International Symposium on Computer Architecture - ISCA 1993, pp. 289–300. ACM Press, San Diego (1993). https://doi.org/10.1145/165123.165164, http://portal.acm.org/citation.cfm?doid=165123.165164

  20. Holk, E., Pathirage, M., Chauhan, A., Lumsdaine, A., Matsakis, N.D.: GPU programming in rust: implementing high-level abstractions in a systems-level language. In: 2013 IEEE International Symposium on Parallel & Distributed Processing, Workshops and PHD Forum, pp. 315–324. IEEE, Cambridge (2013). https://doi.org/10.1109/IPDPSW.2013.173, http://ieeexplore.ieee.org/document/6650903/

  21. Jung, R., Jourdan, J.H., Krebbers, R., Dreyer, D.: RustBelt: securing the foundations of the Rust programming language. Proc. ACM Program. Lang. 2(POPL), 1–34 (2018). https://doi.org/10.1145/3158154

  22. Kulkarni, M., Pingali, K., Walter, B., Ramanarayanan, G., Bala, K., Chew, L.P.: Optimistic parallelism requires abstractions. In: Proceedings of the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation - PLDI 2007, p. 211. ACM Press, San Diego (2007). https://doi.org/10.1145/1250734.1250759, http://portal.acm.org/citation.cfm?doid=1250734.1250759

  23. Lee, C.Y.: An algorithm for path connections and its applications. IEEE Trans. Electron. Comput. EC 10(3), 346–365 (1961). https://doi.org/10.1109/TEC.1961.5219222

    CrossRef  MathSciNet  Google Scholar 

  24. Levy, A., et al.: Ownership is theft: experiences building an embedded OS in rust. In: Proceedings of the 8th Workshop on Programming Languages and Operating Systems, pp. 21–26. ACM, Monterey California (2015). https://doi.org/10.1145/2818302.2818306

  25. Levy, A., Campbell, B., Ghena, B., Pannuto, P., Dutta, P., Levis, P.: The case for writing a kernel in rust. In: Proceedings of the 8th Asia-Pacific Workshop on Systems, pp. 1–7. ACM, Mumbai (2017). https://doi.org/10.1145/3124680.3124717

  26. Macqueen, J.: Some methods for classification and analysis of multivariate observations. In: In 5-th Berkeley Symposium on Mathematical Statistics and Probability, pp. 281–297 (1967)

    Google Scholar 

  27. Pasqualin, D.P., Diener, M., Du Bois, A.R., Pilla, M.L.: Online sharing-aware thread mapping in software transactional memory. In: 2020 IEEE 32nd International Symposium on Computer Architecture and High Performance Computing (SBAC-PAD), pp. 35–42. IEEE, Porto (2020). https://doi.org/10.1109/SBAC-PAD49847.2020.00016, https://ieeexplore.ieee.org/document/9235046/

  28. Paznikov, A., Smirnov, V., Omelnichenko, A.: Towards efficient implementation of concurrent hash tables and search trees based on software transactional memory. In: 2019 International Multi-Conference on Industrial Engineering and Modern Technologies (FarEastCon), pp. 1–5. IEEE, Vladivostok, (2019). https://doi.org/10.1109/FarEastCon.2019.8934131, https://ieeexplore.ieee.org/document/8934131/

  29. Pop, M., Salzberg, S., Shumway, M.: Genome sequence assembly: algorithms and issues. Computer 35(7), 47–54 (2002). https://doi.org/10.1109/MC.2002.1016901, http://ieeexplore.ieee.org/document/1016901/

  30. Ramalhete, P., Correia, A., Felber, P.: Efficient algorithms for persistent transactional memory. In: Proceedings of the 26th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, pp. 1–15. ACM, Virtual Event Republic of Korea (2021). https://doi.org/10.1145/3437801.3441586

  31. Scott, M.L., Spear, M.F., Dalessandro, L., Marathe, V.J.: Transactions and privatization in delaunay triangulation. In: Proceedings of the Twenty-sixth Annual ACM Symposium on Principles of Distributed Computing - PODC 2007. p. 336. ACM Press, Portland (2007). https://doi.org/10.1145/1281100.1281160, http://dl.acm.org/citation.cfm?doid=1281100.1281160

  32. Takano, K., Oda, T., Kohata, M.: Design of a DSL for converting rust programming language into RTL. In: Barolli, L., Okada, Y., Amato, F. (eds.) EIDWT 2020. LNDECT, vol. 47, pp. 342–350. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-39746-3_36

    CrossRef  Google Scholar 

  33. Tasharofi, S., Dinges, P., Johnson, R.E.: Why do scala developers mix the actor model with other concurrency models? In: Castagna, G. (ed.) ECOOP 2013. LNCS, vol. 7920, pp. 302–326. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-39038-8_13

    CrossRef  Google Scholar 

  34. Xu, Y., Izraelevitz, J., Swanson, S.: Clobber-NVM: log less, re-execute more. In: Proceedings of the 26th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, pp. 346–359. ACM, Virtual USA (2021). https://doi.org/10.1145/3445814.3446730

Download references

Acknowledgements

The authors would like to thank Sebastian Ertel for his valuable input.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Felix Suchert .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Suchert, F., Castrillon, J. (2023). STAMP-Rust: Language and Performance Comparison to C on Transactional Benchmarks. In: Gainaru, A., Zhang, C., Luo, C. (eds) Benchmarking, Measuring, and Optimizing. Bench 2022. Lecture Notes in Computer Science, vol 13852. Springer, Cham. https://doi.org/10.1007/978-3-031-31180-2_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-31180-2_10

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-31179-6

  • Online ISBN: 978-3-031-31180-2

  • eBook Packages: Computer ScienceComputer Science (R0)