From ce27833da9ecad1f0a755214c6786137e97e71e0 Mon Sep 17 00:00:00 2001 From: Andy Chu Date: Fri, 12 Oct 2018 12:59:45 -0700 Subject: [PATCH] [benchmarks] Start measuring native code size with Bloaty McBloatFace. Found a bunch of low-hanging fruit. --- benchmarks/native-code.sh | 65 +++++++++++++++++++++++++++++++++++++++ build/codegen.sh | 20 ------------ 2 files changed, 65 insertions(+), 20 deletions(-) create mode 100755 benchmarks/native-code.sh diff --git a/benchmarks/native-code.sh b/benchmarks/native-code.sh new file mode 100755 index 0000000000..fca61c474e --- /dev/null +++ b/benchmarks/native-code.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Usage: +# ./native-code.sh + +set -o nounset +set -o pipefail +set -o errexit + +# Size profiler for binaries. +bloaty() { + ~/git/other/bloaty/bloaty "$@" +} + +pylibc-symbols() { + symbols _devbuild/py-ext/x86_64/libc.so +} + +fastlex-symbols() { + symbols _devbuild/py-ext/x86_64/fastlex.so +} + +symbols() { + local obj=$1 + nm $obj + echo + + bloaty $obj + echo + + # fastlex_MatchToken is 21.2 KiB. That doesn't seem to large compared ot + # the 14K line output? + bloaty -d symbols $obj + echo + + ls -l $obj + echo +} + +# Big functions: +# - PyEval_EvalFrameEx (38 KiB) +# - fastlex_MatchOSHToken (22.5 KiB) +# - convertitem() in args.py (9.04 KiB) +# - PyString_Format() in args.py (6.84 KiB) +# +# Easy removals: +# - marshal_dumps and marshal_dump! We never use those. +# - Remove all docstrings!!! Like sys_doc. + +cpython-bloat() { + # ovm-opt.stripped doesn't show a report. + local file=_build/oil/ovm-opt + + # Slightly different. + #local file=_build/oil/ovm-dbg + + #bloaty -n 30 -d symbols $file + + # Full output + # 3,588 lines! + bloaty --tsv -n 0 -d symbols $file +} + + +"$@" diff --git a/build/codegen.sh b/build/codegen.sh index d7b996e3c4..d7c3cf33c0 100755 --- a/build/codegen.sh +++ b/build/codegen.sh @@ -100,26 +100,6 @@ ast-id-lex() { osh-lex-gen-native } -# Size profiler for binaries. TODO: Fold this into benchmarks/ -bloaty() { ~/git/other/bloaty/bloaty "$@"; } - -stats() { - local obj=_devbuild/py-ext/x86_64/fastlex.so - nm $obj - echo - - bloaty $obj - echo - - # fastlex_MatchToken is 21.2 KiB. That doesn't seem to large compared ot - # the 14K line output? - bloaty -d symbols $obj - echo - - ls -l $obj - echo -} - # NOTES: # - core/id_kind_gen.py generates the mapping from Id to Kind. # - It needs a mapping output by the Python superoptimizatio script.