GithubHelp home page GithubHelp logo

gocc's Introduction

Go Optimistic Concurrency Control (GOCC)

Goal

The goal of this project is to reduce the overhead of mutex lock in Go by replacing it with Hardware Transactional Memory (HTM). It will generate a patch for the given source code with HTM replacement after static analysis on the call graph.

How to get it

go get -u github.com/lollllcat/GOCC/...

How to run

cd $GOPATH/GOCC/tools/gocc.

go run main.go -input <go package> then the source code will be rewritten. optional command line flags:

  1. -synthetic: if you use the second step to generate the synthetic main function, you shold also pass "-synthetic" in to the command above.
  2. -dryrun: this will not actually rewrite the file, instead, it will print out the stats like number of locks can be rewritten.
  3. -profile listOfHotFunction.txt: this will only rewrite the hot function, if you obtain the list from the first step using profiler.
  4. -stats: will dump out the lock info stats. You may need to create "lockcount" and "lockDistribution" folder first.

Example: go run main.go -input ~/gocode/src/github.com/uber-go/tally/ to rewrite Tally.

Feeding profiles

If the profile.out is provided, you can go to profiler/ repo, run go run profiler.go -input nameOfTheProfile to obtain the list of hot functions.

Synthesizing a main for libraries

If the library does not contain a main package and function to test, we can generate a synthetic main function. In order to do that,go to synthesizer/ folder, run go run main.go -input pathToTheLibrary to generate the file. Once created, you can move the file (named as test.go) into the libarary that will be analyzed. Make sure not put in the root directory and CREATE a new subdirectory, otherwise Go may complain the multiple packages... Example:

  1. go run synthesizer/main.go -input ~/gocode/src/github.com/uber-go/tally/
  2. mkdir ~/gocode/src/github.com/uber-go/tally/test/
  3. mv synthesizer/test.go ~/gocode/src/github.com/uber-go/tally/test/
  4. go run main.go -synthetic -input ~/gocode/src/github.com/uber-go/tally/

Internal workings

  1. Obtain the call graph of the given code.
  2. Identify the valid pairs of lock and unlock for safe replacement from the call graph. 2.1 Find lock pairs by iterating thru the ssa form that satisfies the CFG requirements. 2.2 For each pair, analyzing whether its corresponding critical section is safe or not, i.e. there should be no instructions that violate HTM like I/O, sync, and runtime.
  3. Rewrite the identified lock pair candidates with HTM in AST.
  4. Generate patch from modified AST.

Different CFG pattern with their corresponding critical section (CS) that we currently handle:

  1. Lock and unlock in the same basic block (BB), CS is the instructions between them.
  2. Lock and defer unlock in the same BB, CS is the instructions in between plus the ALL reachable BB.
  3. Lock dominates unlock and unlock post-dominates lock, CS is all BBs between the lock BB and unlock BB.
  4. Lock dominates defer unlock and defer unlock post-dominates lock, CS is all BBs between the lock BB and unlock BB, plus ALL reachable BB from defer unlock BB.

gocc's People

Contributors

lollllcat avatar chabbimilind avatar

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.