‹ BackHN Continuity

Thread

Performance Improvements in .NET 11

349 points · 112 comments · soheilpro

  1. AlexErrant · · focus · HN ↗
    Dumb Q: should a non-systems-language dev know/read assembly?

        ; Arm64
        --- .NET 10
        +++ .NET 11
        @@ -13,8 +13,6 @@
                    ble     G_M000_IG04
    
        G_M000_IG03:
        -            cmp     w1, w2
        -            bhs     G_M000_IG05
                    str     wzr, [x0, w1, UXTW #2]
    
        G_M000_IG04:
        @@ -25,4 +23,4 @@
                    bl      CORINFO_HELP_RNGCHKFAIL
                    brk     #0
    
        -; Total bytes of code 68
        +; Total bytes of code 60
    
    I know C#/F# decently well, but is there any reason to actually pull out the ol textbooks and learn wtf the above is saying?
    1. louthy · · focus · HN ↗
      You don’t need to, but if you ever want to really optimise some code, understanding what it turns into on the target CPU really helps. Especially if you know the implications for any particular instruction (cost of memory access, potential branch prediction misses, etc)

      The three* letter mnemonics are usually pretty easy to decode, even if you don’t know the architecture: anything beginning with ‘B’ will be branch, so ‘ble’ is branch if less than or equal. L and S based mnemonics are unusually Load and Store from and to memory. After that it’s understanding the stack and registers and you’re pretty much good to go.

      Everything in assembly is loading something from memory into registers doing something basic with those registers, like add/divide/etc and then putting the result back into memory or using the result to make a decision to jump to processing instructions from another place in memory.

      Most devs won’t ever need to know this stuff, but as someone who grew up with computers that could barely do anything without grinding to a halt (8bit computer, 2mhz processor, 32kb of RAM, 20kb of which is for the screen), knowing this stuff was essential; however I still find this stuff useful today, even with my C# work.

      I am a bit of a performance tuning nerd though, so…

      [*] or more

      1. masfuerte · · focus · HN ↗
        > anything beginning with ‘B’ will be branch

        Usually. BRK is a breakpoint.

        1. louthy · · focus · HN ↗
          True, there are of course exceptions! :D

          (Also, other architectures might use J for 'Jump' rather than 'Branch'). I don't make the rules ;)

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.