diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-05-06 16:56:32 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-06-02 11:18:47 +0200 |
| commit | 8174a918ea3b7cb216bf7ea98cfdc10661b5c37d (patch) | |
| tree | 0747ec3ccb9f8d7eeccfac35977fc17855ca3bbb | |
| parent | 8f52e8fc02dd235582f5961941bcd564e9a681cd (diff) | |
| download | allocbench-8174a918ea3b7cb216bf7ea98cfdc10661b5c37d.tar.gz allocbench-8174a918ea3b7cb216bf7ea98cfdc10661b5c37d.zip | |
make the whole project more python idiomatic
* rename src directory to allocbench
* make global variable names UPPERCASE
* format a lot of code using yapf
* use lowercase ld_preload and ld_library_path as Allocator members
* name expected Errors 'err' and don't raise a new Exception
* disable some pylint messages
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | Readme.md | 2 | ||||
| -rw-r--r-- | allocbench/Makefile (renamed from src/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/__init__.py (renamed from src/__init__.py) | 0 | ||||
| -rw-r--r-- | allocbench/align_to_cl.c (renamed from src/align_to_cl.c) | 0 | ||||
| -rw-r--r-- | allocbench/allocator.py (renamed from src/allocator.py) | 58 | ||||
| -rw-r--r-- | allocbench/allocators/__init__.py (renamed from src/allocators/__init__.py) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/ba_allocators.py (renamed from src/allocators/BA_allocators.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/bumpptr.py (renamed from src/allocators/bumpptr.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/chattymalloc.py (renamed from src/allocators/chattymalloc.py) | 12 | ||||
| -rw-r--r-- | allocbench/allocators/glibc.py (renamed from src/allocators/glibc.py) | 7 | ||||
| -rw-r--r-- | allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch (renamed from src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch (renamed from src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/hoard.py (renamed from src/allocators/hoard.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/jemalloc.py (renamed from src/allocators/jemalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/llalloc.py (renamed from src/allocators/llalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/malt.py (renamed from src/allocators/malt.py) | 5 | ||||
| -rw-r--r-- | allocbench/allocators/mesh.py (renamed from src/allocators/mesh.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/mimalloc.py (renamed from src/allocators/mimalloc.py) | 10 | ||||
| -rw-r--r-- | allocbench/allocators/no_falsesharing.py (renamed from src/allocators/no_falsesharing.py) | 7 | ||||
| -rw-r--r-- | allocbench/allocators/paper.py (renamed from src/allocators/paper.py) | 19 | ||||
| -rw-r--r-- | allocbench/allocators/rpmalloc.py (renamed from src/allocators/rpmalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/scalloc.py (renamed from src/allocators/scalloc.py) | 13 | ||||
| -rw-r--r-- | allocbench/allocators/scalloc/scalloc_fix_log.patch (renamed from src/allocators/scalloc/scalloc_fix_log.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/snmalloc.py (renamed from src/allocators/snmalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/speedymalloc.py (renamed from src/allocators/speedymalloc.py) | 23 | ||||
| -rw-r--r-- | allocbench/allocators/streamflow.py (renamed from src/allocators/streamflow.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/supermalloc.py (renamed from src/allocators/supermalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch (renamed from src/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/tbbmalloc.py (renamed from src/allocators/tbbmalloc.py) | 9 | ||||
| -rw-r--r-- | allocbench/allocators/tcmalloc.py (renamed from src/allocators/tcmalloc.py) | 18 | ||||
| -rw-r--r-- | allocbench/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch (renamed from src/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch (renamed from src/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch) | 0 | ||||
| -rw-r--r-- | allocbench/allocators/tcmalloc/tcmalloc_bazel_build_so.patch (renamed from src/allocators/tcmalloc/tcmalloc_bazel_build_so.patch) | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | allocbench/analyse.py (renamed from src/analyse.py) | 43 | ||||
| -rw-r--r-- | allocbench/artifact.py (renamed from src/artifact.py) | 8 | ||||
| -rw-r--r-- | allocbench/benchmark.py (renamed from src/benchmark.py) | 47 | ||||
| -rw-r--r-- | allocbench/benchmarks/__init__.py (renamed from src/benchmarks/__init__.py) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/blowup.py (renamed from src/benchmarks/blowup.py) | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/blowup/Makefile (renamed from src/benchmarks/blowup/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/blowup/blowup.c (renamed from src/benchmarks/blowup/blowup.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac.py (renamed from src/benchmarks/cfrac.py) | 27 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/CMakeLists.txt (renamed from src/benchmarks/cfrac/CMakeLists.txt) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/README.md (renamed from src/benchmarks/cfrac/README.md) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/asm16bit.h (renamed from src/benchmarks/cfrac/asm16bit.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/atop.c (renamed from src/benchmarks/cfrac/atop.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/cfrac.c (renamed from src/benchmarks/cfrac/cfrac.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/errorp.c (renamed from src/benchmarks/cfrac/errorp.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/getopt.c (renamed from src/benchmarks/cfrac/getopt.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/getopt.h (renamed from src/benchmarks/cfrac/getopt.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/itop.c (renamed from src/benchmarks/cfrac/itop.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/ltop.c (renamed from src/benchmarks/cfrac/ltop.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pabs.c (renamed from src/benchmarks/cfrac/pabs.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/padd.c (renamed from src/benchmarks/cfrac/padd.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pcfrac.c (renamed from src/benchmarks/cfrac/pcfrac.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pcmp.c (renamed from src/benchmarks/cfrac/pcmp.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pconst.c (renamed from src/benchmarks/cfrac/pconst.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pcvt.h (renamed from src/benchmarks/cfrac/pcvt.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pdefs.h (renamed from src/benchmarks/cfrac/pdefs.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pdivmod.c (renamed from src/benchmarks/cfrac/pdivmod.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pfactor.c (renamed from src/benchmarks/cfrac/pfactor.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pfactor.h (renamed from src/benchmarks/cfrac/pfactor.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pfloat.c (renamed from src/benchmarks/cfrac/pfloat.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pgcd.c (renamed from src/benchmarks/cfrac/pgcd.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/phalf.c (renamed from src/benchmarks/cfrac/phalf.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/picmp.c (renamed from src/benchmarks/cfrac/picmp.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pidiv.c (renamed from src/benchmarks/cfrac/pidiv.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pimod.c (renamed from src/benchmarks/cfrac/pimod.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pio.c (renamed from src/benchmarks/cfrac/pio.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pmul.c (renamed from src/benchmarks/cfrac/pmul.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pneg.c (renamed from src/benchmarks/cfrac/pneg.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/podd.c (renamed from src/benchmarks/cfrac/podd.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/pops.c (renamed from src/benchmarks/cfrac/pops.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/ppowmod.c (renamed from src/benchmarks/cfrac/ppowmod.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/precision.h (renamed from src/benchmarks/cfrac/precision.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/primes.c (renamed from src/benchmarks/cfrac/primes.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/primes.h (renamed from src/benchmarks/cfrac/primes.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/psqrt.c (renamed from src/benchmarks/cfrac/psqrt.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/psub.c (renamed from src/benchmarks/cfrac/psub.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/ptoa.c (renamed from src/benchmarks/cfrac/ptoa.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/ptob.c (renamed from src/benchmarks/cfrac/ptob.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/ptou.c (renamed from src/benchmarks/cfrac/ptou.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/seive.h (renamed from src/benchmarks/cfrac/seive.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/cfrac/utop.c (renamed from src/benchmarks/cfrac/utop.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/dj_trace.py (renamed from src/benchmarks/dj_trace.py) | 21 | ||||
| -rw-r--r-- | allocbench/benchmarks/dj_trace/Makefile (renamed from src/benchmarks/dj_trace/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/dj_trace/trace_run.c (renamed from src/benchmarks/dj_trace/trace_run.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso.py (renamed from src/benchmarks/espresso.py) | 24 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/CMakeLists.txt (renamed from src/benchmarks/espresso/CMakeLists.txt) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/README.md (renamed from src/benchmarks/espresso/README.md) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/ansi.h (renamed from src/benchmarks/espresso/ansi.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cofactor.c (renamed from src/benchmarks/espresso/cofactor.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cols.c (renamed from src/benchmarks/espresso/cols.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/compl.c (renamed from src/benchmarks/espresso/compl.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/contain.c (renamed from src/benchmarks/espresso/contain.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/copyright.h (renamed from src/benchmarks/espresso/copyright.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cubestr.c (renamed from src/benchmarks/espresso/cubestr.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cvrin.c (renamed from src/benchmarks/espresso/cvrin.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cvrm.c (renamed from src/benchmarks/espresso/cvrm.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cvrmisc.c (renamed from src/benchmarks/espresso/cvrmisc.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/cvrout.c (renamed from src/benchmarks/espresso/cvrout.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/dominate.c (renamed from src/benchmarks/espresso/dominate.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/equiv.c (renamed from src/benchmarks/espresso/equiv.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/espresso.c (renamed from src/benchmarks/espresso/espresso.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/espresso.h (renamed from src/benchmarks/espresso/espresso.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/essen.c (renamed from src/benchmarks/espresso/essen.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/exact.c (renamed from src/benchmarks/espresso/exact.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/expand.c (renamed from src/benchmarks/espresso/expand.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/gasp.c (renamed from src/benchmarks/espresso/gasp.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/getopt.c (renamed from src/benchmarks/espresso/getopt.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/gimpel.c (renamed from src/benchmarks/espresso/gimpel.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/globals.c (renamed from src/benchmarks/espresso/globals.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/hack.c (renamed from src/benchmarks/espresso/hack.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/indep.c (renamed from src/benchmarks/espresso/indep.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/irred.c (renamed from src/benchmarks/espresso/irred.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/largest.espresso (renamed from src/benchmarks/espresso/largest.espresso) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/main.c (renamed from src/benchmarks/espresso/main.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/main.h (renamed from src/benchmarks/espresso/main.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/map.c (renamed from src/benchmarks/espresso/map.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/matrix.c (renamed from src/benchmarks/espresso/matrix.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/mincov.c (renamed from src/benchmarks/espresso/mincov.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/mincov.h (renamed from src/benchmarks/espresso/mincov.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/mincov_int.h (renamed from src/benchmarks/espresso/mincov_int.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/opo.c (renamed from src/benchmarks/espresso/opo.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/pair.c (renamed from src/benchmarks/espresso/pair.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/part.c (renamed from src/benchmarks/espresso/part.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/port.h (renamed from src/benchmarks/espresso/port.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/primes.c (renamed from src/benchmarks/espresso/primes.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/reduce.c (renamed from src/benchmarks/espresso/reduce.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/regex.h (renamed from src/benchmarks/espresso/regex.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/rows.c (renamed from src/benchmarks/espresso/rows.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/set.c (renamed from src/benchmarks/espresso/set.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/setc.c (renamed from src/benchmarks/espresso/setc.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/sharp.c (renamed from src/benchmarks/espresso/sharp.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/sminterf.c (renamed from src/benchmarks/espresso/sminterf.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/solution.c (renamed from src/benchmarks/espresso/solution.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/sparse.c (renamed from src/benchmarks/espresso/sparse.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/sparse.h (renamed from src/benchmarks/espresso/sparse.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/sparse_int.h (renamed from src/benchmarks/espresso/sparse_int.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/stdlib.h (renamed from src/benchmarks/espresso/stdlib.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/unate.c (renamed from src/benchmarks/espresso/unate.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/utility.c (renamed from src/benchmarks/espresso/utility.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/utility.h (renamed from src/benchmarks/espresso/utility.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/espresso/verify.c (renamed from src/benchmarks/espresso/verify.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing.py (renamed from src/benchmarks/falsesharing.py) | 26 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/Makefile (renamed from src/benchmarks/falsesharing/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/cache-scratch.cc (renamed from src/benchmarks/falsesharing/cache-scratch.cc) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/cache-thrash.cc (renamed from src/benchmarks/falsesharing/cache-thrash.cc) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/cpuinfo.h (renamed from src/benchmarks/falsesharing/cpuinfo.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/fred.h (renamed from src/benchmarks/falsesharing/fred.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/falsesharing/timer.h (renamed from src/benchmarks/falsesharing/timer.h) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/fd.py (renamed from src/benchmarks/fd.py) | 17 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd.py (renamed from src/benchmarks/httpd.py) | 22 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/Makefile (renamed from src/benchmarks/httpd/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/etc/nginx/nginx.conf (renamed from src/benchmarks/httpd/etc/nginx/nginx.conf) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/etc/php/php-fpm.conf (renamed from src/benchmarks/httpd/etc/php/php-fpm.conf) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/etc/php/php-fpm.d/www.conf (renamed from src/benchmarks/httpd/etc/php/php-fpm.d/www.conf) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/etc/php/php.ini (renamed from src/benchmarks/httpd/etc/php/php.ini) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/html/index.html (renamed from src/benchmarks/httpd/html/index.html) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/html/index.php (renamed from src/benchmarks/httpd/html/index.php) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/httpd/php/index.php (renamed from src/benchmarks/httpd/php/index.php) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/keydb.py (renamed from src/benchmarks/keydb.py) | 35 | ||||
| -rw-r--r-- | allocbench/benchmarks/larson.py (renamed from src/benchmarks/larson.py) | 8 | ||||
| -rw-r--r-- | allocbench/benchmarks/larson/Makefile (renamed from src/benchmarks/larson/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/larson/larson.cc (renamed from src/benchmarks/larson/larson.cc) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/lld.py (renamed from src/benchmarks/lld.py) | 26 | ||||
| -rw-r--r-- | allocbench/benchmarks/loop.py (renamed from src/benchmarks/loop.py) | 9 | ||||
| -rw-r--r-- | allocbench/benchmarks/loop/Makefile (renamed from src/benchmarks/loop/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/loop/loop.c (renamed from src/benchmarks/loop/loop.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/mysql.py (renamed from src/benchmarks/mysql.py) | 85 | ||||
| -rw-r--r-- | allocbench/benchmarks/raxmlng.py (renamed from src/benchmarks/raxmlng.py) | 19 | ||||
| -rw-r--r-- | allocbench/benchmarks/rdtsc.py (renamed from src/benchmarks/rdtsc.py) | 29 | ||||
| -rw-r--r-- | allocbench/benchmarks/rdtsc/Makefile (renamed from src/benchmarks/rdtsc/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/rdtsc/rdtsc.c (renamed from src/benchmarks/rdtsc/rdtsc.c) | 3 | ||||
| -rw-r--r-- | allocbench/benchmarks/realloc.py (renamed from src/benchmarks/realloc.py) | 6 | ||||
| -rw-r--r-- | allocbench/benchmarks/realloc/Makefile (renamed from src/benchmarks/realloc/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/realloc/realloc.c (renamed from src/benchmarks/realloc/realloc.c) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/redis.py (renamed from src/benchmarks/redis.py) | 20 | ||||
| -rwxr-xr-x | allocbench/benchmarks/redis/build.sh (renamed from src/benchmarks/redis/build.sh) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/t_test1.py (renamed from src/benchmarks/t_test1.py) | 24 | ||||
| -rw-r--r-- | allocbench/benchmarks/t_test1/Makefile (renamed from src/benchmarks/t_test1/Makefile) | 0 | ||||
| -rw-r--r-- | allocbench/benchmarks/t_test1/t-test1.c (renamed from src/benchmarks/t_test1/t-test1.c) | 0 | ||||
| -rw-r--r-- | allocbench/bumpptr_alloc.c (renamed from src/bumpptr_alloc.c) | 0 | ||||
| -rw-r--r-- | allocbench/exec.c (renamed from src/exec.c) | 0 | ||||
| -rw-r--r-- | allocbench/facter.py (renamed from src/facter.py) | 26 | ||||
| -rw-r--r-- | allocbench/globalvars.py | 66 | ||||
| -rw-r--r-- | allocbench/malloc.c (renamed from src/malloc.c) | 0 | ||||
| -rw-r--r-- | allocbench/plots.py (renamed from src/plots.py) | 81 | ||||
| -rw-r--r-- | allocbench/print_status_on_exit.c (renamed from src/print_status_on_exit.c) | 0 | ||||
| -rw-r--r-- | allocbench/sig_handlers.c (renamed from src/sig_handlers.c) | 0 | ||||
| -rw-r--r-- | allocbench/util.py (renamed from src/util.py) | 20 | ||||
| -rwxr-xr-x | bench.py | 75 | ||||
| -rw-r--r-- | doc/Allocators.md | 2 | ||||
| -rw-r--r-- | doc/Benchmarks.md | 8 | ||||
| -rwxr-xr-x | merge.py | 16 | ||||
| -rwxr-xr-x | scripts/histogram.py | 29 | ||||
| -rwxr-xr-x | scripts/paper_plots.py | 42 | ||||
| -rwxr-xr-x | scripts/print_facts.py | 13 | ||||
| -rw-r--r-- | src/globalvars.py | 66 | ||||
| -rwxr-xr-x | summarize.py | 52 |
200 files changed, 663 insertions, 625 deletions
@@ -1,7 +1,9 @@ -PYTHONFILES = $(shell find src/ -name "*.py") +SRCDIR = allocbench -MAKEFILES = $(shell dirname $(shell find src/ -name Makefile)) -CMAKELISTS = $(shell dirname $(shell find src/ -name CMakeLists.txt)) +PYTHONFILES = $(shell find $(SRCDIR)/ -name "*.py") + +MAKEFILES = $(shell dirname $(shell find $(SRCDIR)/ -name Makefile)) +CMAKELISTS = $(shell dirname $(shell find $(SRCDIR)/ -name CMakeLists.txt)) OBJDIR = $(PWD)/build @@ -22,7 +24,7 @@ export LDXXFLAGS = $(LDFLAGS) -static-libstdc++ all: $(OBJDIR)/ccinfo $(MAKEFILES) $(CMAKELISTS) $(CMAKELISTS): - $(eval BENCHDIR=$(OBJDIR)$(shell echo $@ | sed s/src//)) + $(eval BENCHDIR=$(OBJDIR)$(shell echo $@ | sed s/$(SRCDIR)//)) @if test \( ! \( -d $(BENCHDIR) \) \) ;then mkdir -p $(BENCHDIR);fi ifneq (,$(findstring s,$(MAKEFLAGS))) cd $(BENCHDIR); cmake $(PWD)/$@ >/dev/null @@ -32,9 +34,9 @@ endif $(MAKE) -C $(BENCHDIR) $(MAKEFILES): - $(eval BENCHDIR=$(OBJDIR)$(shell echo $@ | sed s/src//)) + $(eval BENCHDIR=$(OBJDIR)$(shell echo $@ | sed s/$(SRCDIR)//)) @if test \( ! \( -d $(BENCHDIR) \) \) ;then mkdir -p $(BENCHDIR);fi - $(MAKE) -C $@ OBJDIR=$(OBJDIR)$(shell echo $@ | sed s/src//) + $(MAKE) -C $@ OBJDIR=$(OBJDIR)$(shell echo $@ | sed s/$(SRCDIR)//) $(OBJDIR)/ccinfo: | $(OBJDIR) $(CC) -v 2> $@ @@ -99,7 +99,7 @@ It groups the included allocators into categories to produce readable and not ex runs only the loop benchmark for all included allocators and will put its results in `$PWD/results/$HOSTNAME/<time>/loop`. - ./bench.py -a BA_allocators + ./bench.py -a ba_allocators builds all allocators used in Florian Fischer's [BA thesis](https://muhq.space/ba.html) and runs all benchmarks. diff --git a/src/Makefile b/allocbench/Makefile index caceb19..caceb19 100644 --- a/src/Makefile +++ b/allocbench/Makefile diff --git a/src/__init__.py b/allocbench/__init__.py index d989a60..d989a60 100644 --- a/src/__init__.py +++ b/allocbench/__init__.py diff --git a/src/align_to_cl.c b/allocbench/align_to_cl.c index e54f065..e54f065 100644 --- a/src/align_to_cl.c +++ b/allocbench/align_to_cl.c diff --git a/src/allocator.py b/allocbench/allocator.py index e14dfa7..4712634 100644 --- a/src/allocator.py +++ b/allocbench/allocator.py @@ -26,9 +26,9 @@ import shutil from subprocess import CalledProcessError import sys -from src.artifact import ArchiveArtifact, GitArtifact -import src.globalvars -from src.util import print_status, print_debug, print_error, print_info2, run_cmd +from allocbench.artifact import ArchiveArtifact, GitArtifact +from allocbench.globalvars import ALLOCBUILDDIR, ALLOCSRCDIR +from allocbench.util import print_status, print_debug, print_error, print_info2, run_cmd LIBRARY_PATH = "" for line in run_cmd(["ldconfig", "-v", "-N"], @@ -37,9 +37,8 @@ for line in run_cmd(["ldconfig", "-v", "-N"], if not line.startswith('\t'): LIBRARY_PATH += line -BUILDDIR = Path(src.globalvars.allocbuilddir) +BUILDDIR = Path(ALLOCBUILDDIR) SRCDIR = BUILDDIR / "src" -ALLOCDEFDIR = Path('src/allocators') SRCDIR.mkdir(parents=True, exist_ok=True) @@ -52,14 +51,14 @@ class Allocator: Allocator.build will compile the allocator and produce a for allocbench usable allocator dict""" allowed_attributes = [ - "binary_suffix", "cmd_prefix", "LD_PRELOAD", "LD_LIBRARY_PATH", + "binary_suffix", "cmd_prefix", "ld_preload", "ld_library_path", "color", "sources", "version", "patches", "prepare_cmds", "build_cmds" ] binary_suffix = None cmd_prefix = None - LD_PRELOAD = None - LD_LIBRARY_PATH = None + ld_preload = None + ld_library_path = None color = None sources = None version = None @@ -107,20 +106,20 @@ class Allocator: if not_patched: try: run_cmd(["patch", "-p0", "--verbose"], cwd=cwd, input=patch_content) - except CalledProcessError as e: - print_debug(e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug(err.stderr, file=sys.stderr) print_error(f"Patching of {self.name} failed.") - raise e + raise if self.prepare_cmds: print_status(f"Run prepare commands {self.name} ...") for cmd in self.prepare_cmds: try: run_cmd(cmd, shell=True, cwd=self.srcdir) - except CalledProcessError as e: - print_debug(e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug(err.stderr, file=sys.stderr) print_error(f"Prepare {self.name} failed") - raise e + raise def build(self): """Build the allocator if needed and produce an allocator dict""" @@ -153,27 +152,27 @@ class Allocator: try: run_cmd(cmd, cwd=BUILDDIR, shell=True) - except CalledProcessError as e: - print_debug(e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug(err.stderr, file=sys.stderr) print_error(f"Builing {self.name} failed") shutil.rmtree(self.dir, ignore_errors=True) - raise e + raise - with open(buildtimestamp_path, "w") as buildtimestamp_file: - print_info2("Save build time to:", buildtimestamp_path) - buildtimestamp_file.write(str(datetime.now().timestamp())) + with open(buildtimestamp_path, "w") as buildtimestamp_file: + print_info2("Save build time to:", buildtimestamp_path) + buildtimestamp_file.write(str(datetime.now().timestamp())) print_info2("Create allocator dictionary") res_dict = { "cmd_prefix": self.cmd_prefix or "", "binary_suffix": self.binary_suffix or "", - "LD_PRELOAD": self.LD_PRELOAD or "", - "LD_LIBRARY_PATH": self.LD_LIBRARY_PATH or "", + "LD_PRELOAD": self.ld_preload or "", + "LD_LIBRARY_PATH": self.ld_library_path or "", "color": self.color } for attr in ["LD_PRELOAD", "LD_LIBRARY_PATH", "cmd_prefix"]: - value = getattr(self, attr, "") or "" + value = getattr(self, attr.lower(), "") or "" if value != "": value = value.format(dir=self.dir, srcdir=self.srcdir) res_dict[attr] = value @@ -221,11 +220,11 @@ def collect_available_allocators(): available_allocators = {} - for alloc_def_path in Path(ALLOCDEFDIR).glob('*.py'): - alloc_module_name = '.'.join(alloc_def_path.parts[:-1] + (alloc_def_path.stem,)) + for alloc_def_path in Path(ALLOCSRCDIR).glob('*.py'): + alloc_module_name = f'allocbench.allocators.{alloc_def_path.stem}' module = importlib.import_module(alloc_module_name) for name, obj in module.__dict__.items(): - if issubclass(obj.__class__, src.allocator.Allocator): + if issubclass(obj.__class__, Allocator): available_allocators[name] = obj return available_allocators @@ -253,7 +252,7 @@ def collect_allocators(allocators): Otherwise allocators is interpreted as a list of names or files. If an entry in allocators is a file it is handled as a allocator collection file exporting a allocators variable. If the entry is no file it is interpreted as an allocator - name and is searched for in our allocator definitions located at src/allocators. + name and is searched for in our allocator definitions located at allocbench/allocators. """ # Default allocators definition file @@ -262,8 +261,12 @@ def collect_allocators(allocators): if allocators is None and os.path.isfile(default_allocators_file): return read_allocators_collection_file(default_allocators_file) + available_allocators = collect_available_allocators() + ret = {} for name in allocators: + if name == "all": + return available_allocators if name == "installed": print_status("Using system-wide installed allocators ...") ret.update(collect_installed_allocators()) @@ -274,7 +277,6 @@ def collect_allocators(allocators): # interpret name as allocator name or wildcard else: - available_allocators = collect_available_allocators() matched_allocators = fnmatch.filter(available_allocators.keys(), name) if matched_allocators: ret.update({a: available_allocators[a].build() for a in matched_allocators}) diff --git a/src/allocators/__init__.py b/allocbench/allocators/__init__.py index d5c6419..d5c6419 100644 --- a/src/allocators/__init__.py +++ b/allocbench/allocators/__init__.py diff --git a/src/allocators/BA_allocators.py b/allocbench/allocators/ba_allocators.py index 9c11873..e4c55f4 100644 --- a/src/allocators/BA_allocators.py +++ b/allocbench/allocators/ba_allocators.py @@ -16,9 +16,10 @@ # along with allocbench. If not, see <http://www.gnu.org/licenses/>. """Collection containing all allocators used in Florian's BA thesis""" -from src.allocators.glibc import glibc, glibc_notc -from src.allocators.tcmalloc import tcmalloc -from src.allocators.jemalloc import jemalloc -from src.allocators.hoard import hoard +from allocbench.allocators.glibc import glibc, glibc_notc +from allocbench.allocators.tcmalloc import tcmalloc +from allocbench.allocators.jemalloc import jemalloc +from allocbench.allocators.hoard import hoard +# pylint: disable=invalid-name allocators = [glibc, glibc_notc, tcmalloc, jemalloc, hoard] diff --git a/src/allocators/bumpptr.py b/allocbench/allocators/bumpptr.py index 9165352..1d9d111 100644 --- a/src/allocators/bumpptr.py +++ b/allocbench/allocators/bumpptr.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -18,12 +18,13 @@ The bumpptr allocator makes the biggest possible tradeoff between speed and memory in speeds favor. Memory is mmapped per thread and never freed. -See src/bumpptr.c for the actual implementation. +See allocbench/bumpptr.c for the actual implementation. """ import os -from src.allocator import Allocator, BUILDDIR +from allocbench.allocator import Allocator, BUILDDIR +# pylint: disable=invalid-name bumpptr = Allocator("bumpptr", - LD_PRELOAD=os.path.join(BUILDDIR, "bumpptr_alloc.so"), + ld_preload=os.path.join(BUILDDIR, "bumpptr_alloc.so"), color="xkcd:black") diff --git a/src/allocators/chattymalloc.py b/allocbench/allocators/chattymalloc.py index ff4a3ba..22dc2d4 100644 --- a/src/allocators/chattymalloc.py +++ b/allocbench/allocators/chattymalloc.py @@ -21,13 +21,12 @@ the allocator usage and the executed program. It overrides the malloc API and saves each call and its result to a memory mapped output file. """ -import os - -from src.artifact import GitArtifact -from src.allocator import Allocator +from allocbench.artifact import GitArtifact +from allocbench.allocator import Allocator VERSION = "1a09b144eb18919014ecf86da3442344b0eaa5b2" + class Chattymalloc(Allocator): """Chattymalloc definition for allocbench""" @@ -44,9 +43,10 @@ class Chattymalloc(Allocator): f"meson {{srcdir}} {{dir}} {configuration}", "ninja -C {dir}" ] - self.LD_PRELOAD = "{dir}/libchattymalloc.so" - self.cmd_prefix="env CHATTYMALLOC_FILE={{result_dir}}/{{perm}}.trace" + self.ld_preload = "{dir}/libchattymalloc.so" + self.cmd_prefix = "env CHATTYMALLOC_FILE={{result_dir}}/{{perm}}.trace" super().__init__(name, **kwargs) +# pylint: disable=invalid-name chattymalloc = Chattymalloc("chattymalloc", version=VERSION) diff --git a/src/allocators/glibc.py b/allocbench/allocators/glibc.py index 5d2814d..44ac4af 100644 --- a/src/allocators/glibc.py +++ b/allocbench/allocators/glibc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -18,8 +18,8 @@ from multiprocessing import cpu_count -from src.allocator import Allocator, LIBRARY_PATH -from src.artifact import GitArtifact +from allocbench.allocator import Allocator, LIBRARY_PATH +from allocbench.artifact import GitArtifact class Glibc(Allocator): @@ -47,6 +47,7 @@ class Glibc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name glibc = Glibc("glibc", version="glibc-2.29", color="xkcd:red") glibc_notc = Glibc("glibc-noThreadCache", diff --git a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch b/allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch index becbfda..becbfda 100644 --- a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch +++ b/allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing.patch diff --git a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch b/allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch index 480d072..480d072 100644 --- a/src/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch +++ b/allocbench/allocators/glibc/glibc_2.29_no_passive_falsesharing_fancy.patch diff --git a/src/allocators/hoard.py b/allocbench/allocators/hoard.py index 5d0c2ce..b7f3abe 100644 --- a/src/allocators/hoard.py +++ b/allocbench/allocators/hoard.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Hoard allocator definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Hoard(Allocator): @@ -26,7 +26,7 @@ class Hoard(Allocator): sources = GitArtifact("Hoard", "https://github.com/emeryberger/Hoard.git") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libhoard.so" + self.ld_preload = "{dir}/libhoard.so" self.build_cmds = [ "cd {srcdir}/src; make", "mkdir -p {dir}", "ln -f -s {srcdir}/src/libhoard.so {dir}/libhoard.so" @@ -36,6 +36,7 @@ class Hoard(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name hoard = Hoard("Hoard", version="aa6d31700d5368a9f5ede3d62731247c8d9f0ebb", color="xkcd:brown") diff --git a/src/allocators/jemalloc.py b/allocbench/allocators/jemalloc.py index ab2528b..6e42733 100644 --- a/src/allocators/jemalloc.py +++ b/allocbench/allocators/jemalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """jemalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Jemalloc(Allocator): @@ -27,7 +27,7 @@ class Jemalloc(Allocator): "https://github.com/jemalloc/jemalloc.git") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libjemalloc.so" + self.ld_preload = "{dir}/libjemalloc.so" self.prepare_cmds = ["./autogen.sh"] self.build_cmds = [ "cd {srcdir}; ./configure --prefix={dir}", "cd {srcdir}; make -j4", @@ -38,4 +38,5 @@ class Jemalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name jemalloc = Jemalloc("jemalloc", version="5.1.0", color="xkcd:yellow") diff --git a/src/allocators/llalloc.py b/allocbench/allocators/llalloc.py index d3c5288..73cb18b 100644 --- a/src/allocators/llalloc.py +++ b/allocbench/allocators/llalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Lockless allocator definition for allocbench""" -from src.allocator import Allocator -from src.artifact import ArchiveArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import ArchiveArtifact class LocklessAllocator(Allocator): @@ -34,9 +34,10 @@ class LocklessAllocator(Allocator): "ln -f -s {srcdir}/lockless_allocator/libllalloc.so.1.3 {dir}/libllalloc.so" ] - self.LD_PRELOAD = "{dir}/libllalloc.so" + self.ld_preload = "{dir}/libllalloc.so" super().__init__(name, **kwargs) +# pylint: disable=invalid-name llalloc = LocklessAllocator("llalloc", color="purple") diff --git a/src/allocators/malt.py b/allocbench/allocators/malt.py index 8613145..ebe4255 100644 --- a/src/allocators/malt.py +++ b/allocbench/allocators/malt.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -20,9 +20,10 @@ Malt is a malloc tracker and used to capture and analyse the allocation profile of a program. See https://github.com/memtt/malt for more details """ -from src.allocator import Allocator +from allocbench.allocator import Allocator # result_dir and perm are substituted during Benchmark.run +# pylint: disable=invalid-name malt = Allocator( "malt", cmd_prefix="malt -q -o output:name={{result_dir}}/malt.{{perm}}.%3") diff --git a/src/allocators/mesh.py b/allocbench/allocators/mesh.py index 4d99f4d..a268e01 100644 --- a/src/allocators/mesh.py +++ b/allocbench/allocators/mesh.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Mesh definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Mesh(Allocator): @@ -26,7 +26,7 @@ class Mesh(Allocator): sources = GitArtifact("Mesh", "https://github.com/plasma-umass/Mesh") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libmesh.so" + self.ld_preload = "{dir}/libmesh.so" self.build_cmds = [ "cd {srcdir}; ./configure", "cd {srcdir}; make -j 4", "mkdir -p {dir}", "ln -f -s {srcdir}/libmesh.so {dir}/libmesh.so" @@ -35,6 +35,7 @@ class Mesh(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name mesh = Mesh("Mesh", version="4a1012cee990cb98cc1ea0294a836f467b29be02", color="xkcd:mint") diff --git a/src/allocators/mimalloc.py b/allocbench/allocators/mimalloc.py index 6801191..c6952c5 100644 --- a/src/allocators/mimalloc.py +++ b/allocbench/allocators/mimalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """mimalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Mimalloc(Allocator): @@ -26,7 +26,7 @@ class Mimalloc(Allocator): sources = GitArtifact("mimalloc", "https://github.com/microsoft/mimalloc") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libmimalloc.so" + self.ld_preload = "{dir}/libmimalloc.so" self.build_cmds = [ "mkdir -p {dir}", "cd {dir}; cmake {srcdir}", "cd {dir}; make" ] @@ -34,5 +34,5 @@ class Mimalloc(Allocator): super().__init__(name, **kwargs) - +# pylint: disable=invalid-name mimalloc = Mimalloc("mimalloc", version="v1.6.0") diff --git a/src/allocators/no_falsesharing.py b/allocbench/allocators/no_falsesharing.py index 77310b3..5d8ebfd 100644 --- a/src/allocators/no_falsesharing.py +++ b/allocbench/allocators/no_falsesharing.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,9 +16,10 @@ # along with allocbench. """Collection containing all no falsesahring patches""" -from src.allocators.tcmalloc import tcmalloc_gperftools, tcmalloc_gperftools_nofs -from src.allocators.glibc import glibc, glibc_nofs, glibc_nofs_fancy +from allocbench.allocators.tcmalloc import tcmalloc_gperftools, tcmalloc_gperftools_nofs +from allocbench.allocators.glibc import glibc, glibc_nofs, glibc_nofs_fancy +# pylint: disable=invalid-name allocators = [ glibc, glibc_nofs, glibc_nofs_fancy, tcmalloc_gperftools, tcmalloc_gperftools_nofs diff --git a/src/allocators/paper.py b/allocbench/allocators/paper.py index 3f36be9..f4aa44a 100644 --- a/src/allocators/paper.py +++ b/allocbench/allocators/paper.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,16 +16,15 @@ # along with allocbench. If not, see <http://www.gnu.org/licenses/>. """Collection containing all available allocators""" -from src.allocators.glibc import glibc -from src.allocators.tcmalloc import tcmalloc, tcmalloc_align, tcmalloc_gperftools, tcmalloc_gperftools_align -from src.allocators.jemalloc import jemalloc -from src.allocators.scalloc import scalloc -from src.allocators.llalloc import llalloc -from src.allocators.tbbmalloc import tbbmalloc -from src.allocators.mimalloc import mimalloc -from src.allocators.bumpptr import bumpptr -from src.allocators.speedymalloc import speedymalloc +from allocbench.allocators.glibc import glibc +from allocbench.allocators.tcmalloc import tcmalloc, tcmalloc_align, tcmalloc_gperftools, tcmalloc_gperftools_align +from allocbench.allocators.jemalloc import jemalloc +from allocbench.allocators.llalloc import llalloc +from allocbench.allocators.mimalloc import mimalloc +from allocbench.allocators.bumpptr import bumpptr +from allocbench.allocators.speedymalloc import speedymalloc +# pylint: disable=invalid-name allocators = [ glibc, tcmalloc, tcmalloc_align, tcmalloc_gperftools, tcmalloc_gperftools_align, jemalloc, llalloc, mimalloc, bumpptr, diff --git a/src/allocators/rpmalloc.py b/allocbench/allocators/rpmalloc.py index c27f244..995d109 100644 --- a/src/allocators/rpmalloc.py +++ b/allocbench/allocators/rpmalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """rpmalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Rpmalloc(Allocator): @@ -27,7 +27,7 @@ class Rpmalloc(Allocator): def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/librpmalloc.so" + self.ld_preload = "{dir}/librpmalloc.so" self.build_cmds = [ "cd {srcdir}; ./configure.py", "cd {srcdir}; ninja", "mkdir -p {dir}", @@ -37,4 +37,5 @@ class Rpmalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name rpmalloc = Rpmalloc("rpmalloc", color="xkcd:chestnut", version="1.4.0") diff --git a/src/allocators/scalloc.py b/allocbench/allocators/scalloc.py index c071f22..d009226 100644 --- a/src/allocators/scalloc.py +++ b/allocbench/allocators/scalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Scalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Scalloc(Allocator): @@ -35,15 +35,15 @@ class Scalloc(Allocator): "cd {srcdir}; BUILDTYPE=Release make", "mkdir -p {dir}" ] - self.LD_PRELOAD = "{srcdir}/out/Release/lib.target/libscalloc.so" + self.ld_preload = "{srcdir}/out/Release/lib.target/libscalloc.so" self.patches = ["{patchdir}/scalloc_fix_log.patch"] super().__init__(name, **kwargs) def build(self): - with open("/proc/sys/vm/overcommit_memory", "r") as f: - if f.read()[0] != "1": + with open("/proc/sys/vm/overcommit_memory", "r") as overcommit_memory_file: + if overcommit_memory_file.read()[0] != "1": raise AssertionError("""\ vm.overcommit_memory not set Scalloc needs permission to overcommit_memory. @@ -52,4 +52,5 @@ sysctl vm.overcommit_memory=1 return super().build() +# pylint: disable=invalid-name scalloc = Scalloc("scalloc", color="xkcd:magenta", version="v1.0.0") diff --git a/src/allocators/scalloc/scalloc_fix_log.patch b/allocbench/allocators/scalloc/scalloc_fix_log.patch index 9d4a7d8..9d4a7d8 100644 --- a/src/allocators/scalloc/scalloc_fix_log.patch +++ b/allocbench/allocators/scalloc/scalloc_fix_log.patch diff --git a/src/allocators/snmalloc.py b/allocbench/allocators/snmalloc.py index 2c5dfa8..db59233 100644 --- a/src/allocators/snmalloc.py +++ b/allocbench/allocators/snmalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Snmalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Snmalloc(Allocator): @@ -26,7 +26,7 @@ class Snmalloc(Allocator): sources = GitArtifact("snmalloc", "https://github.com/microsoft/snmalloc") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libsnmallocshim.so" + self.ld_preload = "{dir}/libsnmallocshim.so" self.build_cmds = [ "mkdir -p {dir}", "cd {dir}; cmake -G Ninja {srcdir} -DCMAKE_BUILD_TYPE=Release", @@ -37,4 +37,5 @@ class Snmalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name snmalloc = Snmalloc("snmalloc", version="0.2") diff --git a/src/allocators/speedymalloc.py b/allocbench/allocators/speedymalloc.py index 6fe202a..e9e5f50 100644 --- a/src/allocators/speedymalloc.py +++ b/allocbench/allocators/speedymalloc.py @@ -21,10 +21,10 @@ A bump pointer allocator makes the biggest possible tradeoff between speed and memory in speeds favor. Memory is mmapped per thread and never freed. """ -from src.artifact import GitArtifact -from src.allocator import Allocator +from allocbench.artifact import GitArtifact +from allocbench.allocator import Allocator -VERSION = "dd24b9d24c78c798df97ca5556ba248ccff97ca7" +VERSION = "c448cfab9e089222cbeb3e294c94047cedec72d8" class Speedymalloc(Allocator): @@ -43,10 +43,11 @@ class Speedymalloc(Allocator): f"meson {{srcdir}} {{dir}} {configuration}", "ninja -C {dir}" ] - self.LD_PRELOAD = "{dir}/libspeedymalloc.so" + self.ld_preload = "{dir}/libspeedymalloc.so" super().__init__(name, **kwargs) +# pylint: disable=invalid-name speedymalloc = Speedymalloc("speedymalloc", version=VERSION) speedymalloc_no_madv_free = Speedymalloc("speedymalloc_no_madv_free", @@ -66,11 +67,11 @@ speedymalloc_4095_sc_32 = Speedymalloc("speedymalloc_4095_sc_32", version=VERSION) speedymalloc_4095_sc_128 = Speedymalloc("speedymalloc_4095_sc_128", - options={ - "cache_bins": 4095, - "cache_bin_seperation": 128 - }, - version=VERSION) + options={ + "cache_bins": 4095, + "cache_bin_seperation": 128 + }, + version=VERSION) speedymalloc_only_glab = Speedymalloc( "speedymalloc_only_glab", @@ -81,7 +82,3 @@ speedymalloc_no_glab = Speedymalloc( "speedymalloc_no_glab", options={"max_local_allocation_buffer_size": -1}, version=VERSION) - -# speedymalloc_rseq = Speedymalloc( - # "speedymalloc_rseq", - # version="e1549fa2a2833deba0ba53504a6c67ee31a0e42a") diff --git a/src/allocators/streamflow.py b/allocbench/allocators/streamflow.py index 3b04a21..073e060 100644 --- a/src/allocators/streamflow.py +++ b/allocbench/allocators/streamflow.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """Streamflow allocator definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class Streamflow(Allocator): @@ -27,7 +27,7 @@ class Streamflow(Allocator): def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libstreamflow.so" + self.ld_preload = "{dir}/libstreamflow.so" self.build_cmds = [ "cd {srcdir}; make", "mkdir -p {dir}", "ln -f -s {srcdir}/libstreamflow.so {dir}/libstreamflow.so" @@ -36,6 +36,7 @@ class Streamflow(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name streamflow = Streamflow("Streamflow", version="8ac345c0f69ec9e7af02f3555c2c97eaa07a442e", color="xkcd:light brown") diff --git a/src/allocators/supermalloc.py b/allocbench/allocators/supermalloc.py index 32f9588..35a4e73 100644 --- a/src/allocators/supermalloc.py +++ b/allocbench/allocators/supermalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """SuperMalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class SuperMalloc(Allocator): @@ -27,7 +27,7 @@ class SuperMalloc(Allocator): "https://github.com/kuszmaul/SuperMalloc") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libsupermalloc.so" + self.ld_preload = "{dir}/libsupermalloc.so" self.build_cmds = [ "cd {srcdir}/release; make", "mkdir -p {dir}", "ln -f -s {srcdir}/release/lib/libsupermalloc.so {dir}/libsupermalloc.so" @@ -37,6 +37,7 @@ class SuperMalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name supermalloc = SuperMalloc("SuperMalloc", color="xkcd:lime", version="709663fb81ba091b0a78058869a644a272f4163d") diff --git a/src/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch b/allocbench/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch index 074f758..074f758 100644 --- a/src/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch +++ b/allocbench/allocators/supermalloc/remove_faulty_aligned_alloc_test.patch diff --git a/src/allocators/tbbmalloc.py b/allocbench/allocators/tbbmalloc.py index 6580939..2df3b0e 100644 --- a/src/allocators/tbbmalloc.py +++ b/allocbench/allocators/tbbmalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """tbbmalloc definition for allocbench""" -from src.allocator import Allocator -from src.artifact import GitArtifact +from allocbench.allocator import Allocator +from allocbench.artifact import GitArtifact class TBBMalloc(Allocator): @@ -26,7 +26,7 @@ class TBBMalloc(Allocator): sources = GitArtifact("tbb", "https://github.com/intel/tbb.git") def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libtbbmalloc.so" + self.ld_preload = "{dir}/libtbbmalloc.so" self.build_cmds = [ "cd {srcdir}; make tbbmalloc -j4", "mkdir -p {dir}", 'ln -f -s $(find {srcdir} -executable -name "*libtbbmalloc_proxy.so*" | head -1) {dir}/libtbbmalloc.so' @@ -35,4 +35,5 @@ class TBBMalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name tbbmalloc = TBBMalloc("tbbmalloc", color="xkcd:green", version="2019_U8") diff --git a/src/allocators/tcmalloc.py b/allocbench/allocators/tcmalloc.py index 7f67146..450b613 100644 --- a/src/allocators/tcmalloc.py +++ b/allocbench/allocators/tcmalloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. """TCMalloc definition for allocbench""" -from src.allocator import Allocator, BUILDDIR -from src.artifact import GitArtifact +from allocbench.allocator import Allocator, BUILDDIR +from allocbench.artifact import GitArtifact class TCMalloc(Allocator): @@ -27,7 +27,7 @@ class TCMalloc(Allocator): def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/libtcmalloc.so" + self.ld_preload = "{dir}/libtcmalloc.so" self.patches = ["{patchdir}/tcmalloc_bazel_build_so.patch"] self.build_cmds = [ "cd {srcdir}; bazel build tcmalloc/tcmalloc.so --compilation_mode opt", @@ -38,6 +38,7 @@ class TCMalloc(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name tcmalloc = TCMalloc("TCMalloc", color="xkcd:blue", version="1676100265bd189df6b5513feac15f102542367e") @@ -46,7 +47,8 @@ tcmalloc_align = TCMalloc("TCMalloc-Aligned", version="1676100265bd189df6b5513feac15f102542367e", color="xkcd:light blue") -tcmalloc_align.LD_PRELOAD = f"{BUILDDIR}/align_to_cl.so {tcmalloc_align.LD_PRELOAD}" +tcmalloc_align.ld_preload = f"{BUILDDIR}/align_to_cl.so {tcmalloc_align.ld_preload}" +# pylint: enable=invalid-name class TCMallocGperftools(Allocator): @@ -57,7 +59,7 @@ class TCMallocGperftools(Allocator): def __init__(self, name, **kwargs): - self.LD_PRELOAD = "{dir}/lib/libtcmalloc.so" + self.ld_preload = "{dir}/lib/libtcmalloc.so" self.prepare_cmds = ["./autogen.sh"] self.build_cmds = [ "cd {srcdir}; ./configure --prefix={dir}", @@ -67,6 +69,7 @@ class TCMallocGperftools(Allocator): super().__init__(name, **kwargs) +# pylint: disable=invalid-name tcmalloc_gperftools = TCMallocGperftools("TCMalloc-gperftools", color="xkcd:dark blue", version="gperftools-2.7") @@ -81,7 +84,8 @@ tcmalloc_gperftools_align = TCMallocGperftools("TCMalloc-Gperftools-Aligned", version="gperftools-2.7", color="xkcd:navy blue") -tcmalloc_gperftools_align.LD_PRELOAD = f"{BUILDDIR}/align_to_cl.so {tcmalloc_gperftools_align.LD_PRELOAD}" +tcmalloc_gperftools_align.ld_preload = (f"{BUILDDIR}/align_to_cl.so " + f"{tcmalloc_gperftools_align.ld_preload}") tcmalloc_gperftools_cacheline_exclusive = TCMallocGperftools( "TCMalloc-Gperftools-Cacheline-Exclusive", diff --git a/src/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch b/allocbench/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch index bdd63e3..bdd63e3 100644 --- a/src/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch +++ b/allocbench/allocators/tcmalloc/tcmalloc_2.7_cacheline_exclusive.patch diff --git a/src/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch b/allocbench/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch index a76a2f2..a76a2f2 100644 --- a/src/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch +++ b/allocbench/allocators/tcmalloc/tcmalloc_2.7_no_active_falsesharing.patch diff --git a/src/allocators/tcmalloc/tcmalloc_bazel_build_so.patch b/allocbench/allocators/tcmalloc/tcmalloc_bazel_build_so.patch index cdd2840..cdd2840 100644 --- a/src/allocators/tcmalloc/tcmalloc_bazel_build_so.patch +++ b/allocbench/allocators/tcmalloc/tcmalloc_bazel_build_so.patch diff --git a/src/analyse.py b/allocbench/analyse.py index bd08c98..6b7fb4b 100755..100644 --- a/src/analyse.py +++ b/allocbench/analyse.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - # Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. @@ -22,32 +20,23 @@ import importlib import os import traceback -from src.util import find_cmd -from src.util import print_status, print_warn, print_error -from src.util import print_info2, print_debug - -ANALYZSE_ALLOC_NAME = None -ANALYZSE_ALLOC_DICT = None +from allocbench.util import find_cmd +from allocbench.util import print_status, print_warn, print_error +from allocbench.util import print_info2, print_debug def build_analyze_alloc(): """Select and build available analysis allocator""" - global ANALYZSE_ALLOC_NAME - global ANALYZSE_ALLOC_DICT - if ANALYZSE_ALLOC_DICT is not None: - return - if find_cmd("malt") is not None: - ANALYZSE_ALLOC_NAME = "malt" + alloc_name = "malt" else: print_warn("malt not found. Using chattymalloc.") - ANALYZSE_ALLOC_NAME = "chattymalloc" + alloc_name = "chattymalloc" analyze_alloc_module = importlib.import_module( - f"src.allocators.{ANALYZSE_ALLOC_NAME}") + f"allocbench.allocators.{alloc_name}") - ANALYZSE_ALLOC_DICT = getattr(analyze_alloc_module, - ANALYZSE_ALLOC_NAME).build() + return alloc_name, getattr(analyze_alloc_module, alloc_name).build() def analyze_bench(bench): @@ -59,15 +48,16 @@ def analyze_bench(bench): print_info2("Creating benchmark result dir:", bench.result_dir) os.makedirs(bench.result_dir, exist_ok=True) - build_analyze_alloc() + alloc_name, alloc_dict = build_analyze_alloc() old_allocs = bench.allocators old_measure_cmd = bench.measure_cmd bench.measure_cmd = "" - bench.allocators = {ANALYZSE_ALLOC_NAME: ANALYZSE_ALLOC_DICT} + bench.allocators = {alloc_name: alloc_dict} try: bench.run(runs=1) + # TODO: Introduce BenchmarkException except Exception: print_debug(traceback.format_exc()) print_error("Skipping analysis of", bench, "!") @@ -75,11 +65,10 @@ def analyze_bench(bench): bench.measure_cmd = old_measure_cmd # Remove results for analyze_alloc - if ANALYZSE_ALLOC_NAME in bench.results: - del bench.results[ANALYZSE_ALLOC_NAME] - if "stats" in bench.results and ANALYZSE_ALLOC_NAME in bench.results[ - "stats"]: - del bench.results["stats"][ANALYZSE_ALLOC_NAME] + if alloc_name in bench.results: + del bench.results[alloc_name] + if "stats" in bench.results and alloc_name in bench.results["stats"]: + del bench.results["stats"][alloc_name] # restore allocs bench.allocators = old_allocs @@ -88,7 +77,7 @@ def analyze_bench(bench): def analyze_allocators(bench, allocators): """Analyse a single benchmark for each allocator in allocators""" # build analyzse allocator before globaly setting LD_PRELOAD - build_analyze_alloc() + alloc_name, alloc_dict = build_analyze_alloc() for name, alloc in allocators.items(): print_status(f"Analysing {name} during {bench} ...") @@ -103,7 +92,7 @@ def analyze_allocators(bench, allocators): else: perm_fmt = "" else: - perm_fmt = ANALYZSE_ALLOC_NAME + perm_fmt = alloc_name old_trace = os.path.join(bench.result_dir, f"{perm_fmt}.trace") new_trace = os.path.join(bench.result_dir, diff --git a/src/artifact.py b/allocbench/artifact.py index ecedbe9..3504486 100644 --- a/src/artifact.py +++ b/allocbench/artifact.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -25,10 +25,10 @@ with a specific checkout. import os from subprocess import CalledProcessError -import src.globalvars -from src.util import print_status, print_info, print_debug, print_error, run_cmd, sha1sum +from allocbench.globalvars import ALLOCBENCHDIR +from allocbench.util import print_status, print_info, print_debug, print_error, run_cmd, sha1sum -ARTIFACT_STORE_DIR = os.path.join(src.globalvars.allocbenchdir, "cache") +ARTIFACT_STORE_DIR = os.path.join(ALLOCBENCHDIR, "cache") class Artifact: diff --git a/src/benchmark.py b/allocbench/benchmark.py index 2fb2606..b08118a 100644 --- a/src/benchmark.py +++ b/allocbench/benchmark.py @@ -30,10 +30,11 @@ import traceback import numpy as np -import src.globalvars -import src.util -from src.util import print_status, print_error, print_warn -from src.util import print_info0, print_info, print_debug +import allocbench.facter as facter +import allocbench.globalvars as globalvars +from allocbench.util import print_status, print_error, print_warn +from allocbench.util import print_info0, print_info, print_debug +from allocbench.util import find_cmd, prefix_cmd_with_abspath class Benchmark: @@ -47,7 +48,7 @@ class Benchmark: measure_cmd_csv = False measure_cmd = "perf stat -x, -d" servers = [] - allocators = copy.deepcopy(src.globalvars.allocators) + allocators = copy.deepcopy(globalvars.ALLOCATORS) @staticmethod def terminate_subprocess(proc, timeout=5): @@ -122,11 +123,11 @@ class Benchmark: # Set result_dir if not hasattr(self, "result_dir"): - self.result_dir = os.path.abspath(os.path.join(src.globalvars.resdir or "", + self.result_dir = os.path.abspath(os.path.join(globalvars.RESDIR or "", self.name)) # Set build_dir if not hasattr(self, "build_dir"): - self.build_dir = os.path.abspath(os.path.join(src.globalvars.builddir, + self.build_dir = os.path.abspath(os.path.join(globalvars.BUILDDIR, "benchmarks", self.name)) self.Perm = namedtuple("Perm", self.args.keys()) @@ -239,12 +240,12 @@ class Benchmark: def prepare(self): """default prepare implementation raising an error if a requirement is not found""" - os.environ["PATH"] += f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}" + os.environ["PATH"] += f"{os.pathsep}{globalvars.BUILDDIR}/benchmarks/{self.name}" for r in self.requirements: - exe = src.util.find_cmd(r) + exe = find_cmd(r) if exe is not None: - self.results["facts"]["libcs"][r] = src.facter.libc_ver(executable=exe) + self.results["facts"]["libcs"][r] = facter.libc_ver(executable=exe) else: raise Exception("Requirement: {} not found".format(r)) @@ -298,17 +299,17 @@ class Benchmark: prefix_argv = alloc["cmd_prefix"].format(**substitutions).split() argv.extend(prefix_argv) # add exec wrapper so that a possible prefixed loader can execute shell scripts - argv.append(f"{src.globalvars.builddir}/exec") + argv.append(f"{globalvars.BUILDDIR}/exec") if self.measure_cmd != "": measure_argv = self.measure_cmd.format(**substitutions) - measure_argv = src.util.prefix_cmd_with_abspath(measure_argv).split() + measure_argv = prefix_cmd_with_abspath(measure_argv).split() argv.extend(measure_argv) - argv.append(f"{src.globalvars.builddir}/exec") + argv.append(f"{globalvars.BUILDDIR}/exec") - ld_preload = f"{src.globalvars.builddir}/print_status_on_exit.so" - ld_preload += f" {src.globalvars.builddir}/sig_handlers.so" + ld_preload = f"{globalvars.BUILDDIR}/print_status_on_exit.so" + ld_preload += f" {globalvars.BUILDDIR}/sig_handlers.so" if "LD_PRELOAD" in env or alloc.get("LD_PRELOAD", ""): ld_preload += f" {alloc.get('LD_PRELOAD', '')}" @@ -320,7 +321,7 @@ class Benchmark: argv.extend(["-l", f"{alloc.get('LD_LIBRARY_PATH', '')} {env.get('LD_LIBRARY_PATH', '')}"]) cmd_argv = cmd.format(**substitutions) - cmd_argv = src.util.prefix_cmd_with_abspath(cmd_argv).split() + cmd_argv = prefix_cmd_with_abspath(cmd_argv).split() argv.extend(cmd_argv) @@ -334,7 +335,7 @@ class Benchmark: substitutions = {"alloc": alloc_name, "perm": alloc_name, - "builddir": src.globalvars.builddir} + "builddir": globalvars.BUILDDIR} substitutions.update(self.__dict__) substitutions.update(alloc) @@ -426,7 +427,7 @@ class Benchmark: Benchmark.is_perf_allowed() # add benchmark dir to PATH - os.environ["PATH"] += f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}" + os.environ["PATH"] += f"{os.pathsep}{globalvars.BUILDDIR}/benchmarks/{self.name}" # save one valid result to expand invalid results valid_result = {} @@ -453,7 +454,7 @@ class Benchmark: # Preallocator hook if hasattr(self, "preallocator_hook"): - self.preallocator_hook((alloc_name, alloc), run, os.environ) + self.preallocator_hook((alloc_name, alloc), run, os.environ) # pylint: disable=no-member # Run benchmark for alloc for perm in self.iterate_args(): @@ -489,7 +490,7 @@ class Benchmark: cwd = os.getcwd() if hasattr(self, "run_dir"): - run_dir = self.run_dir.format(**substitutions) + run_dir = self.run_dir.format(**substitutions) # pylint: disable=no-member os.chdir(run_dir) print_debug("\nChange cwd to:", run_dir) @@ -551,7 +552,7 @@ class Benchmark: if hasattr(self, "process_output"): - self.process_output(result, res.stdout, res.stderr, + self.process_output(result, res.stdout, res.stderr, # pylint: disable=no-member alloc_name, perm) @@ -574,12 +575,12 @@ class Benchmark: server_result["returncode"].append(server["popen"].returncode) if hasattr(self, "postallocator_hook"): - self.postallocator_hook((alloc_name, alloc), run) + self.postallocator_hook((alloc_name, alloc), run) # pylint: disable=no-member print() # reset PATH - os.environ["PATH"] = os.environ["PATH"].replace(f"{os.pathsep}{src.globalvars.builddir}/benchmarks/{self.name}", "") + os.environ["PATH"] = os.environ["PATH"].replace(f"{os.pathsep}{globalvars.BUILDDIR}/benchmarks/{self.name}", "") # expand invalid results if valid_result != {}: diff --git a/src/benchmarks/__init__.py b/allocbench/benchmarks/__init__.py index 68b5e56..68b5e56 100644 --- a/src/benchmarks/__init__.py +++ b/allocbench/benchmarks/__init__.py diff --git a/src/benchmarks/blowup.py b/allocbench/benchmarks/blowup.py index a4e65ea..c4d5b5b 100644 --- a/src/benchmarks/blowup.py +++ b/allocbench/benchmarks/blowup.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. If not, see <http://www.gnu.org/licenses/>. """Definition of the blowup micro benchmark""" -from src.benchmark import Benchmark -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt class BenchmarkBlowup(Benchmark): diff --git a/src/benchmarks/blowup/Makefile b/allocbench/benchmarks/blowup/Makefile index afb5f2a..afb5f2a 100644 --- a/src/benchmarks/blowup/Makefile +++ b/allocbench/benchmarks/blowup/Makefile diff --git a/src/benchmarks/blowup/blowup.c b/allocbench/benchmarks/blowup/blowup.c index 37ba6d6..37ba6d6 100644 --- a/src/benchmarks/blowup/blowup.c +++ b/allocbench/benchmarks/blowup/blowup.c diff --git a/src/benchmarks/cfrac.py b/allocbench/benchmarks/cfrac.py index 1f495e6..9a2628a 100644 --- a/src/benchmarks/cfrac.py +++ b/allocbench/benchmarks/cfrac.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -58,8 +58,8 @@ The relevant non functional allocator properties are the raw speed of the API function as well as memory placement strategies with good data locality. """ -from src.benchmark import Benchmark -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt class BenchmarkCfrac(Benchmark): @@ -86,16 +86,15 @@ class BenchmarkCfrac(Benchmark): file_postfix="time") # L1 cache misses - plt.plot( - self, - "({L1-dcache-load-misses}/{L1-dcache-loads})*100", - plot_type='bar', - fig_options={ - 'ylabel': "L1 misses in %", - 'title': "Cfrac l1 cache misses", - 'yerr': False - }, - file_postfix="l1misses") + plt.plot(self, + "({L1-dcache-load-misses}/{L1-dcache-loads})*100", + plot_type='bar', + fig_options={ + 'ylabel': "L1 misses in %", + 'title': "Cfrac l1 cache misses", + 'yerr': False + }, + file_postfix="l1misses") # Memusage plt.plot(self, @@ -116,7 +115,7 @@ class BenchmarkCfrac(Benchmark): "expression": "{VmHWM}", "sort": "<" }], - file_postfix="table") + file_postfix="table") plt.export_stats_to_dataref(self, "task-clock") diff --git a/src/benchmarks/cfrac/CMakeLists.txt b/allocbench/benchmarks/cfrac/CMakeLists.txt index b84d68c..b84d68c 100644 --- a/src/benchmarks/cfrac/CMakeLists.txt +++ b/allocbench/benchmarks/cfrac/CMakeLists.txt diff --git a/src/benchmarks/cfrac/README.md b/allocbench/benchmarks/cfrac/README.md index 529480a..529480a 100644 --- a/src/benchmarks/cfrac/README.md +++ b/allocbench/benchmarks/cfrac/README.md diff --git a/src/benchmarks/cfrac/asm16bit.h b/allocbench/benchmarks/cfrac/asm16bit.h index 2fb6e48..2fb6e48 100644 --- a/src/benchmarks/cfrac/asm16bit.h +++ b/allocbench/benchmarks/cfrac/asm16bit.h diff --git a/src/benchmarks/cfrac/atop.c b/allocbench/benchmarks/cfrac/atop.c index 98f132a..98f132a 100644 --- a/src/benchmarks/cfrac/atop.c +++ b/allocbench/benchmarks/cfrac/atop.c diff --git a/src/benchmarks/cfrac/cfrac.c b/allocbench/benchmarks/cfrac/cfrac.c index 9185d18..9185d18 100644 --- a/src/benchmarks/cfrac/cfrac.c +++ b/allocbench/benchmarks/cfrac/cfrac.c diff --git a/src/benchmarks/cfrac/errorp.c b/allocbench/benchmarks/cfrac/errorp.c index 5868aa4..5868aa4 100644 --- a/src/benchmarks/cfrac/errorp.c +++ b/allocbench/benchmarks/cfrac/errorp.c diff --git a/src/benchmarks/cfrac/getopt.c b/allocbench/benchmarks/cfrac/getopt.c index 788c2cb..788c2cb 100644 --- a/src/benchmarks/cfrac/getopt.c +++ b/allocbench/benchmarks/cfrac/getopt.c diff --git a/src/benchmarks/cfrac/getopt.h b/allocbench/benchmarks/cfrac/getopt.h index 7fc2cca..7fc2cca 100644 --- a/src/benchmarks/cfrac/getopt.h +++ b/allocbench/benchmarks/cfrac/getopt.h diff --git a/src/benchmarks/cfrac/itop.c b/allocbench/benchmarks/cfrac/itop.c index 87d309a..87d309a 100644 --- a/src/benchmarks/cfrac/itop.c +++ b/allocbench/benchmarks/cfrac/itop.c diff --git a/src/benchmarks/cfrac/ltop.c b/allocbench/benchmarks/cfrac/ltop.c index 33eaea5..33eaea5 100644 --- a/src/benchmarks/cfrac/ltop.c +++ b/allocbench/benchmarks/cfrac/ltop.c diff --git a/src/benchmarks/cfrac/pabs.c b/allocbench/benchmarks/cfrac/pabs.c index 674cf1b..674cf1b 100644 --- a/src/benchmarks/cfrac/pabs.c +++ b/allocbench/benchmarks/cfrac/pabs.c diff --git a/src/benchmarks/cfrac/padd.c b/allocbench/benchmarks/cfrac/padd.c index 62b93d5..62b93d5 100644 --- a/src/benchmarks/cfrac/padd.c +++ b/allocbench/benchmarks/cfrac/padd.c diff --git a/src/benchmarks/cfrac/pcfrac.c b/allocbench/benchmarks/cfrac/pcfrac.c index 2a0d032..2a0d032 100644 --- a/src/benchmarks/cfrac/pcfrac.c +++ b/allocbench/benchmarks/cfrac/pcfrac.c diff --git a/src/benchmarks/cfrac/pcmp.c b/allocbench/benchmarks/cfrac/pcmp.c index 2c8e0b8..2c8e0b8 100644 --- a/src/benchmarks/cfrac/pcmp.c +++ b/allocbench/benchmarks/cfrac/pcmp.c diff --git a/src/benchmarks/cfrac/pconst.c b/allocbench/benchmarks/cfrac/pconst.c index 89b63a7..89b63a7 100644 --- a/src/benchmarks/cfrac/pconst.c +++ b/allocbench/benchmarks/cfrac/pconst.c diff --git a/src/benchmarks/cfrac/pcvt.h b/allocbench/benchmarks/cfrac/pcvt.h index e2dd724..e2dd724 100644 --- a/src/benchmarks/cfrac/pcvt.h +++ b/allocbench/benchmarks/cfrac/pcvt.h diff --git a/src/benchmarks/cfrac/pdefs.h b/allocbench/benchmarks/cfrac/pdefs.h index 9c43099..9c43099 100644 --- a/src/benchmarks/cfrac/pdefs.h +++ b/allocbench/benchmarks/cfrac/pdefs.h diff --git a/src/benchmarks/cfrac/pdivmod.c b/allocbench/benchmarks/cfrac/pdivmod.c index ce4a24b..ce4a24b 100644 --- a/src/benchmarks/cfrac/pdivmod.c +++ b/allocbench/benchmarks/cfrac/pdivmod.c diff --git a/src/benchmarks/cfrac/pfactor.c b/allocbench/benchmarks/cfrac/pfactor.c index 6c765d1..6c765d1 100644 --- a/src/benchmarks/cfrac/pfactor.c +++ b/allocbench/benchmarks/cfrac/pfactor.c diff --git a/src/benchmarks/cfrac/pfactor.h b/allocbench/benchmarks/cfrac/pfactor.h index edd5686..edd5686 100644 --- a/src/benchmarks/cfrac/pfactor.h +++ b/allocbench/benchmarks/cfrac/pfactor.h diff --git a/src/benchmarks/cfrac/pfloat.c b/allocbench/benchmarks/cfrac/pfloat.c index 63f4344..63f4344 100644 --- a/src/benchmarks/cfrac/pfloat.c +++ b/allocbench/benchmarks/cfrac/pfloat.c diff --git a/src/benchmarks/cfrac/pgcd.c b/allocbench/benchmarks/cfrac/pgcd.c index a72a8a7..a72a8a7 100644 --- a/src/benchmarks/cfrac/pgcd.c +++ b/allocbench/benchmarks/cfrac/pgcd.c diff --git a/src/benchmarks/cfrac/phalf.c b/allocbench/benchmarks/cfrac/phalf.c index 8658de5..8658de5 100644 --- a/src/benchmarks/cfrac/phalf.c +++ b/allocbench/benchmarks/cfrac/phalf.c diff --git a/src/benchmarks/cfrac/picmp.c b/allocbench/benchmarks/cfrac/picmp.c index b942268..b942268 100644 --- a/src/benchmarks/cfrac/picmp.c +++ b/allocbench/benchmarks/cfrac/picmp.c diff --git a/src/benchmarks/cfrac/pidiv.c b/allocbench/benchmarks/cfrac/pidiv.c index 61c09a7..61c09a7 100644 --- a/src/benchmarks/cfrac/pidiv.c +++ b/allocbench/benchmarks/cfrac/pidiv.c diff --git a/src/benchmarks/cfrac/pimod.c b/allocbench/benchmarks/cfrac/pimod.c index b26536d..b26536d 100644 --- a/src/benchmarks/cfrac/pimod.c +++ b/allocbench/benchmarks/cfrac/pimod.c diff --git a/src/benchmarks/cfrac/pio.c b/allocbench/benchmarks/cfrac/pio.c index 16b5bda..16b5bda 100644 --- a/src/benchmarks/cfrac/pio.c +++ b/allocbench/benchmarks/cfrac/pio.c diff --git a/src/benchmarks/cfrac/pmul.c b/allocbench/benchmarks/cfrac/pmul.c index e69a366..e69a366 100644 --- a/src/benchmarks/cfrac/pmul.c +++ b/allocbench/benchmarks/cfrac/pmul.c diff --git a/src/benchmarks/cfrac/pneg.c b/allocbench/benchmarks/cfrac/pneg.c index c781066..c781066 100644 --- a/src/benchmarks/cfrac/pneg.c +++ b/allocbench/benchmarks/cfrac/pneg.c diff --git a/src/benchmarks/cfrac/podd.c b/allocbench/benchmarks/cfrac/podd.c index def95b4..def95b4 100644 --- a/src/benchmarks/cfrac/podd.c +++ b/allocbench/benchmarks/cfrac/podd.c diff --git a/src/benchmarks/cfrac/pops.c b/allocbench/benchmarks/cfrac/pops.c index 7154dd7..7154dd7 100644 --- a/src/benchmarks/cfrac/pops.c +++ b/allocbench/benchmarks/cfrac/pops.c diff --git a/src/benchmarks/cfrac/ppowmod.c b/allocbench/benchmarks/cfrac/ppowmod.c index 4528db9..4528db9 100644 --- a/src/benchmarks/cfrac/ppowmod.c +++ b/allocbench/benchmarks/cfrac/ppowmod.c diff --git a/src/benchmarks/cfrac/precision.h b/allocbench/benchmarks/cfrac/precision.h index 28befce..28befce 100644 --- a/src/benchmarks/cfrac/precision.h +++ b/allocbench/benchmarks/cfrac/precision.h diff --git a/src/benchmarks/cfrac/primes.c b/allocbench/benchmarks/cfrac/primes.c index f9dbd84..f9dbd84 100644 --- a/src/benchmarks/cfrac/primes.c +++ b/allocbench/benchmarks/cfrac/primes.c diff --git a/src/benchmarks/cfrac/primes.h b/allocbench/benchmarks/cfrac/primes.h index 206f480..206f480 100644 --- a/src/benchmarks/cfrac/primes.h +++ b/allocbench/benchmarks/cfrac/primes.h diff --git a/src/benchmarks/cfrac/psqrt.c b/allocbench/benchmarks/cfrac/psqrt.c index 00531a6..00531a6 100644 --- a/src/benchmarks/cfrac/psqrt.c +++ b/allocbench/benchmarks/cfrac/psqrt.c diff --git a/src/benchmarks/cfrac/psub.c b/allocbench/benchmarks/cfrac/psub.c index d887287..d887287 100644 --- a/src/benchmarks/cfrac/psub.c +++ b/allocbench/benchmarks/cfrac/psub.c diff --git a/src/benchmarks/cfrac/ptoa.c b/allocbench/benchmarks/cfrac/ptoa.c index a928ea2..a928ea2 100644 --- a/src/benchmarks/cfrac/ptoa.c +++ b/allocbench/benchmarks/cfrac/ptoa.c diff --git a/src/benchmarks/cfrac/ptob.c b/allocbench/benchmarks/cfrac/ptob.c index d5b04c1..d5b04c1 100644 --- a/src/benchmarks/cfrac/ptob.c +++ b/allocbench/benchmarks/cfrac/ptob.c diff --git a/src/benchmarks/cfrac/ptou.c b/allocbench/benchmarks/cfrac/ptou.c index b8ca07b..b8ca07b 100644 --- a/src/benchmarks/cfrac/ptou.c +++ b/allocbench/benchmarks/cfrac/ptou.c diff --git a/src/benchmarks/cfrac/seive.h b/allocbench/benchmarks/cfrac/seive.h index 2e1cb85..2e1cb85 100644 --- a/src/benchmarks/cfrac/seive.h +++ b/allocbench/benchmarks/cfrac/seive.h diff --git a/src/benchmarks/cfrac/utop.c b/allocbench/benchmarks/cfrac/utop.c index 4d87c04..4d87c04 100644 --- a/src/benchmarks/cfrac/utop.c +++ b/allocbench/benchmarks/cfrac/utop.c diff --git a/src/benchmarks/dj_trace.py b/allocbench/benchmarks/dj_trace.py index 22398e6..b0ec7e1 100644 --- a/src/benchmarks/dj_trace.py +++ b/allocbench/benchmarks/dj_trace.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -24,11 +24,11 @@ from urllib.request import urlretrieve import matplotlib.pyplot as plt import numpy as np -from src.artifact import ArchiveArtifact -from src.benchmark import Benchmark -from src.globalvars import summary_file_ext -import src.plots as abplt -from src.util import print_status +from allocbench.artifact import ArchiveArtifact +from allocbench.benchmark import Benchmark +from allocbench.globalvars import SUMMARY_FILE_EXT +import allocbench.plots as abplt +from allocbench.util import print_status COMMA_SEP_NUMBER_RE = "(?:\\d*(?:,\\d*)?)*" RSS_RE = f"(?P<rss>{COMMA_SEP_NUMBER_RE})" @@ -147,7 +147,7 @@ class BenchmarkDJTrace(Benchmark): self.workload_dir = workloads.provide() @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument def to_int(string): return int(string.replace(',', "")) @@ -219,7 +219,7 @@ class BenchmarkDJTrace(Benchmark): plt.ylabel("cycles") plt.title(f"Avg. runtime of API functions {perm.workload}") plt.savefig(".".join( - [self.name, perm.workload, "apitimes", summary_file_ext])) + [self.name, perm.workload, "apitimes", SUMMARY_FILE_EXT])) plt.clf() # Memusage @@ -276,7 +276,7 @@ class BenchmarkDJTrace(Benchmark): plt.ylabel("Max RSS in MB") plt.title(f"Maximal RSS (VmHWM) {perm.workload}") plt.savefig(".".join( - [self.name, perm.workload, "rss", summary_file_ext])) + [self.name, perm.workload, "rss", SUMMARY_FILE_EXT])) plt.clf() abplt.export_stats_to_csv(self, "Max_RSS") @@ -377,7 +377,8 @@ class BenchmarkDJTrace(Benchmark): file=f) for perm in self.iterate_args(args=args): - cycles = abplt._get_y_data(self, "{cycles}", allocator, perm)[0] + cycles = abplt._get_y_data(self, "{cycles}", allocator, + perm)[0] times = [t for t in func_times_means[allocator][perm]] rss = rss_means[allocator][perm] print(fmt.format(perm.workload, cycles, times[0], times[1], diff --git a/src/benchmarks/dj_trace/Makefile b/allocbench/benchmarks/dj_trace/Makefile index 0b04678..0b04678 100644 --- a/src/benchmarks/dj_trace/Makefile +++ b/allocbench/benchmarks/dj_trace/Makefile diff --git a/src/benchmarks/dj_trace/trace_run.c b/allocbench/benchmarks/dj_trace/trace_run.c index 604d01e..604d01e 100644 --- a/src/benchmarks/dj_trace/trace_run.c +++ b/allocbench/benchmarks/dj_trace/trace_run.c diff --git a/src/benchmarks/espresso.py b/allocbench/benchmarks/espresso.py index 4671822..6be9ce4 100644 --- a/src/benchmarks/espresso.py +++ b/allocbench/benchmarks/espresso.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -57,9 +57,9 @@ API function as well as memory placement strategies with good data locality. import os -from src.benchmark import Benchmark -import src.globalvars -import src.plots as plt +from allocbench.benchmark import Benchmark +from allocbench.globalvars import BENCHSRCDIR +import allocbench.plots as plt class BenchmarkEspresso(Benchmark): @@ -69,10 +69,8 @@ class BenchmarkEspresso(Benchmark): self.cmd = "espresso{binary_suffix} {file}" self.args = { - "file": [ - os.path.join(src.globalvars.benchsrcdir, name, - "largest.espresso") - ] + "file": + [os.path.join(BENCHSRCDIR, name, "largest.espresso")] } self.requirements = ["espresso"] @@ -84,8 +82,8 @@ class BenchmarkEspresso(Benchmark): "{task-clock}/1000", plot_type='bar', fig_options={ - 'ylabel': "cpu-second", - 'title': "Espresso: runtime", + 'ylabel': "cpu-second", + 'title': "Espresso: runtime", }, file_postfix="time") @@ -93,9 +91,9 @@ class BenchmarkEspresso(Benchmark): plt.plot(self, "({L1-dcache-load-misses}/{L1-dcache-loads})*100", fig_options={ - 'ylabel': "L1 misses in %", - 'title': "Espresso l1 cache misses", - 'yerr': False + 'ylabel': "L1 misses in %", + 'title': "Espresso l1 cache misses", + 'yerr': False }, file_postfix="l1misses") diff --git a/src/benchmarks/espresso/CMakeLists.txt b/allocbench/benchmarks/espresso/CMakeLists.txt index cc5dac2..cc5dac2 100644 --- a/src/benchmarks/espresso/CMakeLists.txt +++ b/allocbench/benchmarks/espresso/CMakeLists.txt diff --git a/src/benchmarks/espresso/README.md b/allocbench/benchmarks/espresso/README.md index 7cc0d93..7cc0d93 100644 --- a/src/benchmarks/espresso/README.md +++ b/allocbench/benchmarks/espresso/README.md diff --git a/src/benchmarks/espresso/ansi.h b/allocbench/benchmarks/espresso/ansi.h index 81e482f..81e482f 100644 --- a/src/benchmarks/espresso/ansi.h +++ b/allocbench/benchmarks/espresso/ansi.h diff --git a/src/benchmarks/espresso/cofactor.c b/allocbench/benchmarks/espresso/cofactor.c index e082695..e082695 100644 --- a/src/benchmarks/espresso/cofactor.c +++ b/allocbench/benchmarks/espresso/cofactor.c diff --git a/src/benchmarks/espresso/cols.c b/allocbench/benchmarks/espresso/cols.c index 0bfa160..0bfa160 100644 --- a/src/benchmarks/espresso/cols.c +++ b/allocbench/benchmarks/espresso/cols.c diff --git a/src/benchmarks/espresso/compl.c b/allocbench/benchmarks/espresso/compl.c index d0db019..d0db019 100644 --- a/src/benchmarks/espresso/compl.c +++ b/allocbench/benchmarks/espresso/compl.c diff --git a/src/benchmarks/espresso/contain.c b/allocbench/benchmarks/espresso/contain.c index 6b9c644..6b9c644 100644 --- a/src/benchmarks/espresso/contain.c +++ b/allocbench/benchmarks/espresso/contain.c diff --git a/src/benchmarks/espresso/copyright.h b/allocbench/benchmarks/espresso/copyright.h index 49c2f0b..49c2f0b 100644 --- a/src/benchmarks/espresso/copyright.h +++ b/allocbench/benchmarks/espresso/copyright.h diff --git a/src/benchmarks/espresso/cubestr.c b/allocbench/benchmarks/espresso/cubestr.c index 93ca911..93ca911 100644 --- a/src/benchmarks/espresso/cubestr.c +++ b/allocbench/benchmarks/espresso/cubestr.c diff --git a/src/benchmarks/espresso/cvrin.c b/allocbench/benchmarks/espresso/cvrin.c index d3388fb..d3388fb 100644 --- a/src/benchmarks/espresso/cvrin.c +++ b/allocbench/benchmarks/espresso/cvrin.c diff --git a/src/benchmarks/espresso/cvrm.c b/allocbench/benchmarks/espresso/cvrm.c index 1fb21e2..1fb21e2 100644 --- a/src/benchmarks/espresso/cvrm.c +++ b/allocbench/benchmarks/espresso/cvrm.c diff --git a/src/benchmarks/espresso/cvrmisc.c b/allocbench/benchmarks/espresso/cvrmisc.c index f0be0c3..f0be0c3 100644 --- a/src/benchmarks/espresso/cvrmisc.c +++ b/allocbench/benchmarks/espresso/cvrmisc.c diff --git a/src/benchmarks/espresso/cvrout.c b/allocbench/benchmarks/espresso/cvrout.c index a8c7e67..a8c7e67 100644 --- a/src/benchmarks/espresso/cvrout.c +++ b/allocbench/benchmarks/espresso/cvrout.c diff --git a/src/benchmarks/espresso/dominate.c b/allocbench/benchmarks/espresso/dominate.c index 882a43c..882a43c 100644 --- a/src/benchmarks/espresso/dominate.c +++ b/allocbench/benchmarks/espresso/dominate.c diff --git a/src/benchmarks/espresso/equiv.c b/allocbench/benchmarks/espresso/equiv.c index be10542..be10542 100644 --- a/src/benchmarks/espresso/equiv.c +++ b/allocbench/benchmarks/espresso/equiv.c diff --git a/src/benchmarks/espresso/espresso.c b/allocbench/benchmarks/espresso/espresso.c index 41dc1d3..41dc1d3 100644 --- a/src/benchmarks/espresso/espresso.c +++ b/allocbench/benchmarks/espresso/espresso.c diff --git a/src/benchmarks/espresso/espresso.h b/allocbench/benchmarks/espresso/espresso.h index 38670e4..38670e4 100644 --- a/src/benchmarks/espresso/espresso.h +++ b/allocbench/benchmarks/espresso/espresso.h diff --git a/src/benchmarks/espresso/essen.c b/allocbench/benchmarks/espresso/essen.c index 52a1655..52a1655 100644 --- a/src/benchmarks/espresso/essen.c +++ b/allocbench/benchmarks/espresso/essen.c diff --git a/src/benchmarks/espresso/exact.c b/allocbench/benchmarks/espresso/exact.c index 336a3ff..336a3ff 100644 --- a/src/benchmarks/espresso/exact.c +++ b/allocbench/benchmarks/espresso/exact.c diff --git a/src/benchmarks/espresso/expand.c b/allocbench/benchmarks/espresso/expand.c index 8eb7239..8eb7239 100644 --- a/src/benchmarks/espresso/expand.c +++ b/allocbench/benchmarks/espresso/expand.c diff --git a/src/benchmarks/espresso/gasp.c b/allocbench/benchmarks/espresso/gasp.c index b9a3d90..b9a3d90 100644 --- a/src/benchmarks/espresso/gasp.c +++ b/allocbench/benchmarks/espresso/gasp.c diff --git a/src/benchmarks/espresso/getopt.c b/allocbench/benchmarks/espresso/getopt.c index 017c907..017c907 100644 --- a/src/benchmarks/espresso/getopt.c +++ b/allocbench/benchmarks/espresso/getopt.c diff --git a/src/benchmarks/espresso/gimpel.c b/allocbench/benchmarks/espresso/gimpel.c index d1122b7..d1122b7 100644 --- a/src/benchmarks/espresso/gimpel.c +++ b/allocbench/benchmarks/espresso/gimpel.c diff --git a/src/benchmarks/espresso/globals.c b/allocbench/benchmarks/espresso/globals.c index dc0b958..dc0b958 100644 --- a/src/benchmarks/espresso/globals.c +++ b/allocbench/benchmarks/espresso/globals.c diff --git a/src/benchmarks/espresso/hack.c b/allocbench/benchmarks/espresso/hack.c index 6cb76c0..6cb76c0 100644 --- a/src/benchmarks/espresso/hack.c +++ b/allocbench/benchmarks/espresso/hack.c diff --git a/src/benchmarks/espresso/indep.c b/allocbench/benchmarks/espresso/indep.c index c462988..c462988 100644 --- a/src/benchmarks/espresso/indep.c +++ b/allocbench/benchmarks/espresso/indep.c diff --git a/src/benchmarks/espresso/irred.c b/allocbench/benchmarks/espresso/irred.c index 0c49ff3..0c49ff3 100644 --- a/src/benchmarks/espresso/irred.c +++ b/allocbench/benchmarks/espresso/irred.c diff --git a/src/benchmarks/espresso/largest.espresso b/allocbench/benchmarks/espresso/largest.espresso index 53b0157..53b0157 100644 --- a/src/benchmarks/espresso/largest.espresso +++ b/allocbench/benchmarks/espresso/largest.espresso diff --git a/src/benchmarks/espresso/main.c b/allocbench/benchmarks/espresso/main.c index b82813b..b82813b 100644 --- a/src/benchmarks/espresso/main.c +++ b/allocbench/benchmarks/espresso/main.c diff --git a/src/benchmarks/espresso/main.h b/allocbench/benchmarks/espresso/main.h index 216ce3a..216ce3a 100644 --- a/src/benchmarks/espresso/main.h +++ b/allocbench/benchmarks/espresso/main.h diff --git a/src/benchmarks/espresso/map.c b/allocbench/benchmarks/espresso/map.c index d0c041d..d0c041d 100644 --- a/src/benchmarks/espresso/map.c +++ b/allocbench/benchmarks/espresso/map.c diff --git a/src/benchmarks/espresso/matrix.c b/allocbench/benchmarks/espresso/matrix.c index b012a3e..b012a3e 100644 --- a/src/benchmarks/espresso/matrix.c +++ b/allocbench/benchmarks/espresso/matrix.c diff --git a/src/benchmarks/espresso/mincov.c b/allocbench/benchmarks/espresso/mincov.c index e940e5d..e940e5d 100644 --- a/src/benchmarks/espresso/mincov.c +++ b/allocbench/benchmarks/espresso/mincov.c diff --git a/src/benchmarks/espresso/mincov.h b/allocbench/benchmarks/espresso/mincov.h index f6a0425..f6a0425 100644 --- a/src/benchmarks/espresso/mincov.h +++ b/allocbench/benchmarks/espresso/mincov.h diff --git a/src/benchmarks/espresso/mincov_int.h b/allocbench/benchmarks/espresso/mincov_int.h index a9f932e..a9f932e 100644 --- a/src/benchmarks/espresso/mincov_int.h +++ b/allocbench/benchmarks/espresso/mincov_int.h diff --git a/src/benchmarks/espresso/opo.c b/allocbench/benchmarks/espresso/opo.c index 1951cb9..1951cb9 100644 --- a/src/benchmarks/espresso/opo.c +++ b/allocbench/benchmarks/espresso/opo.c diff --git a/src/benchmarks/espresso/pair.c b/allocbench/benchmarks/espresso/pair.c index 50e86aa..50e86aa 100644 --- a/src/benchmarks/espresso/pair.c +++ b/allocbench/benchmarks/espresso/pair.c diff --git a/src/benchmarks/espresso/part.c b/allocbench/benchmarks/espresso/part.c index c2c2407..c2c2407 100644 --- a/src/benchmarks/espresso/part.c +++ b/allocbench/benchmarks/espresso/part.c diff --git a/src/benchmarks/espresso/port.h b/allocbench/benchmarks/espresso/port.h index d84a1b5..d84a1b5 100644 --- a/src/benchmarks/espresso/port.h +++ b/allocbench/benchmarks/espresso/port.h diff --git a/src/benchmarks/espresso/primes.c b/allocbench/benchmarks/espresso/primes.c index 7386784..7386784 100644 --- a/src/benchmarks/espresso/primes.c +++ b/allocbench/benchmarks/espresso/primes.c diff --git a/src/benchmarks/espresso/reduce.c b/allocbench/benchmarks/espresso/reduce.c index f818a2d..f818a2d 100644 --- a/src/benchmarks/espresso/reduce.c +++ b/allocbench/benchmarks/espresso/reduce.c diff --git a/src/benchmarks/espresso/regex.h b/allocbench/benchmarks/espresso/regex.h index be96614..be96614 100644 --- a/src/benchmarks/espresso/regex.h +++ b/allocbench/benchmarks/espresso/regex.h diff --git a/src/benchmarks/espresso/rows.c b/allocbench/benchmarks/espresso/rows.c index 6cb38ae..6cb38ae 100644 --- a/src/benchmarks/espresso/rows.c +++ b/allocbench/benchmarks/espresso/rows.c diff --git a/src/benchmarks/espresso/set.c b/allocbench/benchmarks/espresso/set.c index 4c6ad15..4c6ad15 100644 --- a/src/benchmarks/espresso/set.c +++ b/allocbench/benchmarks/espresso/set.c diff --git a/src/benchmarks/espresso/setc.c b/allocbench/benchmarks/espresso/setc.c index a2d06c9..a2d06c9 100644 --- a/src/benchmarks/espresso/setc.c +++ b/allocbench/benchmarks/espresso/setc.c diff --git a/src/benchmarks/espresso/sharp.c b/allocbench/benchmarks/espresso/sharp.c index 24401df..24401df 100644 --- a/src/benchmarks/espresso/sharp.c +++ b/allocbench/benchmarks/espresso/sharp.c diff --git a/src/benchmarks/espresso/sminterf.c b/allocbench/benchmarks/espresso/sminterf.c index 96e77fa..96e77fa 100644 --- a/src/benchmarks/espresso/sminterf.c +++ b/allocbench/benchmarks/espresso/sminterf.c diff --git a/src/benchmarks/espresso/solution.c b/allocbench/benchmarks/espresso/solution.c index 2222b71..2222b71 100644 --- a/src/benchmarks/espresso/solution.c +++ b/allocbench/benchmarks/espresso/solution.c diff --git a/src/benchmarks/espresso/sparse.c b/allocbench/benchmarks/espresso/sparse.c index 559b8ca..559b8ca 100644 --- a/src/benchmarks/espresso/sparse.c +++ b/allocbench/benchmarks/espresso/sparse.c diff --git a/src/benchmarks/espresso/sparse.h b/allocbench/benchmarks/espresso/sparse.h index 9c84827..9c84827 100644 --- a/src/benchmarks/espresso/sparse.h +++ b/allocbench/benchmarks/espresso/sparse.h diff --git a/src/benchmarks/espresso/sparse_int.h b/allocbench/benchmarks/espresso/sparse_int.h index d80cfed..d80cfed 100644 --- a/src/benchmarks/espresso/sparse_int.h +++ b/allocbench/benchmarks/espresso/sparse_int.h diff --git a/src/benchmarks/espresso/stdlib.h b/allocbench/benchmarks/espresso/stdlib.h index c5cf479..c5cf479 100644 --- a/src/benchmarks/espresso/stdlib.h +++ b/allocbench/benchmarks/espresso/stdlib.h diff --git a/src/benchmarks/espresso/unate.c b/allocbench/benchmarks/espresso/unate.c index b787c3c..b787c3c 100644 --- a/src/benchmarks/espresso/unate.c +++ b/allocbench/benchmarks/espresso/unate.c diff --git a/src/benchmarks/espresso/utility.c b/allocbench/benchmarks/espresso/utility.c index 3c140a1..3c140a1 100644 --- a/src/benchmarks/espresso/utility.c +++ b/allocbench/benchmarks/espresso/utility.c diff --git a/src/benchmarks/espresso/utility.h b/allocbench/benchmarks/espresso/utility.h index dcb834e..dcb834e 100644 --- a/src/benchmarks/espresso/utility.h +++ b/allocbench/benchmarks/espresso/utility.h diff --git a/src/benchmarks/espresso/verify.c b/allocbench/benchmarks/espresso/verify.c index 3cecd8b..3cecd8b 100644 --- a/src/benchmarks/espresso/verify.c +++ b/allocbench/benchmarks/espresso/verify.c diff --git a/src/benchmarks/falsesharing.py b/allocbench/benchmarks/falsesharing.py index 1e9fc34..2bab852 100644 --- a/src/benchmarks/falsesharing.py +++ b/allocbench/benchmarks/falsesharing.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -19,11 +19,9 @@ import re import matplotlib.pyplot as plt -import numpy as np -from src.benchmark import Benchmark -from src.globalvars import summary_file_ext -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt TIME_RE = re.compile("^Time elapsed = (?P<time>\\d*\\.\\d*) seconds.$") @@ -49,12 +47,11 @@ class BenchmarkFalsesharing(Benchmark): super().__init__(name) @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument result["time"] = TIME_RE.match(stdout).group("time") def summary(self): args = self.results["args"] - nthreads = args["threads"] allocators = self.results["allocators"] # calculate relevant datapoints: speedup, l1-cache-misses @@ -62,9 +59,8 @@ class BenchmarkFalsesharing(Benchmark): for allocator in allocators: sequential_perm = self.Perm(bench=bench, threads=1) - for perm in self.iterate_args({"bench": bench}, args=args): - speedup = [] - l1chache_misses = [] + for perm in self.iterate_args(fixed={"bench": bench}, + args=args): for i, measure in enumerate(self.results[allocator][perm]): sequential_time = float(self.results[allocator] [sequential_perm][i]["time"]) @@ -82,9 +78,9 @@ class BenchmarkFalsesharing(Benchmark): "{speedup}", x_args=["bench"], fig_options={ - 'ylabel': "Speedup", - 'title': "Speedup: {arg} {arg_value}", - 'autoticks': False, + 'ylabel': "Speedup", + 'title': "Speedup: {arg} {arg_value}", + 'autoticks': False, }, file_postfix="speedup") @@ -96,7 +92,7 @@ class BenchmarkFalsesharing(Benchmark): 'title': "cache misses: {arg} {arg_value}", 'autoticks': False, }, - file_postfix="l1-misses") + file_postfix="l1-misses") plt.write_tex_table(self, [{ "label": "Speedup", @@ -111,7 +107,7 @@ class BenchmarkFalsesharing(Benchmark): # pgfplots for bench in args["bench"]: plt.pgfplot(self, - self.iterate_args({"bench": bench}, args=args), + self.iterate_args(fixed={"bench": bench}, args=args), "int(perm.threads)", "{speedup}", xlabel="Threads", diff --git a/src/benchmarks/falsesharing/Makefile b/allocbench/benchmarks/falsesharing/Makefile index 2058b05..2058b05 100644 --- a/src/benchmarks/falsesharing/Makefile +++ b/allocbench/benchmarks/falsesharing/Makefile diff --git a/src/benchmarks/falsesharing/cache-scratch.cc b/allocbench/benchmarks/falsesharing/cache-scratch.cc index 2cb9b28..2cb9b28 100644 --- a/src/benchmarks/falsesharing/cache-scratch.cc +++ b/allocbench/benchmarks/falsesharing/cache-scratch.cc diff --git a/src/benchmarks/falsesharing/cache-thrash.cc b/allocbench/benchmarks/falsesharing/cache-thrash.cc index 79242eb..79242eb 100644 --- a/src/benchmarks/falsesharing/cache-thrash.cc +++ b/allocbench/benchmarks/falsesharing/cache-thrash.cc diff --git a/src/benchmarks/falsesharing/cpuinfo.h b/allocbench/benchmarks/falsesharing/cpuinfo.h index 1ed1f36..1ed1f36 100644 --- a/src/benchmarks/falsesharing/cpuinfo.h +++ b/allocbench/benchmarks/falsesharing/cpuinfo.h diff --git a/src/benchmarks/falsesharing/fred.h b/allocbench/benchmarks/falsesharing/fred.h index b0198a7..b0198a7 100644 --- a/src/benchmarks/falsesharing/fred.h +++ b/allocbench/benchmarks/falsesharing/fred.h diff --git a/src/benchmarks/falsesharing/timer.h b/allocbench/benchmarks/falsesharing/timer.h index d4d42c7..d4d42c7 100644 --- a/src/benchmarks/falsesharing/timer.h +++ b/allocbench/benchmarks/falsesharing/timer.h diff --git a/src/benchmarks/fd.py b/allocbench/benchmarks/fd.py index 1fdd96a..eccd41f 100644 --- a/src/benchmarks/fd.py +++ b/allocbench/benchmarks/fd.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -17,13 +17,10 @@ """Definition of the fd benchmark""" import os -import re -from urllib.request import urlretrieve -from src.artifact import ArchiveArtifact, GitArtifact -from src.benchmark import Benchmark -import src.plots as plt -from src.util import print_info +from allocbench.artifact import ArchiveArtifact, GitArtifact +from allocbench.benchmark import Benchmark +import allocbench.plots as plt class BenchmarkFd(Benchmark): @@ -52,11 +49,11 @@ class BenchmarkFd(Benchmark): fd_url = ("https://github.com/sharkdp/fd/releases/latest/download/" f"fd-{fd_version}-x86_64-unknown-linux-gnu.tar.gz") - fd = ArchiveArtifact("fd", fd_url, "tar", - "a5d8e7c8484449aa324a46abfdfaf026d7de77ee") + fd_artifact = ArchiveArtifact( + "fd", fd_url, "tar", "a5d8e7c8484449aa324a46abfdfaf026d7de77ee") fd_dir = os.path.join(self.build_dir, "fd_sources") - fd.provide(fd_dir) + fd_artifact.provide(fd_dir) # create symlinks for exe in ["fd"]: diff --git a/src/benchmarks/httpd.py b/allocbench/benchmarks/httpd.py index 18a9bf6..df63919 100644 --- a/src/benchmarks/httpd.py +++ b/allocbench/benchmarks/httpd.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -18,9 +18,9 @@ import re -from src.benchmark import Benchmark -import src.facter -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.facter as facter +import allocbench.plots as plt class BenchmarkHTTPD(Benchmark): @@ -47,13 +47,13 @@ class BenchmarkHTTPD(Benchmark): def prepare(self): super().prepare() - self.results["facts"]["versions"]["nginx"] = src.facter.exe_version( + self.results["facts"]["versions"]["nginx"] = facter.exe_version( "nginx", "-v") - self.results["facts"]["versions"]["ab"] = src.facter.exe_version( + self.results["facts"]["versions"]["ab"] = facter.exe_version( "ab", "-V") @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument result["time"] = re.search( "Time taken for tests:\\s*(\\d*\\.\\d*) seconds", stdout).group(1) result["requests"] = re.search( @@ -73,10 +73,10 @@ class BenchmarkHTTPD(Benchmark): plt.plot(self, "{nginx_vmhwm}", fig_options={ - 'xlabel': "threads", - 'ylabel': "VmHWM in KB", - 'title': "{perm.site}: nginx memory usage", - 'autoticks': False, + 'xlabel': "threads", + 'ylabel': "VmHWM in KB", + 'title': "{perm.site}: nginx memory usage", + 'autoticks': False, }, file_postfix="httpd_vmhwm") diff --git a/src/benchmarks/httpd/Makefile b/allocbench/benchmarks/httpd/Makefile index dff3efe..dff3efe 100644 --- a/src/benchmarks/httpd/Makefile +++ b/allocbench/benchmarks/httpd/Makefile diff --git a/src/benchmarks/httpd/etc/nginx/nginx.conf b/allocbench/benchmarks/httpd/etc/nginx/nginx.conf index 278ea0b..278ea0b 100644 --- a/src/benchmarks/httpd/etc/nginx/nginx.conf +++ b/allocbench/benchmarks/httpd/etc/nginx/nginx.conf diff --git a/src/benchmarks/httpd/etc/php/php-fpm.conf b/allocbench/benchmarks/httpd/etc/php/php-fpm.conf index fa461cf..fa461cf 100644 --- a/src/benchmarks/httpd/etc/php/php-fpm.conf +++ b/allocbench/benchmarks/httpd/etc/php/php-fpm.conf diff --git a/src/benchmarks/httpd/etc/php/php-fpm.d/www.conf b/allocbench/benchmarks/httpd/etc/php/php-fpm.d/www.conf index 3f155db..3f155db 100644 --- a/src/benchmarks/httpd/etc/php/php-fpm.d/www.conf +++ b/allocbench/benchmarks/httpd/etc/php/php-fpm.d/www.conf diff --git a/src/benchmarks/httpd/etc/php/php.ini b/allocbench/benchmarks/httpd/etc/php/php.ini index 13daf6b..13daf6b 100644 --- a/src/benchmarks/httpd/etc/php/php.ini +++ b/allocbench/benchmarks/httpd/etc/php/php.ini diff --git a/src/benchmarks/httpd/html/index.html b/allocbench/benchmarks/httpd/html/index.html index 7052ab3..7052ab3 100644 --- a/src/benchmarks/httpd/html/index.html +++ b/allocbench/benchmarks/httpd/html/index.html diff --git a/src/benchmarks/httpd/html/index.php b/allocbench/benchmarks/httpd/html/index.php index 0dde14e..0dde14e 100644 --- a/src/benchmarks/httpd/html/index.php +++ b/allocbench/benchmarks/httpd/html/index.php diff --git a/src/benchmarks/httpd/php/index.php b/allocbench/benchmarks/httpd/php/index.php index 147cebc..147cebc 100644 --- a/src/benchmarks/httpd/php/index.php +++ b/allocbench/benchmarks/httpd/php/index.php diff --git a/src/benchmarks/keydb.py b/allocbench/benchmarks/keydb.py index 92470b0..49ba211 100644 --- a/src/benchmarks/keydb.py +++ b/allocbench/benchmarks/keydb.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -21,13 +21,11 @@ This benchmark uses the memtier benchmark tool. """ import os -import sys -from multiprocessing import cpu_count -from src.artifact import GitArtifact -from src.benchmark import Benchmark -import src.plots as plt -from src.util import print_info, run_cmd +from allocbench.artifact import GitArtifact +from allocbench.benchmark import Benchmark +import allocbench.plots as plt +from allocbench.util import run_cmd class BenchmarkKeyDB(Benchmark): @@ -36,12 +34,15 @@ class BenchmarkKeyDB(Benchmark): name = "keydb" self.cmd = "memtier_benchmark –hide-histogram --threads {threads} –data-size {size}" - self.args = {"threads": Benchmark.scale_threads_for_cpus(1 / 2), - "size": [8, 64, 256, 1024, 4096, 16384]} + self.args = { + "threads": Benchmark.scale_threads_for_cpus(1 / 2), + "size": [8, 64, 256, 1024, 4096, 16384] + } self.servers = [{ "name": "keydb", - "cmd": f"keydb-server --server-threads 4", # 4 is the by keydb recommended amount + "cmd": + f"keydb-server --server-threads 4", # 4 is the by keydb recommended amount "shutdown_cmds": ["{build_dir}/keydb-cli shutdown"] }] @@ -50,18 +51,17 @@ class BenchmarkKeyDB(Benchmark): def prepare(self): super().prepare() - keydb_version = "v5.3.1" self.results["facts"]["versions"]["keydb"] = keydb_version keydb_dir = os.path.join(self.build_dir, "keydb") if not os.path.exists(os.path.join(self.build_dir, "keydb-server")): - keydb = GitArtifact("keydb", "https://github.com/JohnSully/KeyDB") + keydb_artifact = GitArtifact("keydb", "https://github.com/JohnSully/KeyDB") os.makedirs(self.build_dir, exist_ok=True) # checkout sources - keydb.provide(keydb_version, keydb_dir) + keydb_artifact.provide(keydb_version, keydb_dir) # building keyDB run_cmd(["make", "-C", keydb_dir, "MALLOC=libc"]) @@ -77,8 +77,10 @@ class BenchmarkKeyDB(Benchmark): self.results["facts"]["versions"]["memtier"] = memtier_version memtier_dir = os.path.join(self.build_dir, "memtier") - if not os.path.exists(os.path.join(self.build_dir, "memtier_benchmark")): - memtier = GitArtifact("memtier", "https://github.com/RedisLabs/memtier_benchmark") + if not os.path.exists(os.path.join(self.build_dir, + "memtier_benchmark")): + memtier = GitArtifact( + "memtier", "https://github.com/RedisLabs/memtier_benchmark") memtier.provide(memtier_version, memtier_dir) @@ -93,7 +95,7 @@ class BenchmarkKeyDB(Benchmark): os.link(src, dest) @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument cmds = ["Sets", "Gets", "Waits", "Totals"] stats = ["ops", "hits", "misses", "latency", "throughput"] for line in stdout.splitlines(): @@ -126,4 +128,5 @@ class BenchmarkKeyDB(Benchmark): }, file_postfix="vmhwm") + keydb = BenchmarkKeyDB() diff --git a/src/benchmarks/larson.py b/allocbench/benchmarks/larson.py index db38789..b7acb71 100644 --- a/src/benchmarks/larson.py +++ b/allocbench/benchmarks/larson.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -47,8 +47,8 @@ false sharing because it uses multiple threads, which pass memory around. import re -from src.benchmark import Benchmark -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt THROUGHPUT_RE = re.compile( "^Throughput =\\s*(?P<throughput>\\d+) operations per second.$") @@ -72,7 +72,7 @@ class BenchmarkLarson(Benchmark): super().__init__(name) @staticmethod - def process_output(result, stdout, stderr, target, perm): + def process_output(result, stdout, stderr, target, perm): # pylint: disable=too-many-arguments, unused-argument for line in stdout.splitlines(): res = THROUGHPUT_RE.match(line) if res: diff --git a/src/benchmarks/larson/Makefile b/allocbench/benchmarks/larson/Makefile index 0bb9a5b..0bb9a5b 100644 --- a/src/benchmarks/larson/Makefile +++ b/allocbench/benchmarks/larson/Makefile diff --git a/src/benchmarks/larson/larson.cc b/allocbench/benchmarks/larson/larson.cc index 09bd885..09bd885 100644 --- a/src/benchmarks/larson/larson.cc +++ b/allocbench/benchmarks/larson/larson.cc diff --git a/src/benchmarks/lld.py b/allocbench/benchmarks/lld.py index 55b9063..f89c27e 100644 --- a/src/benchmarks/lld.py +++ b/allocbench/benchmarks/lld.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -201,11 +201,11 @@ import os import matplotlib.pyplot as plt -from src.artifact import ArchiveArtifact -from src.benchmark import Benchmark -import src.facter -import src.plots -from src.globalvars import summary_file_ext +from allocbench.artifact import ArchiveArtifact +from allocbench.benchmark import Benchmark +import allocbench.facter as facter +import allocbench.plots +from allocbench.globalvars import SUMMARY_FILE_EXT class BenchmarkLld(Benchmark): @@ -234,7 +234,7 @@ class BenchmarkLld(Benchmark): super().prepare() # save lld version - self.results["facts"]["versions"]["lld"] = src.facter.exe_version( + self.results["facts"]["versions"]["lld"] = facter.exe_version( "ld.lld", "-v") tests = ArchiveArtifact( @@ -267,7 +267,7 @@ class BenchmarkLld(Benchmark): plt.legend(loc="best") plt.ylabel("time in ms") plt.title(f"Runtime {perm.test}") - plt.savefig(f"{self.name}.{perm.test}.runtime.{summary_file_ext}") + plt.savefig(f"{self.name}.{perm.test}.runtime.{SUMMARY_FILE_EXT}") plt.clf() for i, alloc in enumerate(allocators): @@ -280,21 +280,21 @@ class BenchmarkLld(Benchmark): plt.legend(loc="best") plt.ylabel("Max RSS in MB") plt.title(f"Max RSS {perm.test}") - plt.savefig(f"{self.name}.{perm.test}.rss.{summary_file_ext}") + plt.savefig(f"{self.name}.{perm.test}.rss.{SUMMARY_FILE_EXT}") plt.clf() # self.export_stats_to_csv("VmHWM") - src.plots.export_stats_to_csv(self, "task-clock") + allocbench.plots.export_stats_to_csv(self, "task-clock") # self.export_stats_to_dataref("VmHWM") - src.plots.export_stats_to_dataref(self, "task-clock") + allocbench.plots.export_stats_to_dataref(self, "task-clock") - src.plots.write_tex_table(self, [{ + allocbench.plots.write_tex_table(self, [{ "label": "Runtime [ms]", "expression": "{task-clock}", "sort": "<" }], - file_postfix="table") + file_postfix="table") lld = BenchmarkLld() diff --git a/src/benchmarks/loop.py b/allocbench/benchmarks/loop.py index 030552b..6a08ea8 100644 --- a/src/benchmarks/loop.py +++ b/allocbench/benchmarks/loop.py @@ -34,8 +34,8 @@ Interpretation: differences in differing strategies for seperate sizes (glibc thread caches < 1032B) """ -from src.benchmark import Benchmark -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt class BenchmarkLoop(Benchmark): @@ -56,7 +56,8 @@ class BenchmarkLoop(Benchmark): self.requirements = ["loop"] super().__init__(name) - def process_output(self, result, stdout, stderr, alloc, perm): + @staticmethod + def process_output(result, stdout, stderr, alloc, perm): # pylint: disable=too-many-arguments, unused-argument result["mops"] = perm.threads / float(result["task-clock"]) def summary(self): @@ -89,7 +90,7 @@ class BenchmarkLoop(Benchmark): file_postfix="time.matrix") plt.write_tex_table( - self, + self, [{ "label": "MOPS/s", "expression": "{mops}", diff --git a/src/benchmarks/loop/Makefile b/allocbench/benchmarks/loop/Makefile index d9d64c2..d9d64c2 100644 --- a/src/benchmarks/loop/Makefile +++ b/allocbench/benchmarks/loop/Makefile diff --git a/src/benchmarks/loop/loop.c b/allocbench/benchmarks/loop/loop.c index 04dcd80..04dcd80 100644 --- a/src/benchmarks/loop/loop.c +++ b/allocbench/benchmarks/loop/loop.c diff --git a/src/benchmarks/mysql.py b/allocbench/benchmarks/mysql.py index 0df85d2..20a14ce 100644 --- a/src/benchmarks/mysql.py +++ b/allocbench/benchmarks/mysql.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -80,12 +80,12 @@ import sys import numpy as np -from src.benchmark import Benchmark -import src.facter -import src.plots as plt -from src.util import print_status, print_debug, print_info2, print_warn, run_cmd +from allocbench.benchmark import Benchmark +import allocbench.facter as facter +import allocbench.plots as plt +from allocbench.util import print_status, print_debug, print_info2, print_warn, run_cmd -MYSQL_USER = "root" +MYSQL_USER = "fischerling" RUN_TIME = 300 TABLES = 5 @@ -132,7 +132,7 @@ class BenchmarkMYSQL(Benchmark): # save mysqld and sysbench versions for exe in self.requirements: - self.results["facts"]["versions"][exe] = src.facter.exe_version( + self.results["facts"]["versions"][exe] = facter.exe_version( exe, "--version") # Setup Test Environment @@ -155,11 +155,11 @@ class BenchmarkMYSQL(Benchmark): try: run_cmd(init_db_cmd, capture=True) - except CalledProcessError as e: - print_debug("Stdout:", e.stdout, file=sys.stderr) - print_debug("Stderr:", e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug("Stdout:", err.stdout, file=sys.stderr) + print_debug("Stderr:", err.stderr, file=sys.stderr) self.reset_preparations() - raise e + raise self.start_servers() @@ -170,24 +170,25 @@ class BenchmarkMYSQL(Benchmark): input="CREATE DATABASE sbtest;\n", capture=True, cwd=self.build_dir) - except CalledProcessError as e: - print_debug("Stderr:", e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug("Stderr:", err.stderr, file=sys.stderr) self.reset_preparations() - raise e + raise print_status("Prepare test tables ...") prepare_cmd = PREPARE_CMD.format(build_dir=self.build_dir).split() try: run_cmd(prepare_cmd, capture=True) - except CalledProcessError as e: - print_debug("Stdout:", e.stdout, file=sys.stderr) - print_debug("Stderr:", e.stderr, file=sys.stderr) + except CalledProcessError as err: + print_debug("Stdout:", err.stdout, file=sys.stderr) + print_debug("Stderr:", err.stderr, file=sys.stderr) self.reset_preparations() - raise e + raise self.shutdown_servers() - def process_output(self, result, stdout, stderr, allocator, perm): + @staticmethod + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument result["transactions"] = re.search("transactions:\\s*(\\d*)", stdout).group(1) result["queries"] = re.search("queries:\\s*(\\d*)", stdout).group(1) @@ -223,7 +224,7 @@ class BenchmarkMYSQL(Benchmark): scale=ref_alloc) # bar plot - plt.plot(self, + plt.plot(self, "{transactions}", plot_type='bar', fig_options={ @@ -265,10 +266,10 @@ class BenchmarkMYSQL(Benchmark): "expression": "{mysqld_vmhwm}", "sort": "<" }], - file_postfix="table") + file_postfix="table") # Colored latex table showing transactions count - d = {allocator: {} for allocator in allocators} + data = {allocator: {} for allocator in allocators} for perm in self.iterate_args(args=args): for allocator in allocators: transactions = [ @@ -277,46 +278,46 @@ class BenchmarkMYSQL(Benchmark): ] mean = np.mean(transactions) std = np.std(transactions) / mean - d[allocator][perm] = {"mean": mean, "std": std} + data[allocator][perm] = {"mean": mean, "std": std} mins = {} maxs = {} for perm in self.iterate_args(args=args): cmax = None cmin = None - for i, allocator in enumerate(allocators): - m = d[allocator][perm]["mean"] - if not cmax or m > cmax: - cmax = m - if not cmin or m < cmin: - cmin = m + for allocator in allocators: + mean = data[allocator][perm]["mean"] + if not cmax or mean > cmax: + cmax = mean + if not cmin or mean < cmin: + cmin = mean maxs[perm] = cmax mins[perm] = cmin fname = ".".join([self.name, "transactions.tex"]) headers = [perm.nthreads for perm in self.iterate_args(args=args)] - with open(fname, "w") as f: - print("\\begin{tabular}{| l" + " l" * len(headers) + " |}", file=f) - print("Fäden / Allokator ", end=" ", file=f) + with open(fname, "w") as table_file: + print("\\begin{tabular}{| l" + " l" * len(headers) + " |}", file=table_file) + print("Fäden / Allokator ", end=" ", file=table_file) for head in headers: - print("& {}".format(head), end=" ", file=f) - print("\\\\\n\\hline", file=f) + print("& {}".format(head), end=" ", file=table_file) + print("\\\\\n\\hline", file=table_file) for allocator in allocators: - print(allocator, end=" ", file=f) + print(allocator, end=" ", file=table_file) for perm in self.iterate_args(args=args): - m = d[allocator][perm]["mean"] - s = "& \\textcolor{{{}}}{{{:.3f}}}" - if m == maxs[perm]: + mean = data[allocator][perm]["mean"] + entry_string = "& \\textcolor{{{}}}{{{:.3f}}}" + if mean == maxs[perm]: color = "green" - elif m == mins[perm]: + elif mean == mins[perm]: color = "red" else: color = "black" - print(s.format(color, m), end=" ", file=f) - print("\\\\", file=f) + print(entry_string.format(color, mean), end=" ", file=table_file) + print("\\\\", file=table_file) - print("\\end{tabular}", file=f) + print("\\end{tabular}", file=table_file) plt.export_stats_to_csv(self, "transactions") plt.export_stats_to_dataref(self, "transactions") diff --git a/src/benchmarks/raxmlng.py b/allocbench/benchmarks/raxmlng.py index ef77d2d..65a4838 100644 --- a/src/benchmarks/raxmlng.py +++ b/allocbench/benchmarks/raxmlng.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -19,10 +19,10 @@ import os import re -from src.artifact import GitArtifact -from src.benchmark import Benchmark -import src.plots as plt -from src.util import print_info, run_cmd +from allocbench.artifact import GitArtifact +from allocbench.benchmark import Benchmark +import allocbench.plots as plt +from allocbench.util import run_cmd RUNTIME_RE = re.compile("Elapsed time: (?P<runtime>(\\d*.\\d*)) seconds") @@ -72,13 +72,14 @@ class BenchmarkRaxmlng(Benchmark): raxmlng_data.provide("f8f0b6a057a11397b4dad308440746e3436db8b4", raxmlng_data_dir) - def cleanup(self): + @staticmethod + def cleanup(): for direntry in os.listdir(): if direntry.startswith("prim.raxml"): os.remove(direntry) @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument, no-self-use result["runtime"] = RUNTIME_RE.search(stdout).group("runtime") def summary(self): @@ -86,8 +87,8 @@ class BenchmarkRaxmlng(Benchmark): "{runtime}", plot_type='bar', fig_options={ - 'ylabel': 'runtime in s', - 'title': 'raxml-ng tree inference benchmark', + 'ylabel': 'runtime in s', + 'title': 'raxml-ng tree inference benchmark', }, file_postfix="runtime") diff --git a/src/benchmarks/rdtsc.py b/allocbench/benchmarks/rdtsc.py index 03f8ff3..6b3bf60 100644 --- a/src/benchmarks/rdtsc.py +++ b/allocbench/benchmarks/rdtsc.py @@ -18,16 +18,16 @@ This benchmark measures the clock cycles used by malloc. It tries to spread the spawned thread on all cores exept the first one. -See: https://developers.redhat.com/blog/2016/03/11/practical-micro-benchmarking-with-ltrace-and-sched/ +Inspired by DJ Delorie's blog post: +https://developers.redhat.com/blog/2016/03/11/practical-micro-benchmarking-with-ltrace-and-sched/ """ import numpy as np -import matplotlib import matplotlib.pyplot as plt -from src.benchmark import Benchmark -import src.globalvars -import src.plots +from allocbench.benchmark import Benchmark +from allocbench.globalvars import SUMMARY_FILE_EXT +import allocbench.plots class BenchmarkRdtsc(Benchmark): @@ -41,13 +41,13 @@ class BenchmarkRdtsc(Benchmark): self.cmd = "rdtsc {mode} 100000 64 {threads}" self.measure_cmd = "" - self.args = {"threads": [1], - "mode": ['fresh', 'cached']} + self.args = {"threads": [1], "mode": ['fresh', 'cached']} self.requirements = ["rdtsc"] super().__init__(name) - def process_output(self, result, stdout, stderr, alloc, perm): + @staticmethod + def process_output(result, stdout, stderr, alloc, perm): # pylint: disable=too-many-arguments, unused-argument all_cycles = [] for line in stdout.splitlines(): all_cycles.append(int(line.split()[1])) @@ -58,24 +58,23 @@ class BenchmarkRdtsc(Benchmark): for perm in self.iterate_args(args=self.results['args']): label = f'rdtsc_{perm}_cycles' fig = plt.figure(label) - src.plots.FIGURES[label] = fig + allocbench.plots.FIGURES[label] = fig axes = plt.axes() axes.set_ylim([50, 800]) for i, alloc in enumerate(self.results['allocators']): - d = np.sort(self.results[alloc][perm][0]['all_cycles']) - color = src.plots._get_alloc_color(self, alloc) + data = np.sort(self.results[alloc][perm][0]['all_cycles']) + color = allocbench.plots.get_alloc_color(self, alloc) color = f"C{i}" - plt.plot(d, label=alloc, color=color) + plt.plot(data, label=alloc, color=color) plt.legend() plt.title(str(perm)) - fig.savefig(f'{label}.{src.globalvars.summary_file_ext}') + fig.savefig(f'{label}.{SUMMARY_FILE_EXT}') plt.show() - - src.plots.export_stats_to_csv(self, "cycles") + allocbench.plots.export_stats_to_csv(self, "cycles") rdtsc = BenchmarkRdtsc() diff --git a/src/benchmarks/rdtsc/Makefile b/allocbench/benchmarks/rdtsc/Makefile index f81a84b..f81a84b 100644 --- a/src/benchmarks/rdtsc/Makefile +++ b/allocbench/benchmarks/rdtsc/Makefile diff --git a/src/benchmarks/rdtsc/rdtsc.c b/allocbench/benchmarks/rdtsc/rdtsc.c index fec84d6..f61b9f1 100644 --- a/src/benchmarks/rdtsc/rdtsc.c +++ b/allocbench/benchmarks/rdtsc/rdtsc.c @@ -42,7 +42,8 @@ static void* test_thread_func(void* arg) { int my_cpu_num = (tid % (num_cpus-1))+1; CPU_ZERO (&my_cpu); - CPU_SET (my_cpu_num, &my_cpu); + /* CPU_SET (my_cpu_num, &my_cpu); */ + CPU_SET (3, &my_cpu); if (sched_setaffinity (0, sizeof(my_cpu), &my_cpu) == -1) perror ("setaffinity failed"); diff --git a/src/benchmarks/realloc.py b/allocbench/benchmarks/realloc.py index d3375ff..bfd285b 100644 --- a/src/benchmarks/realloc.py +++ b/allocbench/benchmarks/realloc.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. If not, see <http://www.gnu.org/licenses/>. """Definition of the realloc micro benchmark""" -import src.plots as plt -from src.benchmark import Benchmark +import allocbench.plots as plt +from allocbench.benchmark import Benchmark class BenchmarkRealloc(Benchmark): diff --git a/src/benchmarks/realloc/Makefile b/allocbench/benchmarks/realloc/Makefile index 66b38ca..66b38ca 100644 --- a/src/benchmarks/realloc/Makefile +++ b/allocbench/benchmarks/realloc/Makefile diff --git a/src/benchmarks/realloc/realloc.c b/allocbench/benchmarks/realloc/realloc.c index b6e6034..b6e6034 100644 --- a/src/benchmarks/realloc/realloc.c +++ b/allocbench/benchmarks/realloc/realloc.c diff --git a/src/benchmarks/redis.py b/allocbench/benchmarks/redis.py index 265d825..4fd8fb1 100644 --- a/src/benchmarks/redis.py +++ b/allocbench/benchmarks/redis.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -23,12 +23,11 @@ archive. The used parameters are inspired by the ones used in mimalloc-bench." import os import re -import sys -from src.artifact import ArchiveArtifact -from src.benchmark import Benchmark -import src.plots as plt -from src.util import print_info, run_cmd +from allocbench.artifact import ArchiveArtifact +from allocbench.benchmark import Benchmark +import allocbench.plots as plt +from allocbench.util import run_cmd REQUESTS_RE = re.compile("(?P<requests>(\\d*.\\d*)) requests per second") @@ -38,7 +37,8 @@ class BenchmarkRedis(Benchmark): def __init__(self): name = "redis" - self.cmd = "redis-benchmark 1000000 -n 1000000 -P 8 -q lpush a 1 2 3 4 5 6 7 8 9 10 lrange a 1 10" + self.cmd = ("redis-benchmark 1000000 -n 1000000 -P 8 -q lpush" + " a 1 2 3 4 5 6 7 8 9 10 lrange a 1 10") self.servers = [{ "name": "redis", "cmd": "redis-server", @@ -52,14 +52,14 @@ class BenchmarkRedis(Benchmark): redis_version = "5.0.5" self.results["facts"]["versions"]["redis"] = redis_version - redis = ArchiveArtifact( + redis_artifact = ArchiveArtifact( "redis", f"http://download.redis.io/releases/redis-{redis_version}.tar.gz", "tar", "71e38ae09ac70012b5bc326522b976bcb8e269d6") redis_dir = os.path.join(self.build_dir, f"redis-{redis_version}") - redis.provide(self.build_dir) + redis_artifact.provide(self.build_dir) # building redis run_cmd(["make", "-C", redis_dir, "MALLOC=libc", "USE_JEMALLOC=no"]) @@ -72,7 +72,7 @@ class BenchmarkRedis(Benchmark): os.link(src, dest) @staticmethod - def process_output(result, stdout, stderr, allocator, perm): + def process_output(result, stdout, stderr, allocator, perm): # pylint: disable=too-many-arguments, unused-argument result["requests"] = REQUESTS_RE.search(stdout).group("requests") @staticmethod diff --git a/src/benchmarks/redis/build.sh b/allocbench/benchmarks/redis/build.sh index e58cb43..e58cb43 100755 --- a/src/benchmarks/redis/build.sh +++ b/allocbench/benchmarks/redis/build.sh diff --git a/src/benchmarks/t_test1.py b/allocbench/benchmarks/t_test1.py index 2d86bdc..4ddf940 100644 --- a/src/benchmarks/t_test1.py +++ b/allocbench/benchmarks/t_test1.py @@ -1,4 +1,4 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -16,8 +16,8 @@ # along with allocbench. If not, see <http://www.gnu.org/licenses/>. """Definition of the commonly used t-test1 allocator test""" -from src.benchmark import Benchmark -import src.plots as plt +from allocbench.benchmark import Benchmark +import allocbench.plots as plt class BenchmarkTTest1(Benchmark): @@ -53,16 +53,18 @@ class BenchmarkTTest1(Benchmark): # L1 cache misses plt.plot(self, - "({L1-dcache-load-misses}/{L1-dcache-loads})*100", - fig_options={ - 'ylabel': 'L1 misses in %', - 'title': 't-test1 l1 cache misses: {fixed_part_str}', - 'autoticks': False, - }, - file_postfix="l1misses") + "({L1-dcache-load-misses}/{L1-dcache-loads})*100", + fig_options={ + 'ylabel': 'L1 misses in %', + 'title': 't-test1 l1 cache misses: {fixed_part_str}', + 'autoticks': False, + }, + file_postfix="l1misses") # Speed Matrix - plt.write_best_doublearg_tex_table(self, yval, file_postfix="mops.matrix") + plt.write_best_doublearg_tex_table(self, + yval, + file_postfix="mops.matrix") plt.write_tex_table(self, [{ "label": "MOPS/s", diff --git a/src/benchmarks/t_test1/Makefile b/allocbench/benchmarks/t_test1/Makefile index 62a62ee..62a62ee 100644 --- a/src/benchmarks/t_test1/Makefile +++ b/allocbench/benchmarks/t_test1/Makefile diff --git a/src/benchmarks/t_test1/t-test1.c b/allocbench/benchmarks/t_test1/t-test1.c index 7418693..7418693 100644 --- a/src/benchmarks/t_test1/t-test1.c +++ b/allocbench/benchmarks/t_test1/t-test1.c diff --git a/src/bumpptr_alloc.c b/allocbench/bumpptr_alloc.c index ee2928a..ee2928a 100644 --- a/src/bumpptr_alloc.c +++ b/allocbench/bumpptr_alloc.c diff --git a/src/exec.c b/allocbench/exec.c index 6985fb2..6985fb2 100644 --- a/src/exec.c +++ b/allocbench/exec.c diff --git a/src/facter.py b/allocbench/facter.py index 5141b78..57f5abd 100644 --- a/src/facter.py +++ b/allocbench/facter.py @@ -25,14 +25,14 @@ import os import platform from subprocess import CalledProcessError -import src.globalvars as gv -from src.util import print_debug, print_info, print_warn, run_cmd +from allocbench.globalvars import BUILDDIR +from allocbench.util import print_debug, print_info, print_warn, run_cmd FACTS = {} def collect_facts(): """Collect general facts about the benchmark environment""" - # Populate src.globalvars.facts on import + # Populate allocbench.globalvars.facts on import _uname = platform.uname() FACTS["hostname"] = _uname.node FACTS["system"] = _uname.system @@ -41,7 +41,7 @@ def collect_facts(): FACTS["cpus"] = multiprocessing.cpu_count() FACTS["LD_PRELOAD"] = os.environ.get("LD_PRELOAD", None) - with open(os.path.join(gv.builddir, "ccinfo"), "r") as ccinfo: + with open(os.path.join(BUILDDIR, "ccinfo"), "r") as ccinfo: FACTS["cc"] = ccinfo.readlines()[-1][:-1] # get commit info from git @@ -63,8 +63,8 @@ def store_facts(path=None): filename = path print_info(f"Saving facts to: {filename}") - with open(filename, "w") as f: - json.dump(FACTS, f) + with open(filename, "w") as facts_file: + json.dump(FACTS, facts_file) def load_facts(path=None): @@ -79,17 +79,17 @@ def load_facts(path=None): if os.path.exists(filename + ".json"): filename += ".json" - global FACTS - with open(filename, "r") as f: - FACTS = json.load(f) + with open(filename, "r") as facts_file: + loaded_facts = json.load(facts_file) elif os.path.exists(filename + ".save"): import pickle filename += ".save" - with open(filename, "rb") as f: - FACTS = pickle.load(f) + with open(filename, "rb") as facts_file: + loaded_facts = pickle.load(facts_file) else: raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename) + FACTS.update(loaded_facts) print_info(f"Loading facts from: {filename}") @@ -170,9 +170,9 @@ def exe_version(executable, version_flag="--version"): """Return version of executable""" try: proc = run_cmd([executable, version_flag], capture=True) - except CalledProcessError as e: + except CalledProcessError as err: print_warn(f"failed to get version of {executable}") - print_debug(e.stderr) + print_debug(err.stderr) return "" return proc.stdout[:-1] diff --git a/allocbench/globalvars.py b/allocbench/globalvars.py new file mode 100644 index 0000000..bb41dad --- /dev/null +++ b/allocbench/globalvars.py @@ -0,0 +1,66 @@ +# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# +# This file is part of allocbench. +# +# allocbench is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# allocbench is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with allocbench. If not, see <http://www.gnu.org/licenses/>. + +"""Global variables for allocbench + +VERBOSITY: Verbosity level -1: quiet, 0: status, 1: info, 2: stdout of subcommands, 3: debug info +ALLOCATORS: Dict holding the allocators to compare +BENCHMARKS: List of available benchmarks + +ALLOCBENCHDIR: Root directory of allocbench +SRCDIR: Directory of allocbench sources +BENCHSRCDIR: Source directory for all benchmarks +ALLOCSRCDIR: Source directory for all benchmarks +BUILDDIR: Path of the build directory +ALLOCBUILDDIR: Path of the allocators build directory +RESDIR: Directory were the benchmark results are stored +""" + +import inspect +import os + + +VERBOSITY = 0 + +ALLOCATORS = {} + +# /.../allocbench/allocbench +SRCDIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + +# /.../allocbench/allocbench/benchmarks +BENCHSRCDIR = os.path.join(SRCDIR, "benchmarks") + +# /.../allocbench/allocbench/allocators +ALLOCSRCDIR = os.path.join(SRCDIR, "allocators") + +# /.../allocbench +ALLOCBENCHDIR = os.path.dirname(SRCDIR) + +# /.../allocbench/build +BUILDDIR = os.path.join(ALLOCBENCHDIR, "build") + +# /.../allocbench/build/allocators +ALLOCBUILDDIR = os.path.join(BUILDDIR, "allocators") + +RESDIR = None + +BENCHMARKS = [e[:-3] for e in os.listdir(os.path.join(ALLOCBENCHDIR, BENCHSRCDIR)) + if e[-3:] == ".py" and e != "__init__.py"] + +SUMMARY_FILE_EXT = "svg" + +LATEX_CUSTOM_PREAMBLE = "" diff --git a/src/malloc.c b/allocbench/malloc.c index 92265cb..92265cb 100644 --- a/src/malloc.c +++ b/allocbench/malloc.c diff --git a/src/plots.py b/allocbench/plots.py index fb39578..38c988c 100644 --- a/src/plots.py +++ b/allocbench/plots.py @@ -18,17 +18,19 @@ import copy import itertools +import os +import traceback + import matplotlib import matplotlib.pyplot as plt import numpy as np -import os -import traceback -import src.globalvars -from src.util import print_debug, print_warn +import allocbench.facter as facter +from allocbench.globalvars import SUMMARY_FILE_EXT, LATEX_CUSTOM_PREAMBLE +from allocbench.util import print_debug, print_warn # This is useful when evaluating strings in the plot functions. str(np.NaN) == "nan" -nan = np.NaN +nan = np.NaN # pylint: disable=invalid-name DEFAULT_PLOT_OPTIONS = { 'plot': { @@ -65,23 +67,26 @@ DEFAULT_FIG_OPTIONS = { FIGURES = {} -def _get_alloc_color(bench, alloc): +def _set_all_alloc_colors(allocators): """Populate all not set allocator colors with matplotlib 'C' colors""" + explicit_colors = [ + v["color"] for v in allocators.values() if v["color"] is not None + ] + matplotlib_c_colors = ["C" + str(i) for i in range(0, 10)] + avail_colors = [ + c for c in matplotlib_c_colors if c not in explicit_colors + ] + + for alloc in allocators.values(): + if alloc["color"] is None: + alloc["color"] = avail_colors.pop() + +def get_alloc_color(bench, alloc): + """Retrieve color of an allocator""" if isinstance(alloc, str): alloc = bench.results["allocators"][alloc] if alloc["color"] is None: - allocs = bench.results["allocators"] - explicit_colors = [ - v["color"] for v in allocs.values() if v["color"] is not None - ] - matplotlib_c_colors = ["C" + str(i) for i in range(0, 10)] - avail_colors = [ - c for c in matplotlib_c_colors if c not in explicit_colors - ] - - for alloc in allocs.values(): - if alloc["color"] is None: - alloc["color"] = avail_colors.pop() + _set_all_alloc_colors(bench.results["allocators"]) return alloc["color"] @@ -180,9 +185,8 @@ def _plot(bench, plot_options, fig_options, scale=None, - file_postfix="", sumdir="", - file_ext=src.globalvars.summary_file_ext): + file_ext=SUMMARY_FILE_EXT): """ Create a plot for a given expression @@ -235,14 +239,14 @@ def _plot(bench, plot_func(_x_data, y_data, label=allocator, - color=_get_alloc_color(bench, allocator), + color=get_alloc_color(bench, allocator), **plot_options) if fig_options['legend']: plt.legend(loc=fig_options['legend_pos']) if not fig_options['autoticks']: - plt.xticks(_x_data - (i / 2 * plot_options['width']), x_data) + plt.xticks(_x_data - (len(allocators) / 2 * plot_options['width']), x_data) plt.xlabel(fig_options['xlabel']) plt.ylabel(fig_options['ylabel']) @@ -266,7 +270,7 @@ def plot(bench, fig_options=None, file_postfix="", sumdir="", - file_ext=src.globalvars.summary_file_ext): + file_ext=SUMMARY_FILE_EXT): """ Create plots for a given expression for the y axis. @@ -313,9 +317,9 @@ def plot(bench, Directory where the plot should be saved. If not provided defaults to the current working directory. - file_ext : str, optional, default=:rc:`src.globalvars.summary_file_ext` + file_ext : str, optional, default=:rc:`allocbench.globalvars.SUMMARY_FILE_EXT` File extension of the saved plot. If not provided defaults to the - value of :rc:`src.globalvars.summary_file_ext` + value of :rc:`allocbench.globalvars.SUMMARY_FILE_EXT` """ @@ -329,8 +333,6 @@ def plot(bench, fixed_args = [[(k, v) for v in args[k]] for k in args if k != loose_arg] for fixed_part in itertools.product(*fixed_args): - fixed_part = {k:v for k, v in fixed_part} - fixed_part_str = ".".join([f'{k}={v}' for k, v in fixed_part.items()]) fig_label = f'{bench.name}.{fixed_part_str}.{file_postfix}' @@ -358,11 +360,14 @@ def plot(bench, list(bench.iterate_args(args=args, fixed=fixed_part)), plot_type, cur_plot_options, - cur_fig_options) + cur_fig_options, + scale=scale, + sumdir=sumdir, + file_ext=file_ext) def print_common_facts(comment_symbol="", file=None): print(comment_symbol, "Common facts:", file=file) - for fact, value in src.facter.FACTS.items(): + for fact, value in facter.FACTS.items(): print(f"{comment_symbol} {fact}: {value}", file=file) print(file=file) @@ -647,9 +652,11 @@ def pgfplot_legend(bench, for alloc_name, alloc_dict in allocators.items(): if colors: # define color - rgb = matplotlib.colors.to_rgb(_get_alloc_color(bench, alloc_dict)) - color_definitions += f"\\providecolor{{{alloc_name}-color}}{{rgb}}{{{rgb[0]},{rgb[1]},{rgb[2]}}}\n" - color_definitions += f"\\pgfplotsset{{{alloc_name}/.style={{color={alloc_name}-color}}}}\n\n" + rgb = matplotlib.colors.to_rgb(get_alloc_color(bench, alloc_dict)) + color_definitions += (f"\\providecolor{{{alloc_name}-color}}" + f"{{rgb}}{{{rgb[0]},{rgb[1]},{rgb[2]}}}\n") + color_definitions += (f"\\pgfplotsset{{{alloc_name}/" + f".style={{color={alloc_name}-color}}}}\n\n") alloc_color = "" if colors: @@ -665,7 +672,7 @@ f""" \\usepackage{{xcolor}} {color_definitions} -{src.globalvars.latex_custom_preamble} +{LATEX_CUSTOM_PREAMBLE} \\begin{{document}} \\begin{{tikzpicture}} \\begin{{axis}} [ @@ -716,9 +723,11 @@ def pgfplot(bench, for alloc_name, alloc_dict in allocators.items(): if colors: # define color - rgb = matplotlib.colors.to_rgb(_get_alloc_color(bench, alloc_dict)) - color_definitions += f"\\providecolor{{{alloc_name}-color}}{{rgb}}{{{rgb[0]},{rgb[1]},{rgb[2]}}}\n" - style_definitions += f"\\pgfplotsset{{{alloc_name}/.style={{color={alloc_name}-color}}}}\n\n" + rgb = matplotlib.colors.to_rgb(get_alloc_color(bench, alloc_dict)) + color_definitions += (f"\\providecolor{{{alloc_name}-color}}" + "{{rgb}}{{{rgb[0]},{rgb[1]},{rgb[2]}}}\n") + style_definitions += (f"\\pgfplotsset{{{alloc_name}/" + ".style={{color={alloc_name}-color}}}}\n\n") eb = "" ebt = "" diff --git a/src/print_status_on_exit.c b/allocbench/print_status_on_exit.c index 5775afc..5775afc 100644 --- a/src/print_status_on_exit.c +++ b/allocbench/print_status_on_exit.c diff --git a/src/sig_handlers.c b/allocbench/sig_handlers.c index 3274482..3274482 100644 --- a/src/sig_handlers.c +++ b/allocbench/sig_handlers.c diff --git a/src/util.py b/allocbench/util.py index fb0e75b..08fc11d 100644 --- a/src/util.py +++ b/allocbench/util.py @@ -21,7 +21,7 @@ import os import subprocess import sys -import src.globalvars +import allocbench.globalvars def run_cmd(cmd, @@ -35,7 +35,7 @@ def run_cmd(cmd, if capture: stdout = subprocess.PIPE stderr = stdout - elif src.globalvars.verbosity < output_verbosity: + elif allocbench.globalvars.VERBOSITY < output_verbosity: stdout = subprocess.DEVNULL stderr = stdout else: @@ -100,7 +100,7 @@ def prefix_cmd_with_abspath(cmd): def allocbench_msg(color, *objects, sep=' ', end='\n', file=None): """Colored output function wrapping print""" - if src.globalvars.verbosity < 0: + if allocbench.globalvars.VERBOSITY < 0: return color = { @@ -121,28 +121,28 @@ def allocbench_msg(color, *objects, sep=' ', end='\n', file=None): def print_debug(*objects, sep=' ', end='\n', file=None): """Print colorless debug message""" - if src.globalvars.verbosity < 3: + if allocbench.globalvars.VERBOSITY < 3: return print(*objects, sep=sep, end=end, file=file) def print_info(*objects, sep=' ', end='\n', file=None): """Print colorless info message""" - if src.globalvars.verbosity < 1: + if allocbench.globalvars.VERBOSITY < 1: return print(*objects, sep=sep, end=end, file=file) def print_info0(*objects, sep=' ', end='\n', file=None): """Print colorless info message at every verbosity level message""" - if src.globalvars.verbosity < 0: + if allocbench.globalvars.VERBOSITY < 0: return print(*objects, sep=sep, end=end, file=file) def print_info2(*objects, sep=' ', end='\n', file=None): """Print colorless info message at the second verbosity level message""" - if src.globalvars.verbosity < 2: + if allocbench.globalvars.VERBOSITY < 2: return print(*objects, sep=sep, end=end, file=file) @@ -154,7 +154,7 @@ def print_status(*objects, sep=' ', end='\n', file=None): def print_warn(*objects, sep=' ', end='\n', file=None): """Print yellow warning""" - if src.globalvars.verbosity < 1: + if allocbench.globalvars.VERBOSITY < 1: return allocbench_msg("YELLOW", *objects, sep=sep, end=end, file=file) @@ -177,7 +177,7 @@ def sha1sum(filename): sha1 = hashlib.sha1() barray = bytearray(64 * 1024) view = memoryview(barray) - with open(filename, 'rb', buffering=0) as f: - for n in iter(lambda: f.readinto(view), 0): + with open(filename, 'rb', buffering=0) as input_file: + for n in iter(lambda: input_file.readinto(view), 0): sha1.update(view[:n]) return sha1.hexdigest() @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -26,14 +26,14 @@ import os import sys import traceback -from src.allocator import collect_allocators -from src.analyse import analyze_bench, analyze_allocators -import src.facter -import src.globalvars -from src.util import find_cmd, run_cmd -from src.util import print_status, print_warn, print_error -from src.util import print_info, print_info2, print_debug -from src.util import print_license_and_exit +from allocbench.allocator import collect_allocators +from allocbench.analyse import analyze_bench, analyze_allocators +import allocbench.facter as facter +import allocbench.globalvars +from allocbench.util import find_cmd, run_cmd +from allocbench.util import print_status, print_warn, print_error +from allocbench.util import print_info, print_info2, print_debug +from allocbench.util import print_license_and_exit from summarize import summarize @@ -41,15 +41,15 @@ from summarize import summarize def epilog(): """Run tasks on exit""" # After early errors resdir may not be set - if src.globalvars.resdir is not None: - if os.listdir(src.globalvars.resdir) == []: + if allocbench.globalvars.RESDIR is not None: + if os.listdir(allocbench.globalvars.RESDIR) == []: print_warn("Remove empty resultdir") - os.removedirs(src.globalvars.resdir) + os.removedirs(allocbench.globalvars.RESDIR) else: endtime = datetime.datetime.now().isoformat() endtime = endtime[:endtime.rfind(':')] - src.facter.FACTS["endtime"] = endtime - src.facter.store_facts(src.globalvars.resdir) + facter.FACTS["endtime"] = endtime + facter.store_facts(allocbench.globalvars.RESDIR) # remove a left over status file if some is present if os.path.exists("status"): @@ -63,14 +63,6 @@ def check_dependencies(): print_error("At least python version 3.6 is required.") sys.exit(1) - # matplotlib is needed by Benchmark.plot_* - try: - importlib.import_module("matplotlib") - except ModuleNotFoundError: - print_error("matplotlib not found.") - sys.exit(1) - # TODO mariadb - def main(): check_dependencies() @@ -116,7 +108,7 @@ def main(): parser.add_argument("--version", help="print version info and exit", action='version', - version=f"allocbench {src.facter.allocbench_version()}") + version=f"allocbench {facter.allocbench_version()}") args = parser.parse_args() if args.license: @@ -131,57 +123,58 @@ def main(): # 2: Print all infos # 3: Print everything if args.verbose: - src.globalvars.verbosity = args.verbose + allocbench.globalvars.VERBOSITY = args.verbose print_info2("Arguments:", args) # Prepare allocbench print_status("Building allocbench ...") make_cmd = ["make"] - if src.globalvars.verbosity < 2: + if allocbench.globalvars.VERBOSITY < 2: make_cmd.append("-s") run_cmd(make_cmd, output_verbosity=1) # allocators to benchmark - src.globalvars.allocators = collect_allocators(args.allocators) + allocbench.globalvars.ALLOCATORS = collect_allocators(args.allocators) - print_info("Allocators:", *src.globalvars.allocators.keys()) - print_debug("Allocators:", *src.globalvars.allocators.items()) + print_info("Allocators:", *allocbench.globalvars.ALLOCATORS.keys()) + print_debug("Allocators:", *allocbench.globalvars.ALLOCATORS.items()) - if src.globalvars.allocators == {}: + if allocbench.globalvars.ALLOCATORS == {}: print_error("Abort because there are no allocators to benchmark") sys.exit(1) # collect facts about benchmark environment - src.facter.collect_facts() + facter.collect_facts() # Create result directory if args.resultdir: - src.globalvars.resdir = os.path.join(args.resultdir) + allocbench.globalvars.RESDIR = os.path.join(args.resultdir) else: - src.globalvars.resdir = os.path.join("results", - src.facter.FACTS["hostname"], - src.facter.FACTS["starttime"]) + allocbench.globalvars.RESDIR = os.path.join("results", + facter.FACTS["hostname"], + facter.FACTS["starttime"]) - print_status("Writing results to:", src.globalvars.resdir) - os.makedirs(src.globalvars.resdir, exist_ok=True) + print_status("Writing results to:", allocbench.globalvars.RESDIR) + os.makedirs(allocbench.globalvars.RESDIR, exist_ok=True) cwd = os.getcwd() # warn about unknown benchmarks for bench in (args.benchmarks or []) + (args.exclude_benchmarks or []): - if bench not in src.globalvars.benchmarks: + if bench not in allocbench.globalvars.BENCHMARKS: print_error(f'Benchmark "{bench}" unknown!') # Run actual benchmarks - for bench in src.globalvars.benchmarks: + for bench in allocbench.globalvars.BENCHMARKS: if args.benchmarks and bench not in args.benchmarks: continue if args.exclude_benchmarks and bench in args.exclude_benchmarks: continue - bench_module = importlib.import_module(f"src.benchmarks.{bench}") + bench_module = importlib.import_module( + f"allocbench.benchmarks.{bench}") if not hasattr(bench_module, bench): print_error(f"{bench_module} has no member {bench}.") @@ -202,7 +195,7 @@ def main(): analyze_bench(bench) if args.analyze_allocators: - analyze_allocators(bench, src.globalvars.allocators) + analyze_allocators(bench, allocbench.globalvars.ALLOCATORS) if args.runs > 0: print_status("Running", bench.name, "...") @@ -223,7 +216,7 @@ def main(): start_time).total_seconds() # Save results in resultdir - bench.save(src.globalvars.resdir) + bench.save(allocbench.globalvars.RESDIR) if hasattr(bench, "cleanup"): print_status("Cleaning up", bench.name, "...") diff --git a/doc/Allocators.md b/doc/Allocators.md index 30d4abc..3148c45 100644 --- a/doc/Allocators.md +++ b/doc/Allocators.md @@ -40,4 +40,4 @@ To reproducible build allocators and patched version you can use the classes `Allocator` and `Allocator_Sources` provided in `src/allocator.py`. See [allocators/no_falsesharing.py](allocators/no_falsesharing.py) or -[allocators/BA_allocators.py](allocators/BA_allocators.py) for examples. +[allocators/ba_allocators.py](allocators/ba_allocators.py) for examples. diff --git a/doc/Benchmarks.md b/doc/Benchmarks.md index e883afb..e8add89 100644 --- a/doc/Benchmarks.md +++ b/doc/Benchmarks.md @@ -46,9 +46,9 @@ Delorie using the tools from dj/malloc branch of the glibc. 1. Make sure your command is deterministic and allocator behavior is a significant part of your measured results 2. Create a new Python class for your benchmark. You can inherit from the - provided class src.Benchmark. + provided class allocbench.Benchmark. 3. Implement your custom functionality -4. Export a object of your class in a python file under src/benchmarks named +4. Export a object of your class in a python file under allocbench/benchmarks named like your exported object and allocbench will find it automatically. #### loop.py as Example @@ -73,7 +73,7 @@ Delorie using the tools from dj/malloc branch of the glibc. """Definition of the loop micro benchmark""" -from src.benchmark import Benchmark +from allocbench.benchmark import Benchmark class BenchmarkLoop(Benchmark): @@ -129,7 +129,7 @@ loop = BenchmarkLoop() ## The Benchmark class -The class Benchmark defined in the src/benchmark.py implements most +The class Benchmark defined in the allocbench/benchmark.py implements most common operations for a benchmark. It provides load and save functions using pythons pickle module, helpers generating plots using matplotlib and most importantly a run method using @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -25,16 +25,16 @@ import os import pickle import sys -import src.facter -from src.util import print_license_and_exit +import allocbench.facter as facter +from allocbench.util import print_license_and_exit def load_file(filename): if filename.endswith("json"): - with open(filename, "r") as f: - return json.load(f) + with open(filename, "r") as json_file: + return json.load(json_file) else: - with open(filename, "rb") as f: - return pickle.load(f) + with open(filename, "rb") as pickle_file: + return pickle.load(pickle_file) def main(): @@ -46,7 +46,7 @@ def main(): parser.add_argument("dest", help="results in which src should be merged", type=str) parser.add_argument("--license", help="print license info and exit", action='store_true') parser.add_argument("--version", help="print version info and exit", action='version', - version=f"allocbench {src.facter.allocbench_version()}") + version=f"allocbench {facter.allocbench_version()}") parser.add_argument("-b", "--benchmarks", help="benchmarks to summarize", nargs='+') parser.add_argument("-x", "--exclude-benchmarks", help="benchmarks to exclude", nargs='+') diff --git a/scripts/histogram.py b/scripts/histogram.py index 2dd3b6c..5bca21c 100755 --- a/scripts/histogram.py +++ b/scripts/histogram.py @@ -1,5 +1,22 @@ #!/usr/bin/env python3 +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> +# +# This file is part of allocbench. +# +# allocbench is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# allocbench is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with allocbench. If not, see <http://www.gnu.org/licenses/>. + """Plot an interactive histogram from malt or chattymalloc output file""" import argparse @@ -15,7 +32,6 @@ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) -import src.chattyparser def main(): parser = argparse.ArgumentParser(description="Plot histograms using a malt or chattymalloc output file") @@ -30,11 +46,16 @@ def main(): fname = os.path.basename(fpath) # chattymalloc if fname.startswith("chatty") and fext == ".txt": - hist, calls, _ = src.chattyparser.parse(args.input_file, coll_size=False) + try: + chattyparser = importlib.import_module("chattyparser") + except ModuleNotFoundError as err: + print("Can't import chattyparser") + sys.exit(1) + hist, calls, _ = chattyparser.parse(args.input_file, coll_size=False) # malt else: with open(args.input_file, "r") as json_file: - malt_res = json.load(json_file) + malt_res = json.load(json_file) hist = malt_res["memStats"]["sizeMap"] calls = {} @@ -49,7 +70,7 @@ def main(): print(size, amount, file=csv_file) if not args.no_ascii: - src.chattyparser.plot_hist_ascii(f"{fpath}.hist.txt", hist, calls) + chattyparser.plot_hist_ascii(f"{fpath}.hist.txt", hist, calls) if args.interactive: sizes = [] diff --git a/scripts/paper_plots.py b/scripts/paper_plots.py index 9b15220..d1aad21 100755 --- a/scripts/paper_plots.py +++ b/scripts/paper_plots.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -28,17 +28,17 @@ currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) -import src.allocators.paper -import src.facter -import src.globalvars -import src.plots as plt -from src.util import print_status, print_warn, print_error -from src.util import print_license_and_exit +from allocbench.allocators.paper import allocators as paper_allocators +import allocbench.facter as facter +import allocbench.globalvars +import allocbench.plots as plt +from allocbench.util import print_status, print_warn, print_error +from allocbench.util import print_license_and_exit -ALLOCATOR_NAMES = [a.name for a in src.allocators.paper.allocators] -SURVEY_ALLOCATORS = [a.name for a in src.allocators.paper.allocators if not '-' in a.name or a.name not in ["speedymalloc", "bumpptr"]] -TCMALLOCS = [a.name for a in src.allocators.paper.allocators if a.name.startswith("TCMalloc")] -ALIGNED_ALLOCATORS = [a.name for a in src.allocators.paper.allocators if a.name.endswith("-Aligned")] +ALLOCATOR_NAMES = [a.name for a in paper_allocators] +SURVEY_ALLOCATORS = [a.name for a in paper_allocators if not '-' in a.name or a.name not in ["speedymalloc", "bumpptr"]] +TCMALLOCS = [a.name for a in paper_allocators if a.name.startswith("TCMalloc")] +ALIGNED_ALLOCATORS = [a.name for a in paper_allocators if a.name.endswith("-Aligned")] def falsesharing_plots(falsesharing): @@ -110,8 +110,8 @@ def blowup_plots(blowup): bar=True) def loop_plots(loop): - args = blowup.results["args"] - loop.results["allocators"] = {k: v for k, v in blowup.results["allocators"].items() if k in ALLOCATOR_NAMES} + args = loop.results["args"] + loop.results["allocators"] = {k: v for k, v in loop.results["allocators"].items() if k in ALLOCATOR_NAMES} plt.pgfplot(loop, loop.iterate_args_fixed({"threads": 40}, args), @@ -178,7 +178,7 @@ def summarize(benchmarks=None, exclude_benchmarks=None): if exclude_benchmarks and benchmark in exclude_benchmarks: continue - bench_module = importlib.import_module(f"src.benchmarks.{benchmark}") + bench_module = importlib.import_module(f"allocbench.benchmarks.{benchmark}") if not hasattr(bench_module, benchmark): print_error(f"{benchmark} has no member {benchmark}") @@ -187,14 +187,14 @@ def summarize(benchmarks=None, exclude_benchmarks=None): bench = getattr(bench_module, benchmark) try: - bench.load(src.globalvars.resdir) + bench.load(allocbench.globalvars.resdir) except FileNotFoundError: print_warn(f"Skipping {bench.name}. No results found") continue print_status(f"Summarizing {bench.name} ...") - res_dir = os.path.join(src.globalvars.resdir, bench.name, "paper") + res_dir = os.path.join(allocbench.globalvars.resdir, bench.name, "paper") if not os.path.isdir(res_dir): os.makedirs(res_dir) os.chdir(res_dir) @@ -212,7 +212,7 @@ if __name__ == "__main__": parser.add_argument("--version", help="print version info and exit", action='version', - version=f"allocbench {src.facter.allocbench_version()}") + version=f"allocbench {facter.allocbench_version()}") parser.add_argument("-v", "--verbose", help="more output", action='count') parser.add_argument("-b", "--benchmarks", @@ -229,19 +229,19 @@ if __name__ == "__main__": args = parser.parse_args() if args.verbose: - src.globalvars.verbosity = args.verbose + allocbench.globalvars.verbosity = args.verbose if args.latex_preamble: - src.globalvars.latex_custom_preamble = args.latex_preamble + allocbench.globalvars.latex_custom_preamble = args.latex_preamble if not os.path.isdir(args.results): print_error(f"{args.results} is no directory") sys.exit(1) - src.globalvars.resdir = args.results + allocbench.globalvars.resdir = args.results # Load facts - src.facter.load_facts(src.globalvars.resdir) + facter.load_facts(allocbench.globalvars.resdir) summarize(benchmarks=args.benchmarks, exclude_benchmarks=args.exclude_benchmarks) diff --git a/scripts/print_facts.py b/scripts/print_facts.py index 831cc78..389028e 100755 --- a/scripts/print_facts.py +++ b/scripts/print_facts.py @@ -29,9 +29,10 @@ CURRENTDIR = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentfram PARENTDIR = os.path.dirname(CURRENTDIR) sys.path.insert(0, PARENTDIR) -import src.facter -from src.plots import print_facts, print_common_facts -from src.util import print_error +import allocbench.facter as facter +from allocbench.globalvars import BENCHMARKS +from allocbench.plots import print_facts, print_common_facts +from allocbench.util import print_error def main(): @@ -40,15 +41,15 @@ def main(): args = parser.parse_args() # Load common facts - src.facter.load_facts(args.results) + facter.load_facts(args.results) print_common_facts() cwd = os.getcwd() os.chdir(args.results) - for benchmark in src.globalvars.benchmarks: - bench_module = importlib.import_module(f"src.benchmarks.{benchmark}") + for benchmark in BENCHMARKS: + bench_module = importlib.import_module(f"allocbench.benchmarks.{benchmark}") if not hasattr(bench_module, benchmark): print_error(f"{benchmark} has no member {benchmark}") diff --git a/src/globalvars.py b/src/globalvars.py deleted file mode 100644 index 474c124..0000000 --- a/src/globalvars.py +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> -# -# This file is part of allocbench. -# -# allocbench is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# allocbench is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with allocbench. If not, see <http://www.gnu.org/licenses/>. - -"""Global variables for allocbench - -verbosity: Verbosity level -1: quiet, 0: status, 1: info, 2: stdout of subcommands, 3: debug info -allocators: Dict holding the allocators to compare -benchmarks: List of available benchmarks - -allocbenchdir: Root directory of allocbench -srcdir: Directory of allocbench sources -benchsrcdir: Source directory for all benchmarks -allocsrcdir: Source directory for all benchmarks -builddir: Path of the build directory -allocbuilddir: Path of the allocators build directory -resdir: Directory were the benchmark results are stored -""" - -import inspect -import os - - -verbosity = 0 - -allocators = {} - -# allocbench/src/ -srcdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) - -# allocbench/src/benchmarks -benchsrcdir = os.path.join(srcdir, "benchmarks") - -# allocbench/src/allocators -allocsrcdir = os.path.join(srcdir, "allocators") - -# allocbench -allocbenchdir = os.path.dirname(srcdir) - -# allocbench/build -builddir = os.path.join(allocbenchdir, "build") - -# allocbench/build/allocators -allocbuilddir = os.path.join(builddir, "allocators") - -resdir = None - -benchmarks = [e[:-3] for e in os.listdir(os.path.join(allocbenchdir, benchsrcdir)) - if e[-3:] == ".py" and e != "__init__.py"] - -summary_file_ext = "svg" - -latex_custom_preamble = "" diff --git a/summarize.py b/summarize.py index 8f1d8f4..fd1926b 100755 --- a/summarize.py +++ b/summarize.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de> +# Copyright 2018-2020 Florian Fischer <florian.fl.fischer@fau.de> # # This file is part of allocbench. # @@ -23,10 +23,10 @@ import importlib import os import sys -import src.facter -import src.globalvars -from src.util import print_status, print_debug, print_error -from src.util import print_license_and_exit +import allocbench.facter as facter +import allocbench.globalvars +from allocbench.util import print_status, print_debug, print_error +from allocbench.util import print_license_and_exit ALLOCS_TO_EXCLUDE = [] @@ -61,7 +61,7 @@ def specific_summary(bench, sum_dir, allocators): if value["color"] is None: value["color"] = avail_colors.pop() - src.globalvars.allocators = allocators + allocbench.globalvars.allocators = allocators bench.summary() bench.results["allocators"] = old_allocs @@ -86,8 +86,11 @@ def bench_sum(bench): "research": ["scalloc", "SuperMalloc", "Mesh", "Hoard", "snmalloc"] } - old_allocs = bench.results["allocators"] - new_allocs = {an: a for an, a in bench.results["allocators"].items() if an not in ALLOCS_TO_EXCLUDE} + new_allocs = { + an: a + for an, a in bench.results["allocators"].items() + if an not in ALLOCS_TO_EXCLUDE + } bench.results["allocators"] = new_allocs os.makedirs(bench.name) @@ -108,15 +111,16 @@ def summarize(benchmarks=None, exclude_benchmarks=None): """summarize the benchmarks in the resdir""" cwd = os.getcwd() - os.chdir(src.globalvars.resdir) + os.chdir(allocbench.globalvars.resdir) - for benchmark in src.globalvars.benchmarks: + for benchmark in allocbench.globalvars.BENCHMARKS: if benchmarks and not benchmark in benchmarks: continue if exclude_benchmarks and benchmark in exclude_benchmarks: continue - bench_module = importlib.import_module(f"src.benchmarks.{benchmark}") + bench_module = importlib.import_module( + f"allocbench.benchmarks.{benchmark}") if not hasattr(bench_module, benchmark): print_error(f"{benchmark} has no member {benchmark}") @@ -132,8 +136,8 @@ def summarize(benchmarks=None, exclude_benchmarks=None): print_status(f"Summarizing {bench.name} ...") try: bench_sum(bench) - except FileExistsError as e: - print(e) + except FileExistsError as err: + print(err) os.chdir(cwd) @@ -155,7 +159,7 @@ if __name__ == "__main__": parser.add_argument("--version", help="print version info and exit", action='version', - version=f"allocbench {src.facter.allocbench_version()}") + version=f"allocbench {facter.allocbench_version()}") parser.add_argument("-v", "--verbose", help="more output", action='count') parser.add_argument("-b", "--benchmarks", @@ -169,23 +173,25 @@ if __name__ == "__main__": "--exclude-allocators", help="allocators to exclude", nargs='+') - parser.add_argument("--latex-preamble", - help="latex code to include in the preamble of generated standalones", - type=str) - parser.add_argument("-i", "--interactive", + parser.add_argument( + "--latex-preamble", + help="latex code to include in the preamble of generated standalones", + type=str) + parser.add_argument("-i", + "--interactive", help="drop into repl after summarizing the results", action='store_true') args = parser.parse_args() if args.verbose: - src.globalvars.verbosity = args.verbose + allocbench.globalvars.verbosity = args.verbose if args.file_ext: - src.globalvars.summary_file_ext = args.file_ext + allocbench.globalvars.summary_file_ext = args.file_ext if args.latex_preamble: - src.globalvars.latex_custom_preamble = args.latex_preamble + allocbench.globalvars.latex_custom_preamble = args.latex_preamble if not os.path.isdir(args.results): print_error(f"{args.results} is no directory") @@ -193,10 +199,10 @@ if __name__ == "__main__": ALLOCS_TO_EXCLUDE = args.exclude_allocators or [] - src.globalvars.resdir = args.results + allocbench.globalvars.resdir = args.results # Load facts - src.facter.load_facts(src.globalvars.resdir) + facter.load_facts(allocbench.globalvars.resdir) summarize(benchmarks=args.benchmarks, exclude_benchmarks=args.exclude_benchmarks) |
