Giter Club home page Giter Club logo

stabilizer's Introduction

Stabilizer: Statistically Sound Performance Evaluation

Charlie Curtsinger and Emery D. Berger University of Massachusetts Amherst

Abstract

Researchers and software developers require effective performance evaluation. Researchers must evaluate optimizations or measure overhead. Software developers use automatic performance regression tests to discover when changes improve or degrade performance. The standard methodology is to compare execution times before and after applying changes.

Unfortunately, modern architectural features make this approach unsound. Statistically sound evaluation requires multiple samples to test whether one can or cannot (with high confidence) reject the null hypothesis that results are the same before and after. However, caches and branch predictors make performance dependent on machine-specific parameters and the exact layout of code, stack frames, and heap objects. A single binary constitutes just one sample from the space of program layouts, regardless of the number of runs. Since compiler optimizations and code changes also alter layout, it is currently impossible to distinguish the impact of an optimization from that of its layout effects.

Stabilizer is a system that enables the use of the powerful statistical techniques required for sound performance evaluation on modern architectures. Stabilizer forces executions to sample the space of memory configurations by repeatedly rerandomizing layouts of code, stack, and heap objects at runtime. STABILIZER thus makes it possible to control for layout effects. Re-randomization also ensures that layout effects follow a Gaussian distribution, enabling the use of statistical tests like ANOVA. We demonstrate Stabilizer'sโ€™s efficiency (< 7% median overhead) and its effectiveness by evaluating the impact of LLVMโ€™s optimizations on the SPEC CPU2006 benchmark suite. We find that, while -O2 has a significant impact relative to -O1, the performance impact of -O3 over -O2 optimizations is indistinguishable from random noise.

A full description of Stabilizer is available in the technical paper, which appeared at ASPLOS 2013.

See also this nice blog post about this research.

Building Requirements

NOTE: This project is no longer being actively maintained, and only works on quite old versions of LLVM.

Stabilizer requires LLVM 3.1. Stabilizer runs on OSX and Linux, and supports x86, x86_64, and PowerPC.

Stabilizer requires LLVM 3.1. Follow the directions here to build LLVM 3.1 and the Clang front-end. Stabilizer's build system assumes LLVM include files will be accessible through your default include path.

By default, Stabilizer will use GCC and the Dragonegg plugin to produce LLVM IR. Fortran programs can only be built with the GCC front end. Stabilizer is tested against GCC version 4.6.2.

Stabilizer's compiler driver szc is written in Python. It uses the argparse module, so a relatively modern version of Python (>=2.7) is required.

Building Stabilizer

$ git clone git://github.com/ccurtsinger/stabilizer.git stabilizer
$ make

By default, Stabilizer is build with debug output enabled. Run make clean release to build the release version with asserts and debug output disabled.

Using Stabilizer

Stabilizer includes the szc compiler driver, which builds programs using the Stabilizer compiler transformations. szc passes on common GCC flags, and is compatible with C, C++ and Fortran inputs.

To compile a program in foo.c with Stabilizer, run:

$ szc -Rcode -Rstack -Rheap foo.c -o foo

The -R flags enable randomizations, and may be used in any combination. Stabilizer uses GCC with the Dragonegg plugin as its default front-end. To use clang, pass -frontend=clang to szc.

The resulting executable is linked against with libstabilizer.so (or .dylib on OSX). Place this library somewhere in your system's dynamic library search path or (preferably) add the Stabilizer base directory to your LD_LIBRARY_PATH or DYLD_LIBRARY_PATH environment variable.

SPEC CPU2006

The szchi.cfg and szclo.cfg config files can be installed in a SPEC CPU2006 config directory to build and run benchmarks with Stabilizer. The szchi config -O2 for base and -O3 for peak tuning, and szclo uses -O0 and -O1.

The run.py and process.py scripts were used to drive experiments and collect results. The run script accepts optimization levels, benchmarks to enable (or disable with a "-" prefix), a number of runs, and build configurations in any order. For example:

$ ./run.py 10 bzip2 code code.stack code.heap.stack

This will run the bzip2 benchmark 10 times in each of three randomization configurations. The runspec tool must be in your path, so cd to your SPEC installation and sourceh shrc first.

$ ./run.py 10 -astar code link O2 O3

This will run every benchmark except astar 10 times with link randomization at -O2 and -O3 optimization levels.

Be warned: there is no easy way to distinguish O2 and O0 results after the fact: both are marked as "base" tuning. Keep these results in separate directories.

The process script reads .rsf files from SPEC and provides some summary statistics, or collects results in an easy-to-process format.

$ ./process.py $SPEC/result/*.rsf

This will print average runtimes for each benchmark in each configuration and tuning level for the runs in your SPEC results directory.

Pass the -trim flag to remove the highest and lowest runtimes before computing the average.

The -norm flag tests the results for normality using the Shapiro-Wilk test.

The -all flag dumps all results to console, suitable for pasting into a spreadsheet or CSV file.

stabilizer's People

Contributors

ccurtsinger avatar emeryberger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stabilizer's Issues

Announce: Fork with rewritten compiler wrapper

Yes, this is a little shameless self-promotion, but hopefully for the good of the project.

Because this project has not been maintained for years, and there is a fragmented fork network with mostly half-working versions of Stabilizer, I have taken it upon myself to fork this project and will try to actively maintain it. Note: @ccurtsinger has not endorsed this in any way.

I have made some changes in my fork however.
One of the biggest hurdles for anyone wanting to test Stabilizer with their own application is that szc will fail even the most basic CMake or AutoConf compiler detection. Therefore, before anyone can even test this they might have to do a big rewrite of their applications build system, that would be very hard for bigger projects like Chromium for example.

Therefore I have rewritten the compiler wrapper from scratch, and renamed it to szcc. Now most compiler detection code will succeed, and can it often be used as a drop-in compiler "replacement" for many applications. There are still corner-case bugs, for example I know that gbench fails to compile, and I will accept PRs to fix these if you have the interest and time to contribute.
This makes it a lot easier for anyone to test Stabilizer without investing a lot of time and effort into it before even being able to do anything basic with it.

Unfortunately although Stabilizer has been attempted ported to newer versions of LLVM, and compiles with those, it is causing crashes. Probably the porting effort has been best-effort and is just incomplete. Cudos to @Fusilet @dendibakh @jgall @magras @timadye and others for their efforts though.

One major problem for me is that I do not know how LLVM-pass stuff works at all, so while I have been looking at that code to attempt to find the culprits of the Code Randomization and Stack Randomization crashes, I have very little idea what I'm even looking for. One of those issues has been documented in Issue 1 on my fork so that anyone interested can read up on the symptoms, if anyone has anything to contribute to that analysis or even better a bugfix then that is greatly appreciated.

Hopefully now that Stabilizer is easier to use, it will also be easier to find someone interested in contributing fixes.

In other words, I will attempt to actively maintain the repo and fix any issues that I am able to, but I will also need help to fix some of the Stabilizer functionality. I intentionally broke the Github fork-tree so that it will be less confusing and easier to find up-to-date forks, this Github feature is really not great when the parent project has gone dormant.
If @ccurtsinger wants to become an active maintainer of Stabilizer again, I will happily step aside. My main interest and motivation is that this amazing tool becomes more useful to all the open-source projects out there. If @ccurtsinger would contribute some insight into what the crash bugs are likely caused by, that would be really awesome of course ๐Ÿ˜‰.

Please have a look at the readme of my fork for more information about the changes I have made https://github.com/Dead2/stabilizer

Support for ARM64

I would really appreciate if the STABILIZER would support ARM64.

Maybe you could take this into consideration.

Best

Anything useable these days?

Hi all,

As stabilizer is not compatible with LLVM versions that still works on current OSes (we're 7 versions of LLVM ahead now, no C++17, etc), is there a simpler way to approach the effect of Stabilizer? In "Producing Wrong Data Without Doing Anything Obviously Wrong!", they randomized the order of the .o file, and change the environment size. Is that still the second-best option?

It's not strictly linked to stabilizer, but I'm not sure where to ask that and it's a discussion which is way too much forgotten in computer sciences...

Thanks,
Tom

rustc support?

Hello,

I'm wondering if I can get stabilizer to work with cargo / rustc?
If you're not familiar, rustc uses LLVM as a backend.
Looks like a very useful tool.

Thank you.

Trying ton run stabilizer in a Docker environment

Hi,

I've tried to run stabilizer in a container to be able to use it as-is in a deprecated environment (llvm 3.1) for small files. However, it doesn't build, and my cmake knowledge is very limited. I'll dig more into that later, but if you have any pointer, I'd be thankful!

FROM alpine:3.9

RUN apk add --no-cache git cmake build-base python \
	&& rm -rf /tmp/* /var/cache/apk/*
RUN git clone --depth 1 --branch llvmorg-3.1.0 https://github.com/llvm/llvm-project.git
RUN cd llvm-project \
	&& mkdir build \
	&& cd build \
	&& cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm \
	&& make

RUN git clone git://github.com/ccurtsinger/stabilizer.git stabilizer
RUN cd stabilizer && make

Currently the bug seems to be that I need to specify another std version to CMAKE, yet I've tried many way of doing so without success. The cmake command works, and the make command fails at:

[  5%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp: In static member function 'static void* llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(const char*)':
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:158:42: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
    if (!strcmp(symbolName, #SYM)) return &SYM
                                          ^
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:165:5: note: in expansion of macro 'EXPLICIT_SYMBOL'
     EXPLICIT_SYMBOL(stderr);
     ^~~~~~~~~~~~~~~
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:158:42: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
    if (!strcmp(symbolName, #SYM)) return &SYM
                                          ^
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:166:5: note: in expansion of macro 'EXPLICIT_SYMBOL'
     EXPLICIT_SYMBOL(stdout);
     ^~~~~~~~~~~~~~~
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:158:42: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
    if (!strcmp(symbolName, #SYM)) return &SYM
                                          ^
/llvm-project/llvm/lib/Support/DynamicLibrary.cpp:167:5: note: in expansion of macro 'EXPLICIT_SYMBOL'
     EXPLICIT_SYMBOL(stdin);
     ^~~~~~~~~~~~~~~
make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/build.make:830: lib/Support/CMakeFiles/LLVMSupport.dir/DynamicLibrary.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:91: lib/Support/CMakeFiles/LLVMSupport.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

Ulysse

Effects on __attribute__((aligned(64)))

Hi,

It is awesome to find such an interesting paper/project for rigorous performance evaluation.

I have one question regarding to the randomization effect.

If programmer manually specifies some parts of memory layout of the program, like cache alignment for global struct, will stabilizer preserve the information set by the programmer? Does heap/code/stack randomization respect the setting?

Best

No movement, so now?

Hey @ccurtsinger,

Just listened to the presentation of Emery.

Now I would love to use it. Using it would make much more sence and reduce variance cause in many cases. (currently measuring tests with cargo bench, so not that great). Now yes, I read the readme, it says that the project isn't maintained. May I ask why?

Is there a plan/movement going for something new? did a miss an alternative? Would really love to see that thing fly and sure, if theres something to do or helpout I'm in.

Cheers ๐Ÿป

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.