Optimization

Premature optimization is the root of bugs that you need to handle for 18 years.

Optimization is the process of improving the performance of the program. The two common things that one try to improve is the speed, so it runs faster, or memory, so it use less of it. Often it is possible to trade one for the other, for example to calculate things in advance so the program do run faster but consume more memory. The process of optimization is made up of the following three steps.

Profile to find the hotspot

First one need to find a area to improve. The best one is the one that has the biggest potential to improve the overall performance. To do that one can use external or internal profiler. A internal profiler is something that one has built into the game and an external is another program that measure it's performance. In the end the profiler gives a measure of the current performance of that area. Common units to measure performance in is seconds (for speed) or bytes (for size). Depending on the scale unit prefixes such as milli or mega is common. When measuring speed one should use the unit seconds and not Frames per second.

Optimize it

Do whatever is needed to improve the speed, size or whatever of the hotspot.

Verify improvement

Run the tools (profiler, memory trackers) again to see if the performance has improved. If not try again :).




Tools

GPUView

Reference

Optimizations in C++ Compilers - 2019

Rules of optimization - 2018

The Elusive Frame Timing - 2018

Optimization and performance measurement - 2018

Profiling: The Case of the Missing Milliseconds - 2018

More performance, more gameplay - 2017

CppCon 2016: Nicolas Fleury “Rainbow Six Siege: Quest for Performance"

CppCon 2016: Jason Turner “Practical Performance Practices - 2016

CppCon 2016: Timur Doumler “Want fast C++? Know your hardware!" - 2016

Taming the Jaguar: x86 Optimization at Insomniac Games - 2016

C++ Performance: Common Wisdoms and Common “Wisdoms” - 2016

Stop Misquoting Donald Knuth! - 2015

Understanding Compiler Optimization - Chandler Carruth - Opening Keynote Meeting C++ - 2015

Code Clinic : How to write code the compiler can actually optimize - 2015

Optimizing software in C++ - 2014

Looking For a Good Sort - 2014

The microarchitecture of Intel, AMD and VIA CPUs - 2014

Optimizing subroutines in assembly language - 2014

Vessel: Common Performance Issues - 2013

Don't Help the Compiler - 2013

A Profiling Primer - 2013

Optimisation lessons learned - 2012 Part 1, Part 2 and Part 3.

Visual C++ Performance Pitfalls - 2011

The Windows Heap Is Slow When Launched from the Debugger - 2011

Finding Bottlenecks by Random Breaking - 2011

Hotspots, FLOPS, and uOps: To-The-Metal CPU Optimization - 2011

Optimisation Lesson - 2011 : 1: Profiling , 2: The Pipeline and 3: The Memory Bottleneck.

Optimizations that aren't - 2010

Writing Efficient Game Code for Next-Gen Console Architectures - 2005

OPT#1:Profiling - 2020

OPT#2:LowLevel

Optimizing Trilinear Interpolation

OPT#3:SIMD (part 1 of 2)

OPT#4:SIMD (part 2 of 2)

AMD Ryzen™ Processor Software Optimization - Video / Slides

Optimizing for the Radeon™ RDNA Architecture- Video / Slides

From Source to ISA: A Trip Down the Shader Compiler Pipeline - Video / Slides

Godot - OPTIMIZING A 3D SCENE

https://github.com/dvyukov/perf-load


Tracy Profiler

https://github.com/wolfpld/tracy


Optick: C++ Profiler For Games

https://github.com/bombomby/optick


Optimizing Software Occlusion Culling - 2013

https://fgiesen.wordpress.com/2013/02/17/optimizing-sw-occlusion-culling-index/


Performance Analysis and tuning on modern cpus - 2020

https://book.easyperf.net/perf_book


DoD book is good.

Otherwise, just go with simple stuff, and use a good profiler like Superluminal, to get the low hanging fruits.

You can go with the VS builtin profiler, cachegrind, et


The Art of Writing Efficient Programs

https://github.com/PacktPublishing/The-Art-of-Writing-Efficient-Programs


uops.info

https://www.uops.info/


superluminal

https://superluminal.eu/