Skip to content

Commit 19f13a7

Browse files
committed
crude tool to find out where all the binary size bloat is coming from and fixes for contbuild: timeout to (try to) avoid hanging tests
Summary: crude tool to find out where all the binary size bloat is coming from ran it https://www.facebook.com/groups/fbcode/permalink/930686686968171/ contbuild: timeout to (try to) avoid hanging tests also the speed test can now have the threshold overridden in the env using WDT_THROUGHPUT (default 16000 mbytes/sec) set lower pending https://www.facebook.com/groups/linux.fbk/permalink/1062956390403870/ Reviewed By: nikunjy Differential Revision: D2631045 fb-gh-sync-id: 97fce9f0bd0f1cc077e836f7e8bea43841b4ea09
1 parent ef28e7c commit 19f13a7

File tree

3 files changed

+83
-6
lines changed

3 files changed

+83
-6
lines changed

build/binary_analyzer.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#! /bin/sh
2+
# Quick hack to figure out where is the space coming from
3+
4+
FILE=$1
5+
if [ -z "$FILE" -o "$FILE" = "-h" ] ; then
6+
echo "Usage: $0 binary"
7+
exit 1
8+
fi
9+
10+
TMPRESULT=`mktemp /tmp/nm_out.XXX`
11+
12+
RESULT=$TMPRESULT
13+
14+
echo "Working on $FILE, intermediate nm result in $RESULT"
15+
16+
nm -C --defined-only --print-size -l $FILE > $RESULT
17+
18+
echo "nm done... analyzing..."
19+
#RESULT=/dev/shm/nm.out
20+
21+
gawk '
22+
{sizeHex="0x" $2; size=strtonum(sizeHex); sum+=size}
23+
/:[0-9]+$/ {
24+
if (size) {
25+
ssum += size;
26+
# not all lines of nm output do find a file with line number this finds
27+
# lines like "xxxx/blah.cc:123" and returns "xxxx/blah"
28+
# for the xxx part it tries to keep it shorter by not allowing .
29+
# (nm sometimes outputs path/./tmp/morepath)
30+
match($0, "([^ \t.]+)(\\.(h|c|cc|tcc|cpp|hpp|S|rl|ipp|y))?:[0-9]+$", arr);
31+
src=arr[1]
32+
# unknown extensions...
33+
if (length(src) < 5) print src, " XXXX ", $0;
34+
# get rid of irrelevant stuff
35+
sub("/tmp/", "/", src)
36+
# somehow lots of ....fbcode...////////morestuf
37+
sub(".*///", "", src)
38+
# x/ or y/ ...
39+
sub("^./", "", src)
40+
# 20/....
41+
sub("^[0-9/]+", "", src)
42+
sizes[src] += size;
43+
match(src, "(.*)/[^/]*$", pkg);
44+
sizes[pkg[1] "/*"]+= size;
45+
}
46+
}
47+
END {
48+
print "Extracted file attribution for", ssum/1024/1024., "Mb out of",
49+
sum/1024/1024., "Mb :", int((1000*ssum/sum+.5))/10, "%"
50+
n = asorti(sizes, siter)
51+
for (s in sizes) {
52+
print s, sizes[s]
53+
}
54+
}' $RESULT | sort -k 2 -n
55+
56+
rm $TMPRESULT

build/wdt_cont_build_run.tcl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ append ::env(USER) "_wdt_contbuild"
1010
set userdir $::env(USER)
1111
puts "Will run script with USER env = $userdir"
1212

13+
set maxTestDuration "15m"
14+
set totalMaxDuration "35m"
15+
16+
puts "Max test duration: $maxTestDuration - Max total $totalMaxDuration"
17+
18+
# Set throughput - lower for now / there is some issue with kernel or env
19+
# (or our code?)
20+
set ::env(WDT_THROUGHPUT) 13000
21+
1322
set CDIR "/data/users/$userdir"
1423

1524
# path and ld library path
@@ -43,6 +52,8 @@ proc sleep {time} {
4352

4453
# we will email for the first change
4554
set last {}
55+
# uncomment to force initial version update after restart
56+
# set last "force"
4657
# previous hg log for wdt (will cause email first too)
4758
set hgprev {none}
4859
# also email every x :
@@ -80,15 +91,18 @@ nextEmail
8091

8192
cd $CDIR/fbsource/fbcode
8293

94+
8395
# only 2 types for now - either 'open source' on the mac or full otherwise
8496
set os [exec uname]
8597
if {$os == "Darwin"} {
8698
set type "mac"
8799
set extraCmds "echo done"
88100
set targetDir "/usr/local/var/www/wdt_builds/"
89101
set sudo ""
102+
set timeoutCmd "gtimeout"
90103
} else {
91104
set type "unix"
105+
set timeoutCmd "timeout"
92106
set extraCmds "cd $CDIR/fbsource/fbcode &&\
93107
(sudo tc qdisc del dev lo root; sudo ip6tables --flush || true) &&\
94108
time fbconfig --clang -r wdt &&\
@@ -97,11 +111,11 @@ if {$os == "Darwin"} {
97111
time wdt/test/wdt_max_send_test.sh _bin/wdt/fbonly/wdt_fb |& tail -50 &&\
98112
time fbconfig --sanitize address -r wdt &&\
99113
time fbmake dbg &&\
100-
time fbmake runtests --run-disabled --record-results --return-nonzero-on-timeouts &&\
114+
time $timeoutCmd $maxTestDuration fbmake runtests --run-disabled --record-results --return-nonzero-on-timeouts &&\
101115
sudo tc qdisc add dev lo root netem delay 20ms 10ms \
102116
duplicate 1% corrupt 0.1% &&\
103117
echo rerunning tests with tc delays &&\
104-
time fbmake runtests --run-disabled --record-results --return-nonzero-on-timeouts &&\
118+
time $timeoutCmd $maxTestDuration fbmake runtests --run-disabled --record-results --return-nonzero-on-timeouts &&\
105119
sudo tc qdisc del dev lo root"
106120
set targetDir "~/public_html/wdt_builds/"
107121
set sudo "sudo"
@@ -122,12 +136,13 @@ while {1} {
122136
set LOGF "$CDIR/$LOGTS.log"
123137
puts "Logging to $LOGF"
124138
# cleanup previous builds failure - sudo not needed/asking for passwd on mac
125-
if {[catch {exec sh -c "set -o pipefail; set -x; date; uname -a;\
139+
if {[catch {exec $timeoutCmd $totalMaxDuration sh -c "set -o pipefail;\
140+
set -x; date; uname -a;\
126141
$sudo rm -rf /tmp/wdtTest_$userdir /dev/shm/wdtTest_$userdir wdtTest &&\
127142
cd $CDIR/fbsource/fbcode && time hg pull -u &&\
128143
hg log -l 1 && hg log -v -l 1 folly && hg log -v -l 1 wdt &&\
129144
cd $CDIR/cmake_wdt_build && time make -j 4 && \
130-
CTEST_OUTPUT_ON_FAILURE=1 time make test &&\
145+
CTEST_OUTPUT_ON_FAILURE=1 time $timeoutCmd $maxTestDuration make test &&\
131146
$extraCmds" >& $LOGF < /dev/null} results options]} {
132147
set msg "BAD"
133148
set good 0

test/wdt_max_send_test.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ if [ -z $TEST_COUNT ]; then
3434
TEST_COUNT=16
3535
fi
3636

37+
# WDT_THROUGHPUT is an env var. Set it to overwrite the expected 16Gbyte/sec
38+
if [ -z $WDT_THROUGHPUT ]; then
39+
WDT_THROUGHPUT=16000
40+
fi
41+
42+
3743
if [ -z "$HOSTNAME" ] ; then
3844
echo "HOSTNAME not set, will try with 'localhost'"
3945
HOSTNAME=localhost
@@ -143,8 +149,8 @@ rm -rf $DIR
143149
echo "Speed for all runs: $ALLSPEEDS"
144150

145151
# Normalize by CPU / number of threads
146-
# (32 cores leaves 15 threads and can do ~20-21G, use 19 for margin of noise)
147-
EXPECTED_SPEED=`echo 16000*$NUM_THREADS/16|bc`
152+
# (32 cores leaves 15 threads and can do ~20-22G, use 16 for margin of noise)
153+
EXPECTED_SPEED=`echo $WDT_THROUGHPUT*$NUM_THREADS/16|bc`
148154

149155
echo "Best throughput for $WDTBIN"
150156
if [ "$MAXRATE" -lt "$EXPECTED_SPEED" ]; then

0 commit comments

Comments
 (0)