SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Jonas M. Larsen Memory debugging Recipe profiling
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Memory debugging valgrind > valgrind a.out
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Memory debugging valgrind Memory errors sometimes make programs crash. Other times they don't! Use a memory debugger regularly (valgrind, gdb,...)
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling Reasons to optimize The pipeline must process at about the same speed as observations are performed Trade-off: Science quality vs. execution speed Reasons not to optimize “slow” can be “fast enough” Trade-off: CPU cycles vs. human brain cycles Trade-off: Design vs. speed Measure before you optimize!
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling profile_build > profile_build -qfitssrc=~/qfits cplsrc=~/cpl esorexsrc=~/esorex iiinstrumentsrc=~/xshp -builddir=~/BUILD - iiinstrumentlib=xsh xsh_mbias > ~/BUILD/bin/esorex xsh_mbias xsh_mbias.sof > gprof ~/BUILD/bin/esorex > gcov my_source_file.c
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling GCC gprof GCC gprof
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling GCC gcov Use profiling tools (gprof, gcov, Shark,...) GCC gcov
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling Asymptotic time complexity Example: Looping through a FITS header O(n^3) O(n^2) O(n)
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling Constant factor optimization Measure before you optimize!
SDD/DFS Jonas M. Larsen VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Profiling If n is large, be careful about... Reference: