[normalized Sound] A deep dive into dispatching techniques - Jonathan Müller - Meeting C++ 2022

Sdílet
Vložit
  • čas přidán 24. 01. 2023
  • A deep dive into dispatching techniques - Jonathan Müller - Meeting C++ 2022
    Slides: slides.meetingcpp.com
    Survey: survey.meetingcpp.com
    At the core of an interpreter is a loop that iterates over instructions and executes them in order. This requires dispatching: based on the current instruction, it needs to select different code. A fast interpreter requires a fast instruction dispatcher, but so does everything else that needs to switch over a fixed set of different options.
    This talk investigates at various dispatching techniques, from virtual functions over simple switch statements to jump tables. We'll look at performance analysis tools, benchmarks, and lots and lots of assembly code, in order to learn ways to trick the compiler into generating the assembly code that we actually want.
    Even if you don't need to actually write an interpreter or other dispatcher, you will learn a lot about optimization.
  • Věda a technologie

Komentáře • 6

  • @Roibarkan
    @Roibarkan Před rokem +2

    Great talk!! I have a sense that the performance issue you saw for call-threading was “branch target” related (similar to what was noted for the laptop case) which was mitigated in the token-threading approach by the multiple branches that could be separately learned. Perhaps unrolling the loop in the call-threading approach could have helped. I also wonder if the compiler flag “-march=native” could have generated better (and different) switch-statement code for the different platforms

  • @Roibarkan
    @Roibarkan Před rokem +2

    20:15 I suspect the goto statement in slide 43 should only have the label location, without “argument passing” in parentheses.

  • @sargijapunk
    @sargijapunk Před rokem +2

    Great talk, but please talk at a slower pace, you are almost impossible to understand at times.

  • @Roibarkan
    @Roibarkan Před rokem +1

    34:20 I wonder if the [[unlikely]] attribute could have made a difference here

    • @foonathan
      @foonathan Před rokem +2

      It doesn't help in the case where you don't tail call the "slow part", the compiler doesn't extract that in a separate function for you. If you already applied the optimization, it can further help, yes.