Skip to main content

Branchless Search Programs

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 7933))

Abstract

It was reported in a study by Brodal and Moruz that, due to branch mispredictions, skewed search trees may perform better than perfectly balanced search trees. In this paper we take the search procedures under microscopic examination, and show that perfectly balanced search trees—when programmed carefully—are better than skewed search trees. As in the previous study, we only focus on the static case. We demonstrate that, by decoupling element comparisons from conditional branches and by writing branchless code in general, harmful effects caused by branch mispredictions can be avoided. Being able to store perfectly balanced search trees implicitly, such trees get a further advantage over skewed search trees following an improved cache behaviour.

This is a preview of subscription content, log in via an 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 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

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Andersson, A.: A note on searching in a binary search tree. Software Pract. Exper. 21(10), 1125–1128 (1991)

    Article  Google Scholar 

  2. Bender, M.A., Demaine, E.D., Farach-Colton, M.: Efficient tree layout in a multilevel memory hierarchy. In: Möhring, R.H., Raman, R. (eds.) ESA 2002. LNCS, vol. 2461, pp. 165–173. Springer, Heidelberg (2002)

    Chapter  Google Scholar 

  3. Bentley, J.: Programming Pearls, 2nd edn. Addison-Wesley, Reading (2000)

    Google Scholar 

  4. Brodal, G.S., Moruz, G.: Skewed binary search trees. In: Azar, Y., Erlebach, T. (eds.) ESA 2006. LNCS, vol. 4168, pp. 708–719. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  5. Chen, S., Gibbons, P.B., Mowry, T.C., Valentin, G.: Fractal prefetching B + -trees: Optimizing both cache and disk performance. In: SIGMOD 2002, pp. 157–168. ACM, New York (2002)

    Google Scholar 

  6. Elmasry, A., Katajainen, J.: Lean programs, branch mispredictions, and sorting. In: Kranakis, E., Krizanc, D., Luccio, F. (eds.) FUN 2012. LNCS, vol. 7288, pp. 119–130. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  7. Elmasry, A., Katajainen, J., Stenmark, M.: Branch mispredictions don’t affect mergesort. In: Klasing, R. (ed.) SEA 2012. LNCS, vol. 7276, pp. 160–171. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  8. Guibas, L.J., Sedgewick, R.: A dichromatic framework for balanced trees. In: FOCS 1978, pp. 8–21. IEEE Computer Society, Los Alamitos (1978)

    Google Scholar 

  9. Jensen, C., Katajainen, J., Vitale, F.: Experimental evaluation of local heaps. CPH STL Report 2006-1, Department of Computer Science, University of Copenhagen, Copenhagen (2006)

    Google Scholar 

  10. Johnson, D.B.: Priority queues with update and finding minimum spanning trees. Inform. Process. Lett. 4(3), 53–57 (1975)

    Article  MATH  Google Scholar 

  11. Kaligosi, K., Sanders, P.: How branch mispredictions affect quicksort. In: Azar, Y., Erlebach, T. (eds.) ESA 2006. LNCS, vol. 4168, pp. 780–791. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  12. Katajainen, J.: Branchless search programs: Electronic appendix. CPH STL Report 2012-1, Department of Computer Science, University of Copenhagen, Copenhagen (2012)

    Google Scholar 

  13. Knuth, D.E.: Sorting and Searching, The Art of Computer Programming, 2nd edn., vol. 3. Addison-Wesley, Reading (1998)

    Google Scholar 

  14. Oksanen, K., Malmi, L.: Memory reference locality and periodic relocation in main memory search trees. In: 5th Hellenic Conference on Informatics, pp. 679–687. Greek Computer Society, Athens (1995)

    Google Scholar 

  15. Patterson, D.A., Hennessy, J.L.: Computer Organization and Design: The Hardware/Software Interface, revised 4th edn. Morgan Kaufmann, Waltham (2012)

    Google Scholar 

  16. Prokop, H.: Cache-oblivious algorithms. Master’s Thesis, Department of Electrical Engineering and Computer Science, Massachusetts Institute of Technology, Cambridge (1999)

    Google Scholar 

  17. Rahman, N., Cole, R., Raman, R.: Optimised predecessor data structures for internal memory. In: Brodal, G.S., Frigioni, D., Marchetti-Spaccamela, A. (eds.) WAE 2001. LNCS, vol. 2141, pp. 67–78. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  18. Saikkonen, R., Soisalon-Soininen, E.: Cache-sensitive memory layout for binary trees. In: Ausiello, G., Karhumäki, J., Mauri, G., Ong, L. (eds.) IFIP TCS 2008. IFIP, vol. 273, pp. 241–255. Springer, Boston (2008)

    Google Scholar 

  19. Williams, J.W.J.: Algorithm 232: Heapsort. Commun. ACM 7(6), 347–348 (1964)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Elmasry, A., Katajainen, J. (2013). Branchless Search Programs. In: Bonifaci, V., Demetrescu, C., Marchetti-Spaccamela, A. (eds) Experimental Algorithms. SEA 2013. Lecture Notes in Computer Science, vol 7933. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-38527-8_13

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-38527-8_13

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-38526-1

  • Online ISBN: 978-3-642-38527-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics