• lol their example is how they were able to hand optimize sum(k, 1->n) into (n+1 choose 2) because they're so darn clever, so everyone else should also be able to hand tune their own code as well as -O2

    I can't wait to see a world where people write spaghetti code where they hand unroll critical loops into 100 iteration long monsters, constant fold everything, inline functions everywhere, and do their own manual register-allocation optimal way of variable sharing, because we can't let the compiler cabal turn us into sheep you know?

    This guy is an absolute arse, I hope they're never put into a position where they get to make real decisions because the dude does not have a single ounce of common sense

    The funny thing is that llvm already optimizes that sum into the closed form

    Even worse, it's all going to get constant folded anyway in both gcc and llvm since he hardcoded 1000000000. So the entire exercise was useless.

    Optimizers can do lots of stuff, like inlining recursive function. So even this

    int summe(int acc, int z) {
        if(!z) return acc;   
        return summe(acc+z, z-1);
    

    is still O(1) in llvm

    The guys with the biggest opinions often get put in charge by managers who feel that they must understand what they're doing to claim it so loud.

    I just had a revelation about how to write the fastest function that will solve any problem:

    int answer_to_any_question() { return 42; }

    Replace all those unoptimized functions in your code with this and it will become blazing fast. Don't worry, its result is always correct.

  • Compiler switches? Is that when I select Debug or Release from the dropdown in Visual Studio?

    Yes, always leave it on Debug. Never know when you might want to attach the debugger to production where the real development work is done.

  • My code doesn’t improve with those flags either… but that’s because the compiler just gives up on my terrible code

  • They're right I myself produce by hand -OO quality python code just by never using docstrings or assert statements, it's not that hard

  • > all programmers

    > would learn how to write properly optimized code

    Is there any occupation in the history of the earth that every single person of that occupation does their job properly?

  • /uj Aside from the various compiler-specific actions that no humab would do, this feels like a generic anti-covenience argument. If a compiler can optimize common code patterns, what world should I not take that opportunity to make the most readable code, so that both human and machine (compiler) can understand it? IIRC the C++ handbook discusses this, pointing out that if you try to out-optimizw the compiler you'll often find yourself with second-rate optimizations because 1. you've made a mess that only you can understand and 2. most programmers probably haven't studied optimizations to tbe extent that a compiler developer has

  • Another reason why we should worship the Gopher language.

  • Wait a minute. My beloved Java compiler has switches to make my code faster? WHY DIDN'T ANYONE TELL ME?

    But seriously, OP is right, if programmers knew how to program the right way there's more than a whole industry that would not be necessary.

    Compilers would become trivially simple to the point of being able to be like a search and replace of "this keyword" to "this block of assembly".

    Another example is programmers should just write secure code. That's it. If all code is secure you don't need all those bothersome Fortify scans, Wiz report bullshit. You don't even need firewalls. You can ever fire all the information security people: "we don't need you, we have secure code now"

    Actually this opened my mind, I'm going to write secure and optimized code from now on. Can someone tell me where I remove those switches in my Python app? I don't seem to find the compiler.

  • oh my god bruh

  • I continue reading...

    anything I can do with a NLE or AviSynth I can do manually by converting the video file to independent PNG or TIFF for every frame and working on each frame one by one.

    https://www.phoronix.com/forums/forum/software/distributions/1537284-ubuntu-provides-more-insight-into-their-decision-not-to-o3-optimize-all-packages?p=1538373#post1538373

    Other person:

    The way how modern LLVM optimisation works is that it knows for this CPU...

    This guy:

    First things first, there is no such thing as AI, not in the way people like you seem to think.

    https://www.phoronix.com/forums/forum/software/distributions/1537284-ubuntu-provides-more-insight-into-their-decision-not-to-o3-optimize-all-packages?p=1538788#post1538788

    I can't post much more of that thread since unsurprisingly Mr. Optimisation Expert feels the need to share his socialjerk opinions with everyone as well, but the way they seamlessly switch from talking about compilers to falsely claiming to have multiple biology degrees to win an argument, to incorrecting each other on climate change, to sharing their unique wisdom on colour spaces is 🧑‍🍳😘🤌. HN users take note, you have been dethroned and phoronix is your new king.

  • fuck you turns your O(n) algo into O(1)

  • /uj Compiler swotches often help optimise code, but compilers do not have good enough analysis (and likely never will) to do major structural optimisations. The classic examples tend to showcase cache residency, where modifying loop order (stride) causes massive gains. Another example is flattening function call stacks, by reducing unnecessary (and expensive) abstraction. So saying that code switches should not be the focus is probably a sane and correct view, and one that should be emphasised more often. Optimisation switches, much like LTO, PGO, and optimisation passes in general, as meant to be the cherry on top and to help get the final 20% of performance back, not make up 80% of performance gains.

    I use compiler swatches to help work out which coding style will look best in my new bathroom.

    /uj

    I do think with languages like Rust we might see compilers start to support structure re-ordering optimizations for access patterns based on runtime profiling.

    The issue with that kind of optimization in C/C++ is there's no way to tell the compiler "Hey this structure is only used within this module, you don't need to keep it ABI stable".

    Compilers already support some limited form of this for things like function vectorization and other SIMD optimizations.

    Okay Mike Acton. Where do you buy your Hawaii shirts?

  • Right. Anything more than Assembly is a crutch.

  • So, I guess don't use any of the big-name compilers because they all will generate extra code in the prologue and epilogue on default settings.

    Hell you need to include debug symbols too because that's a size optimization.

  • sophisticles

    username checks out

  • That’s the silliest thing I read this week so far.