Home
Welcome
About This Wiki
sandbox (play here)
This shows you the differences between two versions of the page.
shell [2016/07/21 08:11] dblume [Application Memory Usage] |
shell [2018/03/22 10:57] (current) dblume [Command Template] |
||
---|---|---|---|
Line 113: | Line 113: | ||
((VERBOSE==1)) && echo "Starting at $(date)" | ((VERBOSE==1)) && echo "Starting at $(date)" | ||
rsync /cygdrive/c/Users/me /cygdrive/"$DISK"/backup/Users | rsync /cygdrive/c/Users/me /cygdrive/"$DISK"/backup/Users | ||
+ | |||
+ | # We add "|| true" because we don't want to stop | ||
+ | # if the directory was already empty | ||
+ | rm -r /cygdrive/c/Users/me/tmp/* || true | ||
+ | |||
+ | # Note how we find the number of cores to use | ||
+ | make -C build_subdirectory all -j$(grep -c ^processor /proc/cpuinfo) | ||
</code> | </code> | ||
Line 381: | Line 388: | ||
</code> | </code> | ||
+ | ====== Measuring Available Memory ====== | ||
+ | |||
+ | This note doesn't entirely make sense to me. Maybe need to study up on "cat /proc/meminfo" vs. "cat /proc/vmstat" vs. "vmstat". | ||
+ | |||
+ | The best measure I've found for "available memory" is nr_inactive_file_pages+nr_active_file_pages+nr_free_pages from /proc/vmstat. And then you have to subtract out some heuristically determined value which is base system working set. (That heuristically determined value can be 30-40MB.) | ||
+ | |||
+ | The command ''free'' just isn't a great indicator in general of how much memory is available because it doesn't account for the cached file-backed pages that could be dumped to make more memory available. | ||
====== Shared Memory Usage ====== | ====== Shared Memory Usage ====== | ||
Line 396: | Line 410: | ||
kernel.shmall= 268435456 | kernel.shmall= 268435456 | ||
</code> | </code> | ||
+ | |||
+ | ====== Performance Metrics ====== | ||
+ | |||
+ | * Use [[http://man7.org/linux/man-pages/man1/perf-timechart.1.html|perf-timechart]] | ||
+ | * [[https://github.com/gperftools/gperftools|gperftools]] | ||
+ | |||
+ | And you can scrape logs that start with timecodes to create Spreadsheet charts. Given logs like: | ||
+ | |||
+ | <code> | ||
+ | 2016-10-13 19:54:44 memory 22a4 | ||
+ | </code> | ||
+ | |||
+ | On a Macintosh: | ||
+ | |||
+ | <code bash> | ||
+ | grep memory devicelogs.txt | tr -s ' ' | cut -d " " -f 1,2,4 | \ | ||
+ | sed 's/\([0-9\-]\+\) \([0-9:]\+\).[0-9]\+ \([0-9a-f]\+\)/\1,\2,=DATEVALUE("\1")+TIMEVALUE("\2"),=HEX2DEC("\3")/' > heapinfo.csv; \ | ||
+ | open heapinfo.csv -a "Microsoft Excel" | ||
+ | </code> | ||
+ | |||
+ | And on Linux, instead of opening Microsoft Excel, that last line would be: | ||
+ | |||
+ | <code bash> | ||
+ | libreoffice --calc heapinfo.csv | ||
+ | </code> | ||
+ | |||
+ | ====== Cron ====== | ||
+ | |||
+ | Keep tasks serialized with [[https://linux.die.net/man/1/flock|flock(1)]]: | ||
+ | |||
+ | ( | ||
+ | flock -n 9 || exit 1 | ||
+ | # ... commands executed under lock ... | ||
+ | ) 9>/var/lock/mylockfile | ||
+ | |||
+ | |||
+ | ====== Retrieving Symbols with addr2line ====== | ||
+ | |||
+ | You can gather a backtrace (stacktrace) with this piped command to addr2line. | ||
+ | |||
+ | $ cat << EOF | cut -d " " -f 3 | tr -d "[]" | \ | ||
+ | addr2line -e builds/austin/src/platform/gibbon/netflix | \ | ||
+ | xargs -d '\n' realpath --relative-to=. | ||
+ | > 7/22 app() [0xf7878] (0xf7878) | ||
+ | > 8/22 app() [0x39c2f8] (0x39c2f8) | ||
+ | > 9/22 app() [0xe1964] (0xe1964) | ||
+ | > EOF | ||
+ | src/Application.h:106 (discriminator 3) | ||
+ | src/platform/main.cpp:521 | ||
+ | src/Application.cpp:95 | ||
====== Additional Keywords ====== | ====== Additional Keywords ====== | ||
Linux, Unix, *nix | Linux, Unix, *nix |