ad hoc synchroniza on considered harmful
play

Ad Hoc Synchroniza/on Considered Harmful Weiwei Xiong, - PowerPoint PPT Presentation

Ad Hoc Synchroniza/on Considered Harmful Weiwei Xiong, Soyoen Park, Jiaqi Zhang, Yuanyuan Zhou and Zhiqiang Ma UC San Diego University of


  1. Ad ¡Hoc ¡Synchroniza/on ¡ Considered ¡Harmful ¡ Weiwei ¡Xiong, ¡Soyoen ¡Park, ¡Jiaqi ¡Zhang, ¡ ¡ Yuanyuan ¡Zhou ¡and ¡Zhiqiang ¡Ma ¡ UC ¡San ¡Diego ¡ ¡ ¡ ¡University ¡of ¡Illinois ¡ ¡ ¡ ¡Intel ¡ ¡

  2. Synchroniza/on ¡is ¡Important ¡ • Concurrent ¡programs ¡are ¡pervasive ¡ • Synchroniza/on ¡in ¡programs ¡ – Ensure ¡correctness ¡of ¡execu/on ¡ – Mutual ¡exclusion ¡ – Condi/onal ¡wait ¡ 10/13/10 ¡ 2 ¡

  3. Common ¡Synchroniza/on ¡Primi/ves ¡ where ¡is ¡ handler ¡handle_slave_sql() ¡ ¡ the ¡sync? ¡ { ¡ ¡ ¡ ¡ ¡ ¡ pthread_mutex_lock(&thread_count); ¡ ¡ ¡ ¡ ¡threads.append(thd); ¡ ¡ ¡pthread_mutex_unlock(&thread_count); ¡ } ¡ /* ¡MySQL ¡*/ ¡ pthread ¡lock ¡ apr_status_t ¡apr_reslist_acquire() ¡ ¡ { ¡ ¡ apr_thread_mutex_lock(reslist-­‑>lock); ¡ ¡ ¡ ¡ ¡res ¡= ¡pop_resource(reslist); ¡ apr_thread_mutex_unlock(reslist-­‑>lock); ¡ ¡ } ¡ /* ¡Apache ¡*/ ¡ customized ¡lock ¡ 3 ¡ 10/13/10 ¡

  4. Common ¡Synchroniza/on ¡Primi/ves ¡ where ¡is ¡ handler ¡handle_slave_sql() ¡ ¡ the ¡sync? ¡ { ¡ ¡ ¡ ¡ ¡ ¡ pthread_mutex_lock(&thread_count); ¡ ¡ ¡ ¡ ¡threads.append(thd); ¡ ¡ ¡pthread_mutex_unlock(&thread_count); ¡ } ¡ /* ¡MySQL ¡*/ ¡ pthread ¡lock ¡ apr_status_t ¡apr_reslist_acquire() ¡ ¡ { ¡ ¡ apr_thread_mutex_lock(reslist-­‑>lock); ¡ ¡ ¡ ¡ ¡res ¡= ¡pop_resource(reslist); ¡ apr_thread_mutex_unlock(reslist-­‑>lock); ¡ ¡ } ¡ /* ¡Apache ¡*/ ¡ customized ¡lock ¡ 4 ¡ 10/13/10 ¡

  5. Hard-­‑to-­‑recognize ¡Synchroniza/on ¡ Sync ¡ Ad ¡hoc ¡ variable ¡ for ¡(deleted=0; ¡;) ¡{ ¡ sync ¡ ¡ ¡ ¡ ¡… ¡ ¡ ¡ ¡ ¡if ¡(dbmfp-­‑>ref ¡== ¡1) ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(F_ISSET(dbmfp, ¡OPEN_CALLED)) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡TAILQ_REMOVE(&dbmp-­‑>dbmfq, ¡...); ¡ Is ¡it ¡doing ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡deleted ¡= ¡1; ¡ sync? ¡ ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡ ¡ ¡ ¡… ¡ ¡ ¡ ¡ ¡ ¡if ¡(deleted) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡break; ¡ ¡ ¡ ¡ ¡ ¡__os_sleep(dbenv, ¡1, ¡0); ¡ } ¡ /* ¡OpenLDAP ¡*/ ¡ 10/13/10 ¡ 5 ¡

  6. Hard-­‑to-­‑recognize ¡Synchroniza/on ¡ Sync ¡ Ad ¡hoc ¡ variable ¡ for ¡(deleted=0; ¡;) ¡{ ¡ sync ¡ ¡ ¡ ¡ ¡… ¡ ¡ ¡ ¡ ¡if ¡(dbmfp-­‑>ref ¡== ¡1) ¡{ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡if ¡(F_ISSET(dbmfp, ¡OPEN_CALLED)) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡TAILQ_REMOVE(&dbmp-­‑>dbmfq, ¡...); ¡ Is ¡it ¡doing ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡deleted ¡= ¡1; ¡ sync? ¡ ¡ ¡ ¡ ¡ ¡} ¡ ¡ ¡ ¡ ¡ ¡… ¡ ¡ ¡ ¡ ¡ ¡if ¡(deleted) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡break; ¡ ¡ ¡ ¡ ¡ ¡__os_sleep(dbenv, ¡1, ¡0); ¡ } ¡ /* ¡OpenLDAP ¡*/ ¡ 10/13/10 ¡ 6 ¡

  7. Hard-­‑to-­‑recognize ¡Synchroniza/on ¡ Sync? ¡ loop: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡... ¡ ¡ ¡if(shutdown_state ¡ > ¡0) ¡ background_loop: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡background_loop; ¡ ¡ ¡ ¡ ¡/* ¡background ¡opera/ons ¡*/ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡... ¡ ¡ ¡ ¡ ¡… ¡ ¡ if(shutdown_state ¡ == ¡EXIT) ¡ ¡ ¡if(new_ac/vity_counter ¡ > ¡0) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡os_thread_exit(NULL) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡loop; ¡ ¡ ¡ ¡ ¡ ¡goto ¡loop; ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡background_loop; ¡ /* ¡MySQL ¡*/ ¡ 10/13/10 ¡ 7 ¡

  8. Hard-­‑to-­‑recognize ¡Synchroniza/on ¡ Sync? ¡ loop: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡... ¡ ¡ ¡if(shutdown_state ¡ > ¡0) ¡ background_loop: ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡background_loop; ¡ ¡ ¡ ¡ ¡/* ¡background ¡opera/ons ¡*/ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡... ¡ ¡ ¡ ¡ ¡… ¡ ¡ if(shutdown_state ¡ == ¡EXIT) ¡ ¡ ¡if(new_ac/vity_counter ¡ > ¡0) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡os_thread_exit(NULL) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡loop; ¡ ¡ ¡ ¡ ¡ ¡goto ¡loop; ¡ ¡ ¡ ¡ ¡else ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡goto ¡background_loop; ¡ /* ¡MySQL ¡*/ ¡ 10/13/10 ¡ 8 ¡

  9. What ¡are ¡the ¡Consequences? ¡ • ¡Introducing ¡bugs ¡or ¡performance ¡issues ¡ – up ¡to ¡ 67% ¡of ¡ad ¡hoc ¡syncs ¡introduced ¡bugs ¡ • Making ¡program ¡analysis ¡more ¡difficult ¡ – hard-­‑to-­‑detect ¡deadlocks ¡ – introducing ¡false ¡posi/ves ¡to ¡data ¡race ¡checker ¡ – confusions ¡to ¡sync ¡performance ¡profiling ¡ • Problema/c ¡interac/ons ¡with ¡compiler ¡and ¡ memory ¡consistency ¡model ¡ ¡ 10/13/10 ¡ 9 ¡

  10. What ¡are ¡the ¡Consequences? ¡ More ¡examples ¡ • ¡Introducing ¡bugs ¡or ¡performance ¡issues ¡ later ¡ – up ¡to ¡ 67% ¡of ¡ad ¡hoc ¡syncs ¡introduced ¡bugs ¡ • Making ¡program ¡analysis ¡more ¡difficult ¡ – hard-­‑to-­‑detect ¡deadlocks ¡ – introducing ¡false ¡posi/ves ¡to ¡data ¡race ¡checker ¡ – confusions ¡to ¡sync ¡performance ¡profiling ¡ • Problema/c ¡interac/ons ¡with ¡compiler ¡and ¡ memory ¡consistency ¡model ¡ ¡ 10/13/10 ¡ 10 ¡

  11. Our ¡Contribu/on ¡ • Quan/ta/ve ¡evidence ¡to ¡show ¡ad ¡hoc ¡syncs ¡ are ¡harmful ¡ • SyncFinder: ¡a ¡tool ¡that ¡automa/cally ¡iden/fies ¡ and ¡annotates ¡ad ¡hoc ¡syncs ¡ – helps ¡to ¡detect ¡new ¡deadlocks ¡and ¡bad ¡prac/ces ¡ – helps ¡to ¡reduce ¡false ¡posi/ve ¡of ¡race ¡detectors ¡ 10/13/10 ¡ 11 ¡

  12. Outline ¡ Mo/va/on ¡ 1 ¡ Ad ¡Hoc ¡Sync ¡Study ¡ 2 ¡ 3 ¡ SyncFinder: ¡Auto-­‑Annota/on ¡ 3 ¡ Evalua/on ¡Results ¡ 3 ¡ 4 ¡ Conclusions ¡ 5 ¡ 10/13/10 ¡ 12 ¡ 12 ¡

  13. Data ¡Set ¡and ¡Methodology ¡ • Different ¡types ¡of ¡ Apps. ¡ Descrip3on ¡ Apache ¡ Web ¡server ¡ concurrent ¡programs ¡ Server ¡ MySQL ¡ Database ¡server ¡ – servers ¡ OpenLDAP ¡ LDAP ¡server ¡ Cherokee ¡ Web ¡server ¡ – desktop ¡apps ¡ Desktop ¡ Mozilla ¡JS ¡ JS ¡engine ¡ – scien/fic ¡programs ¡ PBZip2 ¡ Parallel ¡bzip2 ¡ • Manually ¡examine ¡ Transmission ¡ BitTorrent ¡client ¡ Radiosity ¡ SPLASH-­‑2 ¡ ¡ ¡ ¡ ¡every ¡program ¡ Scien/fic ¡ Barnes ¡ SPLASH-­‑2 ¡ Water ¡ SPLASH-­‑2 ¡ • Two ¡persons ¡each ¡ OCean ¡ SPLASH-­‑2 ¡ spent ¡3 ¡months ¡ FFT ¡ SPLASH-­‑2 ¡ 10/13/10 ¡ 13 ¡

  14. Every ¡Studied ¡Program ¡Has ¡Ad ¡Hoc ¡Syncs ¡ Apps. ¡ Descrip3on ¡ Ad ¡hoc ¡sync ¡loops ¡ Apache ¡ Web ¡server ¡ 33 ¡ Server ¡ MySQL ¡ Database ¡server ¡ 83 ¡ OpenLDAP ¡ LDAP ¡server ¡ 15 ¡ Cherokee ¡ Web ¡server ¡ 6 ¡ Desktop ¡ Mozilla ¡JS ¡ JS ¡engine ¡ 17 ¡ PBZip2 ¡ Parallel ¡bzip2 ¡ 7 ¡ Transmission ¡ BitTorrent ¡client ¡ 13 ¡ Radiosity ¡ SPLASH-­‑2 ¡ 12 ¡ Scien/fic ¡ Barnes ¡ SPLASH-­‑2 ¡ 7 ¡ Water ¡ SPLASH-­‑2 ¡ 9 ¡ Ocean ¡ SPLASH-­‑2 ¡ 20 ¡ FFT ¡ SPLASH-­‑2 ¡ 7 ¡ 10/13/10 ¡ 14 ¡

  15. Ad ¡Hoc ¡Syncs ¡are ¡Error-­‑prone ¡ • Percentage ¡of ¡buggy ¡ad ¡hoc ¡syncs ¡ Apps. ¡ # ¡ad ¡hoc ¡sync ¡ # ¡buggy ¡sync ¡ Apache ¡ 33 ¡ 7 ¡(22%) ¡ OpenLDAP ¡ 15 ¡ 10 ¡(67%) ¡ Cherokee ¡ 6 ¡ 3 ¡(50%) ¡ Mozilla ¡JS ¡ 17 ¡ 5 ¡(30%) ¡ Transmission ¡ 13 ¡ 8 ¡(62%) ¡ 10/13/10 ¡ 15 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend