Optimizing existing large codebase Measuire Modemise Mem threads Finding bottlenecks Understand where we can improve o analyze each part of the software o in order to find out where most time is spent o and understand whether it can be improved Most usual bottlenecks From biggest to lowest impact(usually) 。10 ●Memory 。Parallelization o Low level behavior:vectorization,cache behavior,high CPl erf tool bottlenecks 12/57 S.Ponce-CERN
Optimizing existing large codebase 12 / 57 S. Ponce - CERN Measure Modernize Mem threads low level c/c perf tools bottlenecks Finding bottlenecks Understand where we can improve analyze each part of the software in order to find out where most time is spent and understand whether it can be improved Most usual bottlenecks From biggest to lowest impact (usually) IO Memory Parallelization Low level behavior : vectorization, cache behavior, high CPI
Optimizing existing large codebase Modernice Mem threads low Code modernization Measuring Performance Code modernization Improving Memory Handling The nightmare of thread safety Low level optimizations Conclusion 13/57 S.Ponce-CERN
Optimizing existing large codebase 13 / 57 S. Ponce - CERN Measure Modernize Mem threads low level c/c Code modernization 1 Measuring Performance 2 Code modernization 3 Improving Memory Handling 4 The nightmare of thread safety 5 Low level optimizations 6 Conclusion
Optimizing existing large codebase Measiare Modernice Mem threads low Make use of latest C++features C++has evolved dramatically between 2010 and now four new versions:C++11,C++14,C++17,C++20 o a LOT of new features targeting performance ●move semantic ●threading library variadic templates vectorization coming o converting existing code may already bring speed o see previous courses for technical details o see my extended C++course if you're not at ease with the language 14/57 S.Ponce-CERN
Optimizing existing large codebase 14 / 57 S. Ponce - CERN Measure Modernize Mem threads low level c/c Make use of latest C++features C ++has evolved dramatically between 2010 and now four new versions : C++11, C++14, C++17, C++20 a LOT of new features targeting performance move semantic threading library variadic templates vectorization coming ! converting existing code may already bring speed see previous courses for technical details see my extended C++course if you’re not at ease with the language
Optimizing existing large codebase Measire Modernice Mem threads lom Cleanup your code While reviewing the code for converting to latest C++: drop unused code drop unnecessary code e.g.do I really need to sort by hits here drop too generic APls if they are finally not needed o replace virtual inheritance with templating when possible o consider dropping use of unmaintained libraries o It is very often surprising how much you gain there 15/57 S.Ponce-CERN
Optimizing existing large codebase 15 / 57 S. Ponce - CERN Measure Modernize Mem threads low level c/c Cleanup your code While reviewing the code for converting to latest C++: drop unused code drop unnecessary code e.g. do I really need to sort by hits here ? drop too generic APIs if they are finally not needed replace virtual inheritance with templating when possible consider dropping use of unmaintained libraries It is very often surprising how much you gain there
Optimizing existing large codebase Mem threads Io Improving Memory Handling Measuring Performance Code modernization Improving Memory Handling o Context o Containers and memory o Container reservation o Detecting offending code The nightmare of thread safety Low level optimizations ®Conclusion context comtainera reserving findBadCode 16157 S.Ponce-CERN
Optimizing existing large codebase 16 / 57 S. Ponce - CERN Measure Modernize Mem threads low level c/c context containers reserving findBadCode Improving Memory Handling 1 Measuring Performance 2 Code modernization 3 Improving Memory Handling Context Containers and memory Container reservation Detecting offending code 4 The nightmare of thread safety 5 Low level optimizations 6 Conclusion