Hope y'all enjoyed the video! ❤️ What's your favourite strategy to optimize your code?
@yerngames3 жыл бұрын
Make sure it works first is the best way to do it 😂
@oamioxmocliox80823 жыл бұрын
;)
@vonatok3 жыл бұрын
compiler switch /O2
@literallynull3 жыл бұрын
What do I use? inline keyword , use as small class/struct fields as possible, shitton of ^=,&=, |=, operators, r-value references(for move semantics purposes only)... these guys are actually the 4 hourseman of a terrible programmer(I consider myself as one of them), just don't use them, pretend they do not even exist or smth.
@Шокирующиеновости-д2с3 жыл бұрын
@@literallynull just make sure theres more nullptrs
@SkullCloud113 жыл бұрын
Easy steps to make code run faster: 1) Don't trust compiler 2) write your own assembly 3) Don't trust OS 4) Write your own OS 5) Don't trust processor's BPU and OoOE 6) roll your own processor 7) redefine the universe 8)
Optmization is easy, just give your customers a top tier pc.
@CasperA3 жыл бұрын
The only way.
@comradepeter873 жыл бұрын
Ngl, a subscription model, or consoles-as-a-service where I can get consoles for certain parts of the year (holidays) will be a blessing. Can fill a certain niche.
@literallynull3 жыл бұрын
Laughs in Yandere Dev
@techzone9133 жыл бұрын
Yeah its was easy until it become challenge to older hardware and that problematic
@karlchiasson49463 жыл бұрын
So you have chosen brute force.
@Mampinator3 жыл бұрын
I found your channel in my recommendations today and I really like all of the devlogs for Hazel. I love the physics demos and the editor ui a lot.
@Zvend3 жыл бұрын
welcome to the best C++ Community
@nathanlloyd7743 жыл бұрын
Empty files usually execute faster than files that contain anything written by me
@Dustyy013 жыл бұрын
Best intro ever 😂
@oamioxmocliox80823 жыл бұрын
;)
@Codepeats3 жыл бұрын
👍👌
@GreenSkyGaming3 жыл бұрын
Mein Keks QwQ
@Dustyy013 жыл бұрын
@@GreenSkyGaming nee
@xeridea3 жыл бұрын
Using 1 thread on a quad core is like driving a car with 3 dead cylinders.
@bluesillybeard3 жыл бұрын
that is a really good analogy
@chlorobyte_projects3 жыл бұрын
Using 1 thread on a multi core is like typing with 1 finger.
@xeridea3 жыл бұрын
@@chlorobyte_projects I had a high school teacher who typed with one hand without looking.
@Warwipf3 жыл бұрын
@SomeoneRandom Typing with two hands without looking is easy, everyone does that. Writing with just one hand without looking is pretty impressive lol
@Beatsbasteln3 жыл бұрын
my projects weren't nearly as big as hazle yet but until now i was always able to tell which methods take the longest by just looking at them. sometimes i deliberately write non-performant code, because it's more readable and i just wanna get stuff done, but then i leave a comment so i remember to improve it later when i need the power, and ofc when i actually wanna finish the thing
@williamclifford6573 жыл бұрын
Really enjoyed the video today. Was only teaching some students about service level agreements and measuring system performance the other day. I'm glad the use of your own performance checks with timers hasn't become totally obsolete. Would be really interested to hear more from you on opengl performance/timers.
@TheExstud3 жыл бұрын
One thing I personally do is prototype in C#, then compare performance with C++. I'm happy when I beat C# by 10-20%, the initial C++ code is often tens to hundreds times slower.Using a custom memorypool is also a good idea to boost performance, if you're doing a lot of memory allocations.It would be great if you could make a video on how to actually make your code faster, not just profile it.
@user-py9cy1sy9u3 жыл бұрын
Pay attention to how you use the memory. Unless you are writing a simulation then memory usage(bandwith, cache) is the big problem. I found talks by Mike Acton to be useful. Thats the best I can do in youtube comment
@TheExstud3 жыл бұрын
@@user-py9cy1sy9u I know about cache lines, thanks, it's indeed important to read from the same chunk (64 bytes on most systems) of memory whenever you can, and to align everything properly. This is one of the things I'd like to see in another Cherno video.
@toby999929 күн бұрын
I very much doubt that.... C++ 100x slower than C# ?
@TheExstud29 күн бұрын
@@toby9999 It's mostly with dynamic allocation, new/malloc is terribly slow in C++/C, compared to C# which uses some kind of memorypool and recycles the memory. A factor 100 is not uncommon.
@nathanosullivan22963 жыл бұрын
Your videos have become so high quality over the years
@jerrody54003 жыл бұрын
Родненькие наши ковры, прям настроение поднимает.
@iDROIDchannel3 жыл бұрын
Жаль не на стене
@ariesduke20473 жыл бұрын
ахах даже не заметил
@comradepeter873 жыл бұрын
For those on desktop -> Comment: Our dear carpets, straight up the hood. 1st reply: Sorry not on the wall 2nd reply: ahah didn't even notice. (Google translated but I still have no idea what they're talking about).
@prateekkarn92773 жыл бұрын
@@comradepeter87 I read this exact thing on mobile translated by Google and even I don't understand wtf is going on
@Olegach213 жыл бұрын
@@prateekkarn9277 the carpet from the beginning of the video is the type that was very popular in ex USSR. It's also was used as an ad hoc sound insulation, by hanging it on the wall. There's also a meme that every Russian has a picture of themselves and a carpet on the wall as a background.
@sangamo382 жыл бұрын
My key strategy for optimization is : 1. Try not to use too much library functions without knowing what they do, most of the time a lot of functions have a lot of build up behind the scenes which in a larger application could affect the performance.. 2. C is the fastest so try to write code in such a way that resembles more towards c style for example if you get away with using an array for hashing instead of map then do it. It will greatly improve performance. 3. I/O operations are your enemy, so you want to avoid as much as I/O possible. 4. Avoid logical impurities like too much branching and recursion. Use guard clauses, bitwise operations and optimal algorithms. 5. Try to use availability of infinite memory to speed up calculations. memoizing calculations that you doing again and again can help greatly improve.
@mohammednihad67553 жыл бұрын
I feel something is different about this episode, IDK what is it, but I love it!
@nikolaiarsenov15953 жыл бұрын
I love the format of that video!
@ashraionart3 жыл бұрын
Love to see ur journey...
@LimboTheory3 жыл бұрын
I've been watching so much rp content after my break up and now KZbin recommended me to you again. KZbin said it's time
@gommito3 жыл бұрын
Great video! I wonder if you implemented some custom allocator. I've heard it can really speed things up. Good luck!
@drip75473 жыл бұрын
imo the "Producing Wrong Data Without Doing Anything Obviously Wrong" paper is also something that pretty interesting to read through if you REALLY really care :>
@MrHaggyy2 жыл бұрын
Writing a timer that tracks a frame and sub timestamps are soo usefull. Timer, number of calls and memory footprint are so basic you should always track them. Makes pro and cons about code measurable.
@ItsMePhoebe3 жыл бұрын
I've been wanting to learn this for ages! Cant wait to watch this later on! Thanks in advance! :)
@wChris_3 жыл бұрын
So i have seen Molly Rockets video about non-pessimization (The Refterm Lecture), and in there he explains that in order to optimize something, you have to write code that isnt pessimized, or in other words you have to write the code that does the minimum amount of work you need to do. For example: dont write an OS if all you need to do is print something to the screen! Or using a library that does extra stuff you DONT need or not even knowing WHAT a library does.
@mistermcking84452 жыл бұрын
Great video mate!
@patryk_493 жыл бұрын
Casey Muratori recently uploaded an excellent video series on optimizations.
@multi21763 жыл бұрын
Cannot wait for the multi-threading video.
@brandonsamuelcruzsilva762611 ай бұрын
Thank you for sharing your expertise!!!
@codecodecode39883 жыл бұрын
when it comes to optimizing i think of the optimizations and the techneks available before writing code; and c and DOD are what i like
@anton_982 жыл бұрын
"You really write them (tools) into your own application, they can't be wrong" Just hilarious)))
@lotusfish86323 жыл бұрын
looking forward to next month: optimisation october 2
@Spacemarine6583 жыл бұрын
I used optimization October to optimize myself and my work flow
@MrJCraft3 жыл бұрын
for optimization of my recent projects, I needed to switch languages yes trying to calculate millions of verts is really slow in python. basically all I found out down that route is just make sure its compiles and designed for speed, because different languages and compilers have different optimizations that can save a lot of time, its surprising how big of a difference a good compiler can make. especially for a relative beginner at optimizing. most of my code never needed it until now. maybe in the future I might try optimizing with assembly its way more natural for me to think of bytes though, so I might be able to make better optimizations. but I have been doing boolean algebra for a while.
@patrikjankovics21132 жыл бұрын
Optimizing with ASM is usually worse than writing optimized C++ code, at least in MSVC's case, because you hurt the optimizer's feelings and he just wont optimize the code as well. (Jokes aside, really, the optimizer won't work that well with inline ASM)
@heatblazer3 жыл бұрын
Usually RW is the bottleneck - less OOP more DOD , less abstractions more cache coherency - simple.
@Kimo.Codess3 жыл бұрын
Thank you for sharing
@CreativeOven3 жыл бұрын
polishing and optimization not for me... no ... but it has to be done! thanks to share your knowledge
@thepretendgineer22883 жыл бұрын
haha that intro just makes me think of studio wildcards optimisation technique
@LuccasSchmigel3 жыл бұрын
Best intro sir. haha
@PugMaxer3 жыл бұрын
Going to be useful for my simulations in rust as well, thanks!
@1schwererziehbar13 жыл бұрын
If you use Rust, your optimizations should focus on compilation speed.
@ShivamJha003 жыл бұрын
@@1schwererziehbar1 c++ isn't much better in that regard either
@mr.anderson50773 жыл бұрын
Thanks sensei
@Haellsigh3 жыл бұрын
Optick is great, but Tracy is even better, at least for my use case.
@billynugget71023 жыл бұрын
Associated memory… cherno bout to hit us with DOD straight facts
@michalrabek77433 жыл бұрын
0:02 Building a computer on a rug without ESD protection should be viewed as an extreme sport. 😂 The intro was great though! 👌
@1schwererziehbar13 жыл бұрын
I've never used ESD protection in my life and never had any problems. Most modern PC parts can be blasted with a tesla coil and will still work.
@michalrabek77433 жыл бұрын
@@1schwererziehbar1 I know that not using ESD protection won't blow up your components instantly, but it CAN happen. Honestly, whether or not you use ESD protection for your personal build is totally your thing 👍. However when I build/fix a PC for someone else, I use ESD protection 100% of the time for the sake of not accidentally breaking their stuff just by being careless. But yeah, not using it for your own home rig is fine, I guess 🤷, although it's still a bit risky. Better safe than sorry and saying sorry to someone for bricking their fancy mobo can be a bit difficult 😅
@xeridea3 жыл бұрын
@@michalrabek7743 If you touch the case first to discharge any built up potential, and don't rub all over the carpet, you should be fine. Similarly, it is good to touch your car first when refueling. Using this basic step virtually eliminates chance of ESD. Using protection isn't a bad idea of course, but I wouldn't stress over it.
@michalrabek77433 жыл бұрын
@@xeridea Yep, you're right. Touching a grounded surface works as well.
@mastershooter643 жыл бұрын
@@1schwererziehbar1 Not using ESD protection while building PCs is like not wearing a seat belt while driving a car, sure you could survive crashes without a seat belt but would you really wanna risk it?
@falxie_3 жыл бұрын
Hazel is looking good
@vyteniskajackas75793 жыл бұрын
Maybe not much of an optimization, but why people write i++ and complete ignore ++i? In 80-90% cases you should be writting ++i, since i++ does extra steps and therefore could lower the performance. It may seem like a detail, but when it is done thousand times, code may be slower, than it could be. Ofcourse, black magic powered compilers probobly fix this for you and makes it ++i where it can be done. Maybe its a small thing, but I believe its a good practise that is not talked about.
@TheCherno3 жыл бұрын
It's not really talked about because for the use cases you're talking about (single expression statements like in a for loop) there is no difference in generated code in bsaically all compilers. Here's an example: godbolt.org/z/s4b7WeWch
@Mugistan3 жыл бұрын
No bug November
@DaveChurchill3 жыл бұрын
Optick crashes whenever I try to load a JSON that was produced using the syntax you stated during your chrome tracing video. Any idea why this is?
@ThankYouESM3 жыл бұрын
Much as I very much love Python and can get it to randomly generate various styles of artwork... it processes way to slow for me. I can't figure out the numpy for it either. Would be awesome if we can also choose which variables to assign so we can get the speed needed from every CPU and especially the GPU as desired. However... I haven't tried out Godot yet.
@TheRyulord2 жыл бұрын
If you haven't heard of it already, you might want to check out JAX. It's basically NumPy but with a JIT compiler and (Nvidia) GPU support.
@ThankYouESM2 жыл бұрын
@@TheRyulord Thank You
@AgentM1243 жыл бұрын
Welcome to No-optimization November.
@HonsHon3 жыл бұрын
Love your videos. Also, you typically look really sad in the thumbnails everything alright?
@beaumanVienna3 жыл бұрын
Are you guys doing the model view projection entirely on the GPU? I use batch rendering and a single uniform, so I have to do the model transformation on the CPU. How to optimize this?
@yasserarguelles61173 жыл бұрын
It's probably better to have the model transformations on the CPU since it's going to be done per vertex shader call on the GPU vs per instance on the CPU, i recommend testing to see if there's even an issue first
@ymi_yugy31333 жыл бұрын
I find that my most common issue is using inefficient, naive algorithms.
@badwolf81123 жыл бұрын
Been wondering about how do we know that improvements by using profiling effects systems with different hardware than the PC the profiler runs on.
@user-py9cy1sy9u3 жыл бұрын
Wait till you read "Producing Wrong Data Without Doing Anything Obviously Wrong!" :D
@timothyvandyke95113 жыл бұрын
Hey Cherno, do you know anything about how to make a dynamic programming problem multi threaded? For my job I made a school scheduler. Each student's schedule is obviously dependent on itself as it goes AND the previous schedules. Does that mean multi-threading my app is impossible? When I reach 215 students it takes 10 seconds while single threaded. I do way more sorting than I need so I know I have some low hanging fruit but also I wondered if there were larger things I could do
@timothyvandyke95113 жыл бұрын
Not game programming at all, and it's in C#
@salockin95153 жыл бұрын
hey, do you play guitar? and if so have you ever made a video playing, I always see them in the background
@pastasawce3 жыл бұрын
How did u both get such strong aussie accents?
@yasserarguelles61173 жыл бұрын
He probably spawned in Australia
@edubogota13 жыл бұрын
Cherno can we do a recation video of the latest Halo infinite gameplkay trailer? It has improvements. Thank you!
@yohwllo21273 жыл бұрын
I have another problem, my code is too fast
@pD5V0DdsaoVhq3 жыл бұрын
This month is Optimization October That means next month is No Nut November???
@CreativeOven3 жыл бұрын
In ue4 take care of the construct function/event/whatever very fast construct instructions! is just one...
@Jkauppa3 жыл бұрын
we have infinite time, no rush
@PirateKnO3 жыл бұрын
Optimization october starts at october 30th 😂
@kalempster3 жыл бұрын
Optimization november incoming
@Iklu-w1p14 күн бұрын
KZbin identifies your language as dutch, so the subtitles are wrong.
@MrBOB-hj8jq2 жыл бұрын
I have the same big ben tea box.
@LiraeNoir3 жыл бұрын
Ugh 24fps... that works in film because projectors are 24fps, insert black between them, and because camera have a shutter meaning they have blur on every single moving part. And even then, camera operators have strict rules about the speed of their pans for example to avoid framerate issues. 24fps in a videogame is just not a pleasant experience to play, at all. 30+ is ok under certain conditions. Under 16ms of frametime is really the reasonable bare minimum nowadays, and under 8ms for fast games.
@xeridea3 жыл бұрын
24FPS works better in video because it is consistent. Games framerates can have a lot of variance. If running average 30FPS, you are likely to have a few frames that would take longer, perhaps twice as long. So to get consistent minimum 30FPS, 60FPS average is desirable. Some years ago, reviewers started including 1% and 0.1% lows, as well as frame time graphs to highlight temporary slowdowns due to drivers, poor game code, slow CPU, overloaded hardware, etc. Some games, particularly first person shooters, or competitive E-Sports games benefit from faster framerate, and casual games can be fine as long as it's smooth.
@LordOfWizardurl3 жыл бұрын
Will you convert hazel to GNU/Linux support?
@pxolqopt35973 жыл бұрын
I'd just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called “Linux” distributions are really distributions of GNU/Linux.
@lucass81193 жыл бұрын
@@pxolqopt3597 They already said GNU/Linux and their comment isn't edited... this is a little embarrassing.
@pxolqopt35973 жыл бұрын
@@lucass8119 i put that in as a joke because they said GNU/Linux
@StevenMartinGuitar3 жыл бұрын
How to optimise your code... Use some tools and spread the GPU/CPU load. Although I enjoyed the video I was hoping to learn the basics of the specifics. As someone who hasn't optimised any code before, I didn't really take anything I can use from this. Not hating, still one of my favourite channels and greatful.
@avtem3 жыл бұрын
i had a few little 3d games that were using 100%cpu all the time. So i just uninstalled all of them, because it's impossible to play.
@katie-ampersand3 жыл бұрын
optimization is easy just set the fps to a higher number
@bradenbigham24873 жыл бұрын
except when you try to fix code in one part...other parts break!!!!
@timothyjohnson44703 жыл бұрын
Unfortunately, I cannot watch this video, there is no subtitle for English. I'm deaf and feel left out of this awesome content
@MiloTheDuck-s7j3 жыл бұрын
It's easy, just press ctrl+A delete
@nicobugs3 жыл бұрын
Just so you know, your intro is what made me click on the video.
@evan_game_dev3 жыл бұрын
Yeah, I do a different kind of optimization. No optimization
@sandeeprao95273 жыл бұрын
gRPC C++ Video Please!!
@shawn5763 жыл бұрын
The game might freeze? Solution: make it autosave all the time. -Bethesda
@LittleRainGames3 жыл бұрын
The best way to easily optimize code is to make variables 1 letter and remove comments.
@LordOfWizardurl3 жыл бұрын
Lol
@Dartht33bagger3 жыл бұрын
-O3
@WhozZzWho3 жыл бұрын
Lol New World
@oamioxmocliox80823 жыл бұрын
;)
@Шокирующиеновости-д2с3 жыл бұрын
you wont have to optimize if you do it right from the start in (C) c++ is bloated
@xeridea3 жыл бұрын
Yeah, so bloated that nearly every AAA game is written in C++.
@Шокирующиеновости-д2с3 жыл бұрын
@@xeridea like they have choice
@Avighna3 жыл бұрын
@@Шокирующиеновости-д2с C++ isn't bloated, the speeds are the same for almost everything in both of the languages.
@xeridea3 жыл бұрын
@@Шокирующиеновости-д2с ... They do have a choice, they could use C. They could use other languages. C++ is used because it is generally as fast as C, but has far more features, and less error prone. It is much easier to write complex, yet still high performance code. Having more features doesn't make it "bloated", or slower, it gives more options. You can still use C style code in your C++ if you want, and for some situations it makes sense performance wise, because C++ features aren't always needed. Generally, replicating functionality that is easy in C++ in C isn't necessarily faster, and can introduce more bugs. C tends to be better for OS, and embedded system though. Neither language is objectively better, both have their strengths.
@Шокирующиеновости-д2с3 жыл бұрын
@@xeridea stop repeating what you heard on internet, c++ is bloated, What features? What templates? that thing is the most retarted thing invented, alone with Bjarne, dude is an idiot, he even put a qoute, I made c++ so that it will be much more difficult to use, so that who ever masters it in 82 years will be dead, basically, people feel smart, but aint doing shit.
@moomsoon20683 жыл бұрын
什么让你变得肥胖 My god!What makes you fat? I can't believe it. I don't love you anymore......
@nikkiofthevalley2 жыл бұрын
I can't tell if this is some kind of translation error, or just someone who is very rude.
@moomsoon20682 жыл бұрын
@@nikkiofthevalley I'm just roast(but translation error,). I have great respect for cherno.