on the cost of type tag soundness
play

ON THE COST OF TYPE-TAG SOUNDNESS Ben Greenman Zeina Migeed ON - PowerPoint PPT Presentation

ON THE COST OF TYPE-TAG SOUNDNESS Ben Greenman Zeina Migeed ON THE COST OF TYPE-TAG SOUNDNESS 1. Tag soundness 2. Performance cost of soundness 3. Evaluation method 4. Conclusions TYPE-TAG SOUNDNESS Type Soundness e : If


  1. ON THE COST OF TYPE-TAG SOUNDNESS Ben Greenman Zeina Migeed

  2. ON THE COST OF TYPE-TAG SOUNDNESS 1. Tag soundness 2. Performance cost of soundness 3. Evaluation method 4. Conclusions

  3. TYPE-TAG SOUNDNESS

  4. Type Soundness ⊢ e : τ If then either: * • and e v ⊢ v : τ • diverges e * • (division by zero, etc.) e Error No undefined behavior Type-based reasoning

  5. Type Soundness ⊢ e : τ If then either: * • and e v ⊢ v : τ • diverges e * • (division by zero, etc.) e Error

  6. Tag Soundness ⊢ e : τ If then either: ⊢ v : ⌊ τ ⌋ * • and e v • diverges e * • (division by zero, etc.) e Error

  7. Tag Soundness ⊢ e : τ If then either: ⌊ τ ⌋ = K ⊢ v : ⌊ τ ⌋ * • and e v ⌊ Int ⌋ = Int • diverges e ⌊ τ × τ ' ⌋ = Pair * • (division by zero, etc.) e Error ⌊ τ → τ ' ⌋ = Fun ...

  8. Tag Soundness ⊢ e : τ If then either: ⌊ τ ⌋ = K ⊢ v : ⌊ τ ⌋ * • and e v ⌊ Int ⌋ = Int • diverges e ⌊ τ × τ ' ⌋ = Pair * • e Error ⌊ τ → τ ' ⌋ = Fun No undefined behavior ... Tag-based reasoning

  9. Types vs. Tags * ⊢ e : Int × Int e v v If and then might be: Type Soundness Tag Soundness ("A", 0) (0, 0) (0, 0) (3, 2) (3, 2) (-7, 9) (-7, 9) (0, (1, 2))

  10. Types vs. Tags * ⊢ e : Int × Int e v v If and then might be: Type Soundness Tag Soundness ("A", 0) (0, 0) (0, 0) (3, 2) (3, 2) (-7, 9) (-7, 9) (0, (1, 2))

  11. * * fast slow

  12. * * fast slow Type Sound? Tag Sound?

  13. PERFORMANCE COST OF SOUNDNESS

  14. Problem: Safe Interaction τ τ τ e τ e e e ?

  15. Gradual Typing τ τ τ e τ e e e λ

  16. User Input τ τ τ * e read() Enter a value: >

  17. Deserialization τ τ τ * e unzip() 0110 1110 1011

  18. Primitive Operations ( δ ) Int Int Int * e v + v E[v,v] ... v'

  19. Unreliable Source τ e τ e λ ? E[•] 0110 1110 Enter a value: > 1011

  20. Option 1: Trust τ τ e v ?

  21. Option 2: Check τ v τ v τ e ... ?

  22. Option 2: Check τ v τ v τ e ... ? COST OF SOUNDNESS

  23. Cost of Types ( ) * slow Int × Int Int × Int Int × Int (6,1) (6,1) (6,1) Int × Int (6,1) ?

  24. Cost of Tags ( ) * fast Int × Int Int × Int (6,1) (6,1) ?

  25. COST OF SOUNDNESS IN RETICULATED

  26. Retic vs. Python τ τ τ e τ e e e

  27. Reticulated def dist(pt : Tuple(Int,Int) ) -> Int : x = pt[0] y = pt[1] return abs(x + y)

  28. Reticulated def dist(pt : Tuple(Int,Int) ) -> Int : x = pt[0] y = pt[1] return abs(x + y) * dist((0, 0)) 0

  29. Reticulated def dist(pt : Tuple(Int,Int) ) -> Int : x = pt[0] y = pt[1] return abs(x + y) * dist("NaN") Expected Tuple

  30. Reticulated def dist(pt : Tuple(Int,Int) ) -> Int : x = pt[0] y = pt[1] return abs(x + y) * dist((0, "NaN")) Expected Int

  31. Evaluation Method

  32. 1. Fully-Typed

  33. 2. Configurations

  34. 3. Measure 11s 7s 9s 2s 5s 24s 9s 14s 5s 21s 9s 6s 9s 8s 4s 5s

  35. What % have at most D = 4, vs. Dx overhead? 11s 7s 9s 2s 5s 24s 9s 14s 5s 21s 9s 6s 9s 8s 4s 5s

  36. What % have at most D = 4, vs. Dx overhead?

  37. Evaluation Method 2 2 or O(2)

  38. EXPERIMENT & RESULTS

  39. Benchmarks DLS 2014 POPL 2017 PEPM 2018 futen call_method espionage http2 call_simple pythonflow slowSHA chaos take5 aespython fannkuch sample_fsm stats go meteor nbody nqueens pidigits pystone spectralnorm

  40. # Typed Components DLS 2014 POPL 2017 PEPM 2018 15 7 12 4 6 12 17 15 16 34 * 1 19 * 79 * 7 8 5 2 5 14 5

  41. Exhaustive Results What % of configurations have at most 4x overhead? 100% 50% 4x

  42. Exhaustive Results What % of configurations have at most Dx overhead? 100% 50% 1x 2x 4x 6x 8x

  43. Exhaustive Results What % of configurations have at most Dx overhead? 100% 50% 1x 2x 4x 6x 8x

  44. Approximate Results What % of configurations have at most 4x overhead, based on R samples of S configurations each? 100% 50% 4x

  45. Approximate Results What % of configurations have at most Dx overhead, based on R samples of S configurations each? 100% 50% 1x 2x 4x 6x 8x

  46. Approximate Results What % of configurations have at most Dx overhead, based on R samples of S configurations each? 100% 50% 1x 2x 4x 6x 8x

  47. 10 samples 
 espionage 4,096 configurations aespython of 340 configurations 100% 100% 50% 50% 1x 1x 2x 4x 6x 8x 2x 4x 6x 8x

  48. Cost of Tag Soundness • Worst-case overhead: under 10x

  49. This is an APPLES to ORANGES comparison! Type Soundness Tag Soundness 1x 1x 1x 1x 2x 4x 1x 1x 1x 1x 1x 5x 5x 3x 1x 2x 27x 2x 29x 2x 3x 32x 3x 10x 34x 2x 5x 3x 43x 7x 47x 6x 233x 292x 6x 7x 139x 7x 1527x 8x

  50. Cost of Tag Soundness • Worst-case overhead: under 10x • Best-case overhead: 1x -- 4x • adding types never* improves performance • Slowest configuration: fully-typed ∝ • Overhead number of type annotations

  51. Runtime vs. # Types

  52. Runtime vs. # Types

  53. Speedup? • Unsound optimization for • Double-checks method read-only values (tuples) calls

  54. Runtime vs. # Types

  55. Experiment • granularity: functions & class-fields • 10 samples of [10 * (F + C)] configurations • Karst at Indiana University cluster (32GB RAM, 250GB other) • Reticulated, master branch, commit e478343 • Python 3.4.3 • 40 iterations per configuration, report average • 200 values of D on x-axis

  56. POPL 2017

  57. References • Vitousek, Swords, Siek. Big Types in Little Runtime: Open-World Soundness and Collaborative Blame for Gradual Type Systems. POPL 2017 • Takikawa, Feltey, Greenman, New, Vitek, Felleisen. Is Sound Gradual Typing Dead? POPL 2016.

  58. UNUSED SLIDES

  59. ??? ⊢ e' : τ ' ⊢ e : τ

  60. Takikawa Method • granularity • experimental modules, fixed modules • configurations • baseline • performance ratio

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