The goal of this exercise is to understand the memory use and performance of
std::vector
. You will get
familiar with the IgProf profiler tool.
Steps
-
Go to the exercise directory:
cd esc15/hands-on/memory
-
Examine the little test programs in this directory. You use them for dedicated little studies on container memory allocation behaviour:
-
vvvi-build-and-copy.cc
: Build triply nested vector ofint
s, and make a copy of it; drops profile heap snapshots part way. This example was used in the presentation. -
vvvi-reserve.cc
: Same asvvvi-build-and-snapshot.cc
, but uses thereserve()
method correctly to avoid vector resizes. This example was used in the presentation.
-
-
Build each program. The command is mentioned in each source file. To build all in one go:
grep -h Compile *.cc | sed 's|// Compile: ||' | sh -x
-
Run the programs under the igprof profiler:
rm -f *.gz igprof -mp ./vvvi-build-and-copy igprof -mp ./vvvi-reserve
-
Analyse the profiles using:
for f in *.gz; do igprof-analyse --sqlite -d -v -g -r MEM_TOTAL $f | sqlite3 ~/public_html/cgi-bin/data/${f}_tot.sql3 igprof-analyse --sqlite -d -v -g -r MEM_LIVE $f | sqlite3 ~/public_html/cgi-bin/data/${f}_live.sql3 igprof-analyse --sqlite -d -v -g -r MEM_LIVE --value peak $f | sqlite3 ~/public_html/cgi-bin/data/${f}_live_peak.sql3 done
-
This results in profiles such as:
http://esc-gw.pd.infn.it:61100/~<student>/cgi-bin/igprof-navigator.py/vvvi-copy.gz_tot/
.