Skip to content

Commit

Permalink
[benchmarks] Start measuring native code size with Bloaty McBloatFace.
Browse files Browse the repository at this point in the history
Found a bunch of low-hanging fruit.
  • Loading branch information
Andy Chu committed Oct 13, 2018
1 parent a5901ea commit ce27833
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 20 deletions.
65 changes: 65 additions & 0 deletions benchmarks/native-code.sh
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Usage:
# ./native-code.sh <function name>

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
}


"$@"
20 changes: 0 additions & 20 deletions build/codegen.sh
Expand Up @@ -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.
Expand Down

0 comments on commit ce27833

Please sign in to comment.