elimina ng read barriers through procras na on and
play

Elimina'ng Read Barriers through Procras'na'on and - PowerPoint PPT Presentation

Elimina'ng Read Barriers through Procras'na'on and Cleanliness KC Sivaramakrishnan Lukasz Ziarek Suresh Jagannathan Big Picture Lightweight user-level threads


  1. Elimina'ng ¡Read ¡Barriers ¡through ¡ Procras'na'on ¡and ¡Cleanliness ¡ KC ¡Sivaramakrishnan ¡ Lukasz ¡Ziarek ¡ Suresh ¡Jagannathan ¡

  2. Big ¡Picture ¡ Lightweight ¡user-­‑level ¡threads ¡ Lots ¡of ¡ t1 ¡ t2 ¡ tn ¡ concurrency! ¡ Scheduler ¡1 ¡ Core ¡1 ¡ Core ¡2 ¡ Core ¡n ¡ Heap ¡ 2 ¡

  3. Big ¡Picture ¡ Big ¡Picture ¡ Expendable ¡ resource? ¡ Lots ¡of ¡ t1 ¡ t2 ¡ tn ¡ concurrency! ¡ Scheduler ¡1 ¡ Heap ¡ 3 ¡ 3 ¡

  4. Big ¡Picture ¡ Big ¡Picture ¡ Exploit ¡program ¡concurrency ¡ ¡ to ¡ ¡ eliminate ¡read ¡barriers ¡from ¡thread-­‑local ¡collectors ¡ Expendable ¡ resource? ¡ Lots ¡of ¡ t2 ¡ tn ¡ concurrency! ¡ Scheduler ¡1 ¡ t1 ¡ Alleviate ¡MM ¡ cost? ¡ Heap ¡ GC ¡OperaDon ¡ 4 ¡ 4 ¡

  5. MulDMLton ¡ • Goals ¡ – Safety, ¡Scalability, ¡ready ¡for ¡future ¡manycore ¡processors ¡ • Parallel ¡extension ¡of ¡MLton ¡– ¡a ¡whole-­‑program, ¡ opDmizing ¡SML ¡compiler ¡ • Parallel ¡extension ¡of ¡Concurrent ¡ML ¡ – Lots ¡of ¡Concurrency! ¡ – Interact ¡by ¡sending ¡messages ¡over ¡first-­‑class ¡channels ¡ send ¡(c, ¡v) ¡ C ¡ v ¡ ß ¡recv ¡(c) ¡ 5 ¡

  6. MulDMLton ¡GC: ¡ConsideraDons ¡ • Standard ¡ML ¡– ¡funcDonal ¡PL ¡with ¡side-­‑effects ¡ – Most ¡objects ¡are ¡small ¡and ¡ephemeral ¡ • Independent ¡generaDonal ¡GC ¡ – # ¡MutaDons ¡<< ¡# ¡Reads ¡ • Keep ¡cost ¡of ¡reads ¡to ¡be ¡low ¡ • Minimize ¡NUMA ¡effects ¡ • Run ¡on ¡non-­‑cache ¡coherent ¡HW ¡ ¡ 6 ¡

  7. MulDMLton ¡GC: ¡Design ¡ Thread-­‑local ¡GC ¡ Shared ¡Heap ¡ Local ¡Heap ¡ Local ¡Heap ¡ Local ¡Heap ¡ Local ¡Heap ¡ Core ¡ Core ¡ Core ¡ Core ¡ • NUMA ¡Awareness ¡ • Circumvent ¡cache-­‑coherence ¡issues ¡ 7 ¡

  8. Invariant ¡PreservaDon ¡ • Read ¡and ¡write ¡barriers ¡for ¡preserving ¡ invariants ¡ TransiDve ¡ closure ¡of ¡x ¡ ExporDng ¡ writes ¡ Shared ¡Heap ¡ Shared ¡Heap ¡ Target ¡ r ¡ r ¡ x ¡ r ¡:= ¡x ¡ x ¡ Mutator ¡ FWD ¡ Source ¡ needs ¡read ¡ Local ¡Heap ¡ Local ¡Heap ¡ barriers! ¡ 8 ¡

  9. Challenge ¡ • Object ¡reads ¡are ¡pervasive ¡ – RB ¡overhead ¡ ∝ ¡cost ¡(RB) ¡* ¡frequency ¡(RB) ¡ • Read ¡barrier ¡opDmizaDon ¡ – Stacks ¡and ¡Registers ¡never ¡point ¡to ¡forwarded ¡objects ¡ Mean ¡Overhead ¡ �� ��� -­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡ Read ¡barrier ¡overhead ¡(%) ¡ ��� �� 20.1 ¡% ¡ ���� 15.3 ¡% ¡ �� 21.3 ¡% ¡ ������������ �� �� �� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � 9 ¡

  10. Mutator ¡and ¡Forwarded ¡Objects ¡ # ¡Encountered ¡ forwarded ¡objects ¡ < ¡ 0.00001 ¡ # ¡RB ¡invocaDons ¡ Eliminate ¡read ¡barriers ¡altogether ¡ 10 ¡

  11. RB ¡EliminaDon ¡ • Visibility ¡Invariant ¡ – Mutator ¡does ¡not ¡encounter ¡forwarded ¡objects ¡ • ObservaDon ¡ – No ¡forwarded ¡objects ¡created ¡ ⇒ ¡visibility ¡ invariant ¡ ⇒ ¡No ¡read ¡barriers ¡ • Exploit ¡concurrency ¡ à à ¡Procras(na(on! ¡ ¡ 11 ¡

  12. ProcrasDnaDon ¡ T1 ¡ T2 ¡ Shared ¡Heap ¡ r1 ¡ r2 ¡ à ¡r1 ¡:= ¡x1 ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡:= ¡x2 ¡ x1 ¡ x2 ¡ Local ¡Heap ¡ à ¡T ¡is ¡ running ¡ T ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 12 ¡

  13. ProcrasDnaDon ¡ T1 ¡ T2 ¡ Shared ¡Heap ¡ r1 ¡ r2 ¡ r1 ¡:= ¡x1 ¡ ¡ à ¡r2 ¡:= ¡x2 ¡ Control ¡ switches ¡ to ¡T2 ¡ x1 ¡ x2 ¡ Local ¡Heap ¡ à ¡T ¡is ¡ running ¡ T ¡ Delayed ¡write ¡list ¡ à ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 13 ¡

  14. ProcrasDnaDon ¡ T1 ¡ T2 ¡ Shared ¡Heap ¡ r1 ¡ r2 ¡ r1 ¡:= ¡x1 ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡:= ¡x2 ¡ x1 ¡ x2 ¡ Local ¡Heap ¡ à ¡T ¡is ¡ running ¡ T ¡ Delayed ¡write ¡list ¡ à ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 14 ¡

  15. ProcrasDnaDon ¡ T1 ¡ T2 ¡ Shared ¡Heap ¡ r1 ¡ x1 ¡ r2 ¡ x2 ¡ r1 ¡:= ¡x1 ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡:= ¡x2 ¡ FWD ¡ FWD ¡ Local ¡Heap ¡ à ¡T ¡is ¡ running ¡ T ¡ Delayed ¡write ¡list ¡ à ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 15 ¡

  16. ProcrasDnaDon ¡ T1 ¡ T2 ¡ Shared ¡Heap ¡ r1 ¡ x1 ¡ r2 ¡ x2 ¡ à ¡r1 ¡:= ¡x1 ¡ ¡ ¡ ¡ ¡ ¡ ¡r2 ¡:= ¡x2 ¡ Force ¡local ¡ GC ¡ Local ¡Heap ¡ à ¡T ¡is ¡ running ¡ T ¡ Delayed ¡write ¡list ¡ à ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 16 ¡

  17. Correctness ¡ • Does ¡ProcrasDnaDon ¡introduce ¡deadlocks? ¡ – Threads ¡can ¡be ¡procrasDnated ¡while ¡holding ¡a ¡lock! ¡ à ¡T ¡is ¡ running ¡ T ¡ ¡ T1 ¡ T2 ¡ T2 ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ 17 ¡

  18. Correctness ¡ • Does ¡ProcrasDnaDon ¡introduce ¡deadlocks? ¡ – Threads ¡can ¡be ¡procrasDnated ¡while ¡holding ¡a ¡lock! ¡ à ¡T ¡is ¡ running ¡ T ¡ ¡ T1 ¡ T2 ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ • Is ¡ProcrasDnaDon ¡safe? ¡ – Yes. ¡Forcing ¡a ¡local ¡GC ¡unblocks ¡the ¡threads. ¡ – No ¡deadlocks ¡or ¡livelocks! ¡ 18 ¡

  19. Correctness ¡ • Does ¡ProcrasDnaDon ¡introduce ¡deadlocks? ¡ – Threads ¡can ¡be ¡procrasDnated ¡while ¡holding ¡a ¡lock! ¡ à ¡T ¡is ¡ running ¡ T ¡ ¡ T1 ¡ T2 ¡ à ¡T ¡is ¡ suspended ¡ T ¡ à ¡T ¡is ¡ blocked ¡ T ¡ • Is ¡ProcrasDnaDon ¡safe? ¡ – Yes. ¡Forcing ¡a ¡local ¡GC ¡unblocks ¡the ¡threads. ¡ – No ¡deadlocks ¡or ¡livelocks! ¡ 19 ¡

  20. Is ¡ProcrasDnaDon ¡alone ¡enough? ¡ • Efficacy ¡(ProcrasDnaDon) ¡ ∝ ¡# ¡Available ¡runnable ¡ threads ¡ ¡ M ¡ Serial ¡(low ¡thread ¡availability) ¡ F ¡ W 1 ¡ W 1 ¡ W 1 ¡ Concurrent ¡(high ¡thread ¡availability) ¡ J ¡ • With ¡ProcrasDnaDon, ¡ half ¡of ¡local ¡major ¡GCs ¡were ¡ forced ¡ Eager ¡exporDng ¡writes ¡while ¡preserving ¡ visibility ¡invariant ¡ 20 ¡

  21. Cleanliness ¡ • A ¡clean ¡object ¡closure ¡can ¡be ¡liped ¡to ¡the ¡ shared ¡heap ¡without ¡breaking ¡the ¡visibility ¡ invariant ¡ r ¡:= ¡x ¡ inLocalHeap ¡(x) ¡ && ¡ inSharedHeap ¡(r) ¡ isClean ¡(x) ¡ Eager ¡write ¡(no ¡ProcrasDnaDon) ¡ 21 ¡

  22. Cleanliness: ¡IntuiDon ¡ Shared ¡Heap ¡ lip ¡(x) ¡to ¡shared ¡ ¡ heap ¡ x ¡ Local ¡Heap ¡ 22 ¡

  23. Cleanliness: ¡IntuiDon ¡ Shared ¡Heap ¡ x ¡ find ¡all ¡references ¡ ¡ to ¡FWD ¡ FWD ¡ Local ¡Heap ¡ 23 ¡

  24. Cleanliness: ¡IntuiDon ¡ Shared ¡Heap ¡ x ¡ Need ¡to ¡scan ¡the ¡ ¡ enDre ¡local ¡heap ¡ Local ¡Heap ¡ 24 ¡

  25. Cleanliness: ¡Simpler ¡quesDon ¡ Shared ¡Heap ¡ x ¡ Do ¡all ¡references ¡ ¡ originate ¡from ¡ ¡ heap ¡region ¡ h? ¡ FWD ¡ h ¡ Local ¡Heap ¡ sizeof ¡(h) ¡<< ¡sizeof ¡(local ¡heap) ¡ 25 ¡

  26. Cleanliness: ¡Simpler ¡quesDon ¡ Shared ¡Heap ¡ x ¡ Only ¡scan ¡the ¡ heap ¡region ¡ h. ¡ Heap ¡ session! ¡ h ¡ Local ¡Heap ¡ sizeof ¡(h) ¡<< ¡sizeof ¡(local ¡heap) ¡ 26 ¡

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