efficient data race detection
Download
Skip this Video
Download Presentation
Efficient Data-Race Detection

Loading in 2 Seconds...

play fullscreen
1 / 28

Efficient Data-Race Detection - PowerPoint PPT Presentation


  • 98 Views
  • Uploaded on

Efficient Data-Race Detection. Recap. Happens-before based data-race detection Shaz’s guest lecture Vector clock algorithm Lock-set based data-race detection Eraser paper discussion. New Definition of a Data Race. Two instruction conflict if They access the same memory location

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Efficient Data-Race Detection' - mirielle-perrin


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
recap
Efficient Data-Race DetectionRecap
  • Happens-before based data-race detection
    • Shaz’s guest lecture
    • Vector clock algorithm
  • Lock-set based data-race detection
    • Eraser paper discussion
new definition of a data race
Efficient Data-Race DetectionNew Definition of a Data Race
  • Two instruction conflict if
    • They access the same memory location
    • At least one of them is a write
  • A program contains a data race if
    • One can schedule the program on a multiprocessor
    • Such that conflicting instructions execute simultaneously
new definition vs happens before
Efficient Data-Race DetectionNew Definition vs Happens-Before

X = 1

Lock L

X = 2

Unlock L

Lock L

X = 3

Unlock L

new definition vs happens before1
Efficient Data-Race DetectionNew Definition vs Happens-Before

Lock L

X = 1

X = 2

Unlock L

Lock L

X = 3

Unlock L

new definition vs happens before2
Efficient Data-Race DetectionNew Definition vs Happens-Before
  • True or False ?
  • If a program has a data race as per the new definition
  • Then it has a data race as per the happens-before definition
new definition vs happens before3
Efficient Data-Race DetectionNew Definition vs Happens-Before
  • True or False ?
  • If a program has a data race as per the new definition
  • Then it has a happens-before data race
  • If a program has a happens-before data race
  • Then it has a data race as per the new definition
new definition vs lock set
Efficient Data-Race DetectionNew Definition vs Lock Set
  • True or False ?
  • If a program has a data race as per the new definition
  • Then it has a lock-set based data race
  • If a program has a lock-set based data race
  • Then it has a data race as per the new definition
challenges for dynamic data race detection
Efficient Data-Race DetectionChallenges For Dynamic Data Race Detection
  • Dynamically monitor memory accesses
    • Need instrumentation infrastructure
    • Performance overhead
challenges for dynamic data race detection1
Efficient Data-Race DetectionChallenges For Dynamic Data Race Detection
  • Dynamically monitor memory accesses
    • Need instrumentation infrastructure
    • Performance overhead
  • Understand synchronization mechanisms
    • Handle home-grown locks
    • Need to annotate the happens-before relationship
challenges for dynamic data race detection2
Efficient Data-Race DetectionChallenges For Dynamic Data Race Detection
  • Dynamically monitor memory accesses
    • Need instrumentation infrastructure
    • Performance overhead
  • Understand synchronization mechanisms
    • Handle home-grown locks
    • Need to annotate the happens-before relationship
  • Maintain detection meta-data per variable, per synchronization object
    • Manage memory
    • Performance overhead
datacollider osdi 10
Efficient Data-Race DetectionDataCollider [OSDI ‘10]
  • Lightweight
    • < 5% overhead
  • Effective
    • Found data races in all applications we have run
  • Easy to implement
    • The algorithm can be described in ~ 10 lines
design choice 1
Efficient Data-Race DetectionDesign Choice #1
  • Sample memory accesses
    • Detect data races on a small, random sample of memory accesses
design choice 11
Efficient Data-Race DetectionDesign Choice #1
  • Sample memory accesses
    • Detect data races on a small, random sample of memory accesses
  • It is acceptable to miss races
    • Dynamic techniques cannot find all data races anyway
  • A lightweight tool will have more coverage
    • Likely to be run on a lot more tests
  • But data races are ‘rare’ events
    • Need to be careful when sampling
design choice 2
Efficient Data-Race DetectionDesign Choice #2
  • Perturb thread schedules
    • By inserting delays
    • Force the data race to happen, rather than infer from past memory/synchronization accesses
design choice 21
Efficient Data-Race DetectionDesign Choice #2
  • Perturb thread schedules

X = 1

Lock L

X = 2

Unlock L

Lock L

X = 3

Unlock L

design choice 22
Efficient Data-Race DetectionDesign Choice #2
  • Perturb thread schedules

X = 1

Insert

Delay

Lock L

X = 1

X = 2

Unlock L

Lock L

X = 3

Unlock L

the algorithm
Efficient Data-Race DetectionThe Algorithm

At_Every_Memory_Access ( x ) {

if (not sampled) return;

delay for some time;

if another thread performed

a conflicting operation

during the delay

report data race;

}

use data breakpoints for detecting conflicting operations
Efficient Data-Race DetectionUse Data Breakpoints for Detecting Conflicting Operations

At_Every_Memory_Access ( x ) {

if (not sampled) return;

rw = accessIsWrite ? RW : W;

SetDataBreakpoint ( x, rw);

Delay();

ClearDataBreakpoint ( x );

if (breakpoint fired)

ReportDataRace();

}

sampling memory accesses
Efficient Data-Race DetectionSampling Memory Accesses
  • Need to execute the sampling function at every access
    • Performance overhead
  • Need a good sampling algorithm
    • Data races are ‘rare’ events
dynamic sampling
Efficient Data-Race DetectionDynamic Sampling
  • Toss a biased coin at each memory access
  • Sample if coin turns up heads (with small probability)
dynamic sampling1
Efficient Data-Race DetectionDynamic Sampling
  • Toss a biased coin at each memory access
  • Sample if coin turns up heads (with small probability)
  • Hot (frequent) instructions are sampled overwhelmingly more that cold instructions
  • Bugs (data races) are likely to be present on cold instructions
code breakpoint sampling
Efficient Data-Race DetectionCode Breakpoint Sampling
  • Pick a random instruction X
  • Set a code breakpoint at X
      • Overwrite the first byte of X with a ‘0xcc’
  • Sample X when the breakpoint fires and goto Step 1
sampling using code breakpoints
Efficient Data-Race DetectionSampling Using Code Breakpoints
  • Samples instructions independent of their execution frequency
    • Hot and cold instructions are sampled uniformly
sampling using code breakpoints1
Efficient Data-Race DetectionSampling Using Code Breakpoints
  • Samples instructions independent of their execution frequency
    • Hot and code instructions are sampled uniformly
  • Sampling distribution is determined by you (fair_coin_toss)
  • Sampling rate is determined by the program (unfair_coin_toss)

repeat {

t = fair_coin_toss();

while( t != unfair_coin_toss() );

print( t );

}

sampling using code breakpoints2
Efficient Data-Race DetectionSampling Using Code Breakpoints
  • Samples instructions independent of their execution frequency
    • Hot and code instructions are sampled uniformly
  • Sampling distribution is determined by you (fair_coin_toss)
  • Sampling rate is determined by the program (unfair_coin_toss)

Set a breakpoint at location X

repeat {

t = fair_coin_toss();

while( t != unfair_coin_toss() );

print( t );

}

Run the program till it executes X

Sample X

the datacollider algorithm
Efficient Data-Race DetectionThe DataCollider Algorithm

Init:

SetRandomCodeBreakpoints( n );

AtCodeBreakpoint( x ) {

SetDataBreakpoint ( x);

Delay();

if (breakpoint fired)

ReportDataRace();

ClearDataBreakPoint( x );

SetRandomCodeBreakpoints( 1 );

}

datacollider summary
Efficient Data-Race DetectionDataCollider Summary
  • Tunable runtime overhead
    • Tune code breakpoint rate so that we get k samples per second
  • Finds lots of data races in practice
  • The fastest implementation
    • Someone hacked it up during the talk
  • Pruning intended data races is a problem
  • Sampling algorithm improvements?
ad