christopher j. rossbach, owen s. hofmann, emmett witchel ut austin

34
Is Transactional Programming Actually Easier? Christopher J. Rossbach, Owen S. Hofmann, Emmett Witchel UT Austin

Upload: alvin-holland

Post on 18-Jan-2016

214 views

Category:

Documents


1 download

TRANSCRIPT

Is Transactional Programming Actually Easier?

Is Transactional Programming Actually Easier?Christopher J. Rossbach, Owen S. Hofmann, Emmett WitchelUT AustinTM Research MantraWe need better parallel programming toolsCMP ubiquity(Concurrent programming == programming w/locks)Locks are difficultTransactional memory is promising:No deadlock, livelock, etc.Optimistic likely more scalable Therefore:Transactional Memory is easier than locksAll TM papers should be publishedIs TM really easier than locks?Programmers still must write critical sectionsRealizable TM will have new issuesHTM overflowSTM performanceTrading one set of difficult issues for another?Ease-of-use is a critical motivator for TM research

Its important to know the answer to this question

How can we answer this question?Step 2: have them write the same program with TM and locksStep 4: Evaluate their codeStep 3: Ask them how it wentStep 1: Get some programmers(preferrably inexperienced)This talk: TM vs. locks user study UT Austin OS undergrads same program using locks (fine/coarse) monitors transactional memoryOutlineMotivationProgramming ProblemUser Study MethodologyResultsConclusionThe programming problemsync-gallery: a rogues gallery of synchronizationMetaphor shooting gallery (welcome to UT)Rogues shoot paint-balls in lanesEach rogue has a unique colorShooting target takes rogues colorCleaners change targets back to whiteRogues/cleaners must synchronize maintain 4 invariantsSync-gallery invariantsOnly one shooter per lane (Uh, hello, dangerous?!)Dont shoot colored lanes (no fun)Clean only when all lanes shot (be lazy)Only one cleaner threadTask: single-lane rogueRogue() {while(true) { Lane lane = randomLane(); if(lane.getColor() == WHITE) lane.shoot(); if(allLanesShot()) clean(); }}Invariants: One shooter per lane Dont shoot colored lanes One cleaner thread Clean only when all lanes shotglobalLock.lock()globalLock.unlock()lane.lock()lane.unlock()lockAllLanes() ???beginTransaction()endTransaction()Coarse-grain lockingFine-grain lockingTransactionsVariation: two-lane rogueRogue() {while(true) { Lane a = randomLane(); Lane b = randomLane(); if(a.getColor() == WHITE && b.getColor() == WHITE) { a.shoot(); b.shoot(); } if(allLanesShot()) clean(); }}Invariants: One shooter per lane Dont shoot colored lanes One cleaner thread Clean only when all lanes shotglobalLock.lock()globalLock.unlock()Coarse-grain lockingFine-grain lockinga.lock();b.lock();Requires lock-ordering!lockAllLanes() ???Variation 2: cleaner roguesRogue() {while(true) Lane lane = randomLane(); if(lane.getColor() == WHITE) lane.shoot();} }Cleaner() { while(true) { if(allLanesShot())clean(); } }Invariants: One shooter per lane Dont shoot colored lanes One cleaner thread Clean only when all lanes shotif(allLanesShot()) lanesFull.signal();while(!allLanesShot() lanesFull.await()(still need other locks!)Sync-gallery in actionSynchronization Cross-productCoarseFineTMSingle-laneCoarseFineTMTwo-laneCoarse2Fine2TM2CleanerCoarseCleanerFineCleanerTMCleaner9 different Rogue implementationsFind a way to emphasize what is interestingCIRCLE THE ITEMS Im talking about12OutlineMotivationProgramming ProblemUser Study MethodologyTM SupportSurvey detailsResultsConclusionTM SupportYear 1: DSTM2 [Herlihy 06]Year 2: JDASTM [Ramadan 09]Library, not language supportNo atomic blocksDifferent concrete syntaxRead/write barriers

DSTM2 concrete syntaxCallable c = new Callable { public Void call() {GalleryLane l = randomLane(); if(l.color() == WHITE)) l.shoot(myColor);return null; }}Thread.doIt(c);JDASTM concrete syntaxTransaction tx = new Transaction(id);boolean done = false;while(!done) { try { tx.BeginTransaction(); GalleryLane l = randomLane(); if(l.color() == WHITE)) l.TM_shoot(myColor); done = tx.CommitTransaction(); } catch(AbortException e) { tx.AbortTransaction(); done = false; }}Undergrads: the ideal TM user-baseTM added to undergrad OS curriculumSurvey studentsAnalyze programming mistakesTMs benchmark for successEasier to use than fine grain locks or conditions

REWORK17SurveyMeasure previous exposureUsed locks/TM before, etcTrack design/code/debug timeRank primitives according along several axes:Ease of reasoning aboutEase of coding/debuggingEase of understanding others code

http://www.cs.utexas.edu/~witchel/tx/sync-gallery-survey.html

Data collectionSurveyed 4 sections of OS students 2 sections x 2 semesters147 students1323 rogue implementationsDefect AnalysisExamined year 2 (604 implementations)Automated testing using condorOutlineMotivationProgramming ProblemUser Study MethodologyResultsConclusionDevelopment EfforthoursCIRCLE the data points21Development EfforthoursImplementation order:Coarserand&2?FineTMCIRCLE the data points22Development EfforthoursCIRCLE the data points23Development EfforthoursCIRCLE the data points24Qualitative preferencesRanking1234Coarse62%30%1%4%Fine6%21%45%40%TM26%32%19%21%Conditions6%21%29%40%Ranking1234Coarse81%14%1%3%Fine1%38%30%29%TM16%32%30%21%Conditions4%14%40%40%Best SyntaxEasiest to Think about(Year 2)Qualitative preferencesRanking1234Coarse62%30%1%4%Fine6%21%45%40%TM26%32%19%21%Conditions6%21%29%40%Ranking1234Coarse81%14%1%3%Fine1%38%30%29%TM16%32%30%21%Conditions4%14%40%40%Best SyntaxEasiest to Think about(Year 2)Coarse > (TM|Coarse) > Fine > (Fine|Conditions)Coarse > (Fine|TM) > ConditionsBest SyntaxEasiest to Think aboutAnalyzing Programming ErrorsError taxonomy: 8 classesLock-ord: lock orderingLock-cond: checking condition outside critsecLock-forgot: forgotten SynchronizationCv-exotic: exotic condition variable usageCv-use: condition variable errorsTM-exotic: TM primitive misuseTM-forgot: Forgotten TM synchronizationTM-order: Ordering in TM

Error Rates by Defect TypeOverall Error RatesProportion of errorsOutlineMotivationProgramming ProblemUser Study MethodologyResultsConclusionConclusionGeneral qualitative ranking:Coarse-grain locks (easiest)TMFine-grain locks/conditions (hardest)Error rates overwhelmingly in favor of TMTM may actually be easierP-values

Development EfforthoursSynchronization PotpourriRogueSynchronizationR/C ThreadsAdditional RequirementsCoarseGlobal locknot distinctCoarse2Global locknot distinctShoot at 2 lanesCoarseCleanerGlobal lock, conditionsDistinctwait/notifyFinePer-lane locksnot distinctFine2Per-lane locksnot distinctShoot at 2 lanesFineCleanerPer-lane locks, conditionsDistinctwait/notifyTMTMnot distinctTM2TMnot distinctShoot at 2 lanesTMCleanerTMdistinctFind a way to emphasize what is interestingCIRCLE THE ITEMS Im talking about34