Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Take Your Time

207 views

Published on

OTP20 officially introduced dirty schedulers. In this talk, we'll cover why they're part of OTP and what function they perform. Using Rust NIFs, we'll compare schedulers and dirty schedulers to illustrate the trade-offs between scheduler types. By the talk's end, it should be apparent why dirty schedulers are part of OTP and how and when you should consider using them.

Published in: Software
  • Be the first to comment

Take Your Time

  1. 1. TAKE YOUR TIME
  2. 2. BEN MARX @bgmarx ARCHITECT
  3. 3. AdoptingElixir_Workshop_2018 25% off til 9/15
  4. 4. HOW SCHEDULERS WORK
  5. 5. NIFS BRIEFLY
  6. 6. DIRTY SCHEDULERS
  7. 7. RUST
  8. 8. NIFS OR NAY?
  9. 9. SCHEDULERS
  10. 10. PREEMPTIVE
  11. 11. RUN QUEUE
  12. 12. MIGRATION LOGIC
  13. 13. RUN QUEUE 2SCHEDULER 2 RUN QUEUE NSCHEDULER N RUN QUEUE 1SCHEDULER1 MIGRATION LOGIC
  14. 14. FINELY TUNED
  15. 15. 1MS
  16. 16. SCHEDULER COLLAPSE
  17. 17. SCHEDULERS
  18. 18. NIFS
  19. 19. NATIVELY IMPLEMENTED FUNCTIONS
  20. 20. WRITTEN IN C
  21. 21. NIFS
  22. 22. DIRTY SCHEDULERS
  23. 23. “Due to heroic efforts by Steve Vinoski, Rickard Green, and Sverker Eriksson, we have an (experimental) so-called dirty-scheduler (DS) NIF API in the Erlang runtime, which has been somewhat stable since release 17.3.” https://medium.com/@jlouis666/erlang-dirty-scheduler-overhead-6e1219dcc7
  24. 24. IO INTENSIVE OR CPU INTENSIVE
  25. 25. DIRTY NIF FLAGS ERL_NIF_DIRTY_JOB_CPU_BOUND ERL_NIF_DIRTY_JOB_IO_BOUND http://erlang.org/doc/man/erl_nif.html
  26. 26. RUN QUEUE CPUDIRTY CPU RUN QUEUE NSCHEDULER N RUN QUEUE IODIRTY IO MIGRATION LOGIC
  27. 27. DIRTY SCHEDULERS ARE UNMANAGED https://github.com/erlang/otp/blob/maint/erts/emulator/internal_doc/ThreadProgress.md
  28. 28. DIRTY SCHEDULERS AREN’T FREE
  29. 29. RE-SCHEDULE DIRTY http://erlang.org/doc/man/erl_nif.html#enif_schedule_nif ENIF_SCHEDULE _NIF DIRTY TO “CLEAN”
  30. 30. LONG SCHEDULING http://erlang.org/doc/man/erlang.html#system_monitor-2 erlang:system_monitor(Pid, [{long_schedule,Time}])
  31. 31. DIRTY SCHEDULERS
  32. 32. RUST
  33. 33. MEMORY SAFE
  34. 34. FOND OF DIALYZER?
  35. 35. BLAZINGLY FAST
  36. 36. THREAD SAFETY
  37. 37. “SAFE C”
  38. 38. SYSTEMS PROGRAMMING
  39. 39. https://mgattozzi.com/avoiding-logic-errors
  40. 40. RUSTLER https://github.com/hansihe/rustler/
  41. 41. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  42. 42. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  43. 43. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  44. 44. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  45. 45. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  46. 46. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  47. 47. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  48. 48. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler/src/schedule.rs
  49. 49. UNSAFE
  50. 50. DIRTY FUNCTIONS
  51. 51. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler_tests/src/test_dirty.rs
  52. 52. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler_tests/src/lib.rs
  53. 53. https://github.com/hansihe/rustler/blob/b6578ea3999fd42f377c2497d8fae0bd629b927d/rustler_tests/test/dirty_test.exs
  54. 54. RUST
  55. 55. NIFS OR NAY?
  56. 56. SERVICES
  57. 57. CRITICAL
  58. 58. LINKS https://bgmarx.com/2018/08/01/getting-started-with-rustler/ https://bgmarx.com/2018/08/15/using-dirty- schedulers-with-rustler/
  59. 59. THANK YOU @BGMARX IMAGE CREDITS https://wallpaper-gallery.net/single/vaporwave-background-hd-14.html http://www.desktopimages.org/preview/770453/1920/1080/ https://www.wallpapervortex.com/ wallpaper-52083_1_miscellaneous_digital_art_vaporwave_image_glitch.html https://www.deviantart.com/epix0r/art/R-o-a-d-W-a-y-1920-x-1080-HD-629299503 https://wallpaper-gallery.net/single/glitch-wallpaper-hd-11.html
  60. 60. THANK YOU @BGMARX RESOURCEShttp://hansihe.com/erlang/elixir/c/2016/07/26/erlang-nif-preemptive-scheduling.html https://medium.com/@jlouis666/erlang-dirty-scheduler-overhead-6e1219dcc7 http://erlang.org/doc/man/erl_nif.html https://www.youtube.com/watch?v=FYQcn9zcZVA https://www.youtube.com/watch?v=lSLTwWqTbKQ https://hamidreza-s.github.io/erlang/scheduling/real-time/preemptive/migration/2016/02/09/erlang-scheduler- details.html https://jlouisramblings.blogspot.com/2013/01/how-erlang-does-scheduling.html https://www.rust-lang.org/en-US/ http://www.erlang-factory.com/upload/presentations/105/KennethLundin-ErlangFactory2009London- AboutErlangOTPandMulti-coreperformanceinparticular.pdf https://github.com/vinoski/bitwise
  61. 61. THANK YOU @BGMARX QUESTIONS? @bgmarx

×