tools/footprint/linux-gdf.mk

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 # -*- Mode: Makefile -*-
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 # This makefile will run Mozilla (or the program you specify), observe
michael@0 8 # the program's memory status using the /proc filesystem, and generate
michael@0 9 # a ``gross dynamic footprint'' graph using gnuplot.
michael@0 10 #
michael@0 11 # Usage:
michael@0 12 #
michael@0 13 # make MOZILLA_DIR=<mozilla-dir> PROGRAM=<program> URL=<url>
michael@0 14 #
michael@0 15 # e.g.,
michael@0 16 #
michael@0 17 # make -flinux-gdf.mk \
michael@0 18 # MOZILLA_DIR=/export2/waterson/seamonkey-opt/mozilla/dist/bin \
michael@0 19 # PROGRAM=gtkEmbed \
michael@0 20 # BUSTER_URL="http://localhost/cgi-bin/buster.cgi?refresh=10"
michael@0 21 #
michael@0 22 # To use this program, you'll need to:
michael@0 23 #
michael@0 24 # 1. Install gnuplot, e.g., using your RedHat distro.
michael@0 25 # 2. Install the "buster.cgi" script onto a webserver somewhere
michael@0 26 # 3. Have a mozilla build.
michael@0 27 #
michael@0 28 # You can tweak ``linux.gnuplot.in'' to change the graph's output.
michael@0 29
michael@0 30 # This script computes a line using linear regression; its output is
michael@0 31 # of the form:
michael@0 32 #
michael@0 33 # <b1> * x + <b0>
michael@0 34 #
michael@0 35 # Where <b1> is the slope and <b0> is the y-intercept.
michael@0 36 LINEAR_REGRESSION=awk -f linear-regression.awk Skip=5
michael@0 37
michael@0 38 INTERVAL=10
michael@0 39 WATCH=./watch.sh
michael@0 40
michael@0 41 MOZILLA_DIR=../../dist/bin
michael@0 42 PROGRAM=gtkEmbed
michael@0 43 BUSTER_URL=http://localhost/cgi-bin/buster.cgi?refresh=$(INTERVAL)
michael@0 44 OUTFILE=linux.dat
michael@0 45
michael@0 46 #----------------------------------------------------------------------
michael@0 47 # Top-level target
michael@0 48 #
michael@0 49 all: gdf.png
michael@0 50
michael@0 51 #----------------------------------------------------------------------
michael@0 52 # gtkEmbed
michael@0 53 #
michael@0 54
michael@0 55 .INTERMEDIATE: linux.gnuplot vms.dat vmd.dat vmx.dat rss.dat
michael@0 56
michael@0 57 # Create a PNG image using the generated ``linux.gnuplot'' script
michael@0 58 gdf.png: vms.dat vmd.dat vmx.dat rss.dat linux.gnuplot
michael@0 59 gnuplot linux.gnuplot
michael@0 60
michael@0 61 # Generate a ``gnuplot'' script from ``linux.gnuplot.in'', making
michael@0 62 # appropriate substitutions as necessary.
michael@0 63 linux.gnuplot: linux.gnuplot.in vms.dat
michael@0 64 sed -e "s/@PROGRAM@/$(PROGRAM)/" \
michael@0 65 -e "s/@VMS-LINE@/`$(LINEAR_REGRESSION) vms.dat`/" \
michael@0 66 -e "s/@GROWTH-RATE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ printf \"%0.1lf\\n\", $$1; }'`/" \
michael@0 67 -e "s/@BASE-SIZE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ print $$5 + 2000; }'`/" \
michael@0 68 linux.gnuplot.in > linux.gnuplot
michael@0 69
michael@0 70 # Break the raw data file into temporary files that can be processed
michael@0 71 # by gnuplot directly.
michael@0 72 vms.dat: $(OUTFILE)
michael@0 73 awk -f create_dat.awk TYPE=vms $? > $@
michael@0 74
michael@0 75 vmd.dat: $(OUTFILE)
michael@0 76 awk -f create_dat.awk TYPE=vmd $? > $@
michael@0 77
michael@0 78 vmx.dat: $(OUTFILE)
michael@0 79 awk -f create_dat.awk TYPE=vmx $? > $@
michael@0 80
michael@0 81 rss.dat: $(OUTFILE)
michael@0 82 awk -f create_dat.awk TYPE=rss $? > $@
michael@0 83
michael@0 84 # Run $(PROGRAM) to produce $(OUTFILE)
michael@0 85 $(OUTFILE):
michael@0 86 LD_LIBRARY_PATH=$(MOZILLA_DIR) \
michael@0 87 MOZILLA_FIVE_HOME=$(MOZILLA_DIR) \
michael@0 88 $(WATCH) -i $(INTERVAL) -o $@ $(MOZILLA_DIR)/$(PROGRAM) "$(BUSTER_URL)"
michael@0 89
michael@0 90 # Clean up the mess.
michael@0 91 clean:
michael@0 92 rm -f $(OUTFILE) gdf.png *~
michael@0 93

mercurial