• porgamrer@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    2 months ago

    I wouldn’t draw conclusions from random benchmarks like this without at least opening godbolt to see what’s going on.

    It really could be anything. e.g. final may have enabled inlining in more places, but this may have inlined a very uncommon branch in a hot loop, causing way more cache misses when fetching instructions. Writing compilers is hard, and all optimisation passes are using imperfect heuristics.

    Compiling with PGO might make the results more compelling, if that wasn’t already tried.

    • lysdexic@programming.devOPM
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      2 months ago

      As a side note, the final keyword is only tangentially related with inlining. It’s killer feature is removing the need to do pointer dereferencing when calling virtual members of instances of classes that no longer require virtualization.

  • quilan@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 months ago

    I’d be curious to know what the difference in generated assembly was between the two. Would this affect things in a program without virtual classes?

  • Gladaed@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    2 months ago

    It does enable looking down classes duch that noone can accidentally inherit it. This could have benefit when writing non-performance critical Code.