• morrowind@lemmy.ml
    link
    fedilink
    arrow-up
    54
    ·
    3 months ago

    “I’m writing a recursive method with threads to optimize the CPU usage in a 0.02%” THIS IS A NONSENSICAL STATEMENT MADE BY DERANGED PEOPLE

    I mean this is correct though

    • stingpie@lemmy.world
      link
      fedilink
      arrow-up
      14
      arrow-down
      1
      ·
      3 months ago

      Recursion makes it cheaper to run in the dev’s mind, but more expensive to run on the computer. Subroutines are always slower than a simple jump.

      • pivot_root@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        3 months ago

        Recursion makes it cheaper to run in the dev’s mind, but more expensive to run on the computer.

        Maybe for a Haskell programmer, divide-and-conquer algorithms, or walking trees. But for everything else, I’m skeptical of it being easier to understand than a stack data structure and a loop.

  • cdf12345@lemm.ee
    link
    fedilink
    English
    arrow-up
    54
    arrow-down
    1
    ·
    3 months ago

    moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney

    • No_Support_8363@lemm.ee
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      2 months ago

      Syntax Error, line 1: ‘moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney moneymoneymoneymoneymoneymoneymoney’ is not defined

    • pivot_root@lemmy.world
      link
      fedilink
      arrow-up
      11
      ·
      3 months ago

      Not necessarily. It depends on what you’re optimizing, the impact of the optimizations, the code complexity tradeoffs, and what your goal is.

      Optimizing many tiny pieces of a compiler by 0.02% each? It adds up.

      Optimizing a function called in an O(n2) algorithm by 0.02%? That will be a lot more beneficial than optimizing a function called only once.

      Optimizing some high-level function by dropping into hand-written assembly? No. Just no.

      • magic_lobster_party@fedia.io
        link
        fedilink
        arrow-up
        5
        arrow-down
        1
        ·
        3 months ago

        0.02% means you’re saving a fraction of a second for every hour of runtime. A lot of adding up is required to make it significant enough for anyone to notice.

        Better to spend that time and effort on things that actually bring value. These kind of micro optimizations can also make the code unnecessarily complicated and difficult to work with, which is a hindrance for the optimizations that truly matter.

        • pivot_root@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          edit-2
          3 months ago

          In a single one-off program or something that’s already fast enough to not take more than a few seconds—yeah, the time is spent better elsewhere.

          I did mention for a compiler, specifically, though. They’re CPU bottlenecked with a huge number of people or CI build agents waiting for it to run, which makes it a good candidate for squeezing extra performance out in places where it doesn’t impact maintainability. 0.02% here, 0.15% there, etc etc, and even a 1% total improvement is still a couple extra seconds of not sitting around and waiting per Jenkins build.

          Also keep in mind that adding features or making large changes to a compiler is likely bottlenecked by bureaucracy and committee, so there’s not much else to do.

    • swab148@lemm.ee
      link
      fedilink
      arrow-up
      11
      ·
      3 months ago

      I saw an article last week about a one-liner they were adding to the Linux kernel that would reduce the startup time by .03 seconds, and let me tell you, I was relieved.

        • Dave.@aussie.zone
          link
          fedilink
          arrow-up
          4
          ·
          edit-2
          3 months ago

          There was a series of books in the '80s where a systems programmer gets pulled through a portal into your typical magical world, good vs evil, etc.

          They subsequently look at the magical spells in use and realise they can apply Good Systems Programming Practices™ to it. And thus, with their knowledge of subroutines and parallel processing, they amplify their tiny innate magical abilities up to become a Pretty Good Magician™. So while all the rest of the magicians basically have to construct their spells to execute in a linear fashion, they’re making magical subroutines and utility functions and spawning recursive spells without halting checks and generally causing havoc.

          It’s quite a good allegory for modern times, where a select few build all the magic and the rest just have useful artefacts they use on a day to day basis with no idea how they work

      • jerkface@lemmy.ca
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        14
        ·
        3 months ago
        1. this isn’t an image macro / meme template

        2. this isn’t how the humor of a meme template works. This is the same joke, worse. This is just stealing a joke.

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          14
          ·
          edit-2
          3 months ago

          There’s literally a community somewhere here centered around versions of this template. I’ve personally seen version posted a few other places on Lemmy, too.

          I’ll let others be the judge of if you can steal a joke on the internet, or if they’re some kind of collective property. Maybe it’s worse now but TBH I didn’t get it the first time.