Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tirando Ruby por la Ventana™

Luis Lavena
November 26, 2011

Tirando Ruby por la Ventana™

Throwing Ruby through the Windows™

At Ruby community, mostly coming from Rails developers, there is a stigma around developers coming from Windows.

But, it is because the ignorance about the platform? it is because the platform sucks? or it because Ruby on Windows sucks?

Walk with me on this quest to find the root and perhaps start thinking on the future of Ruby.

Luis Lavena

November 26, 2011
Tweet

More Decks by Luis Lavena

Other Decks in Programming

Transcript

  1. Tirando Ruby por la Ventana™

  2. Twitter: @luislavena GitHub: luislavena luislavena

  3. AREA 17 www.area17.com

  4. RubyInstaller.org

  5. 4 años (Diciembre 18, 2007)

  6. None
  7. None
  8. None
  9. None
  10. Ruby-Core MinGW platform maintainer Nobuyoshi Nakada (nobu)

  11. ¿Windows?

  12. $#@%!!!!

  13. $#@%!!!!

  14. “No tengo Windows, asi que no hay gema”

  15. “No tengo Windows, asi que no hay gema”

  16. “No quiero preocuparme por Windows”

  17. gem install rake-compiler

  18. Poder crear gemas para Windows desde Linux/OSX

  19. 50+ developers lo usan • EventMachine • DataMapper • Nokogiri

    • Gherkin (Cucumber) • SQLite3 ;-)
  20. Aún asi...

  21. None
  22. None
  23. None
  24. Y peor aún...

  25. http://stackoverflow.com/questions/4704255

  26. “Do yourself a favor and stop knocking your head against

    the wall. Install Linux in VMWare or Virtualbox, load up Rails and RSpec/Cucumber, and compare. I think you'll have a much more enjoyable experience.”
  27. “I had done some looking around at operating system emulators,

    but I could not find anything suitable - I don't know what I'm doing, really”
  28. None
  29. None
  30. None
  31. “Ruby endorses diversity” Yukihiro “Matz” Matsumoto

  32. diversidad. (Del lat. diversĭtas, -ātis). 1. f. Variedad, desemejanza, diferencia.

  33. Linux

  34. Fedora Ubuntu Gentoo ...

  35. SunOS

  36. OSX

  37. ¿Y Windows?

  38. Pero Ruby en Windows es lento.

  39. ¿Por qué?

  40. Rails 3.1.1

  41. rails runner “0”

  42. Evolución 1.8.7 → 1.9.3

  43. 1.8.7-p352 1.9.2-p290 1.9.3-p0 0 1 2 3 4 5 6

    7 8 9 10 Windows
  44. 4.7 segundos!!!

  45. 1.8.7-p352 1.9.2-p290 1.9.3-p0 0 1 2 3 4 5 6

    7 8 9 10 Windows Linux
  46. “La culpa de que Ruby sea lento es de Windows”

  47. ¿Realmente?

  48. ¡A investigar!

  49. Profiling 1.9.3 GCC y AQTime

  50. Hot Spots (Hits)

  51. file_expand_path → 131284 hits

  52. file_expand_path call tree (….....)

  53. file_expand_path Code Type : x86 Hit Count : 131284 Time

    : 5037,07 Time with Children : 5369,69 file_expand_path Code Type : x86 Hit Count : 24274 Time : 987,55 Time with Children : 1045,27 rb_str_set_len Code Type : x86 Hit Count : 1232281 Time : 112,47 Time with Children : 168,66 rb_enc_check Code Type : x86 Hit Count : 155558 Time : 13,01 Time with Children : 61,51 rb_str_resize Code Type : x86 Hit Count : 26653 Time : 5,96 Time with Children : 29,49 rb_enc_associate_index Code Type : x86 Hit Count : 131284 Time : 14,67 Time with Children : 20,45 rb_path_skip_prefix Code Type : x86 Hit Count : 131284 Time : 13,35 Time with Children : 18,63 rb_string_value_ptr Code Type : x86 Hit Count : 131284 Time : 10,32 Time with Children : 16,18 rb_isalpha Code Type : x86 Hit Count : 311120 Time : 13,32 Time with Children : 13,32 rb_enc_get_index Code Type : x86 Hit Count : 107006 Time : 4,35 Time with Children : 4,35 rb_w32_getenv Code Type : x86 Hit Count : 2 Time : 0,02 Time with Children : 0,02 ruby_getcwd Code Type : x86 Hit Count : 2 Time : 0,00 Time with Children : 0,01 rb_filesystem_encindex Code Type : x86 Hit Count : 4 Time : 0,00 Time with Children : 0,00 ruby_xfree Code Type : x86 Hit Count : 2 Time : 0,00 Time with Children : 0,00 rb_feature_p Code Type : x86 Hit Count : 82636 Time : 3334,75 Time with Children : 3521,00 rb_find_file_ext_safe Code Type : x86 Hit Count : 23842 Time : 696,71 Time with Children : 1808,94 file_expand_path Code Type : x86 Hit Count : 24274 Time : 987,55 Time with Children : 1045,27 rb_find_file_safe Code Type : x86 Hit Count : 367 Time : 10,25 Time with Children : 27,10 rb_file_s_expand_path Code Type : x86 Hit Count : 165 Time : 7,81 Time with Children : 12,65 file_expand_path Code Type : x86 Hit Count : 24274 Time : 987,55 Time with Children : 1045,27 rb_str_set_len Code Type : x86 Hit Count : 1232281 Time : 112,47 Time with Children : 168,66 rb_type Code Type : x86 Hit Count : 1004706 Time : 76,73 Time with Children : 76,73 rb_enc_check Code Type : x86 Hit Count : 155558 Time : 13,01 Time with Children : 61,51 rb_safe_level Code Type : x86 Hit Count : 1233305 Time : 56,23 Time with Children : 56,23 rb_enc_compatible Code Type : x86 Hit Count : 158369 Time : 27,69 Time with Children : 49,22 rb_str_resize Code Type : x86 Hit Count : 26653 Time : 5,96 Time with Children : 29,49 ruby_xrealloc2 Code Type : x86 Hit Count : 32626 Time : 22,35 Time with Children : 22,35 rb_enc_associate_index Code Type : x86 Hit Count : 131284 Time : 14,67 Time with Children : 20,45 rb_path_skip_prefix Code Type : x86 Hit Count : 131284 Time : 13,35 Time with Children : 18,63 rb_enc_get_index Code Type : x86 Hit Count : 392035 Time : 17,63 Time with Children : 17,63 rb_string_value_ptr Code Type : x86 Hit Count : 131284 Time : 10,32 Time with Children : 16,18 rb_isalpha Code Type : x86 Hit Count : 311120 Time : 13,32 Time with Children : 13,32 str_independent Code Type : x86 Hit Count : 44277 Time : 3,68 Time with Children : 5,62 rb_isalpha Code Type : x86 Hit Count : 132129 Time : 5,33 Time with Children : 5,33 rb_enc_get_index Code Type : x86 Hit Count : 107006 Time : 4,35 Time with Children : 4,35 ruby_xfree Code Type : x86 Hit Count : 1397 Time : 0,66 Time with Children : 0,66 rb_w32_getenv Code Type : x86 Hit Count : 2 Time : 0,02 Time with Children : 0,02 ruby_getcwd Code Type : x86 Hit Count : 2 Time : 0,00 Time with Children : 0,01 rb_w32_getcwd Code Type : x86 Hit Count : 4 Time : 0,01 Time with Children : 0,01 vm_xmalloc.clone.10 Code Type : x86 Hit Count : 4 Time : 0,01 Time with Children : 0,01 rb_filesystem_encindex Code Type : x86 Hit Count : 4 Time : 0,00 Time with Children : 0,00 st_lookup Code Type : x86 Hit Count : 4 Time : 0,00 Time with Children : 0,00 rb_enc_from_index Code Type : x86 Hit Count : 28 Time : 0,00 Time with Children : 0,00 rb_typeddata_is_kind_of Code Type : x86 Hit Count : 28 Time : 0,00 Time with Children : 0,00 ruby_xfree Code Type : x86 Hit Count : 2 Time : 0,00 Time with Children : 0,00 24274 1232281 155558 26653 131284 131284 131284 311120 107006 2 2 4 2 82636 23842 24274 367 165 24274 1232281 1004706 155558 1233305 158369 26653 32626 131284 131284 392035 131284 311120 44277 132129 107006 1397 2 2 4 4 4 4 28 28 2
  54. None
  55. None
  56. file_expand_path → file_expand_path → file_expand_path → file_expand_path

  57. Inception!

  58. Inception!

  59. file_expand_path_* (y amigos) → file.c

  60. file.c

  61. file.c • 5455 LOC • 99 #ifdef • 37 #if

    defined • 3 #if !defined
  62. file_expand_path • 316 LOC • 15 comentarios • 13 #if*

    • POSIX + Windows + Cygwin • 1 goto • …
  63. None
  64. File.expand_path “” x 10_000

  65. V:\ V:\a\b\c\d\e 0 0,05 0,1 0,15 0,2 0,25 0,3 0,35

    0,4
  66. WTF

  67. File.expand_path “foo”, “bar” x 10_000

  68. V:\ V:\a\b\c\d\e 0 0,1 0,2 0,3 0,4 0,5 0,6 0,7

    0,8 0,9 1
  69. WTF x2

  70. 0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6

  71. Ruby → C → POSIX-like → Win32 API

  72. None
  73. Fenix http://github.com/luislavena/fenix

  74. Ruby → C → Win32 API

  75. Specs!

  76. Ruby no tiene tests para File.expand_path

  77. Fenix::File.expand_path

  78. 0 0,2 0,4 0,6 0,8 1 1,2 1,4 1,6

  79. None
  80. ¡Totalmente experimental! (no me hago responsable de nada)

  81. patch load.c https://gist.github.com/1258289

  82. SET RUBYOPT=-rfenix/replace

  83. rails runner “0”

  84. 1.9.3-p0 0 1 2 3 4 5 6 Ruby Fenix

  85. Demo

  86. 1.9.3-p0 0 1 2 3 4 5 6 Current Fenix

    Linux
  87. Achtung! • Fenix es solo un experimento • Prueba de

    concepto
  88. Usar nuevas Win32 API Windows XP+

  89. Olvidarnos de Windows 95/98

  90. Código más claro

  91. Un Ruby más rápido es posible.

  92. Ruby 2.0 • Plan para 2013 • 20 años

  93. Tiempo de limpiar la casa

  94. Y tirar todo lo viejo

  95. None
  96. Otros ejemplos

  97. PHP 5.3

  98. node.js libuv

  99. libuv • Evented Library • Abstracción de OS • win/unix/bsd

  100. Solo falta voluntad para lograrlo.

  101. (y mejor actitud de la comunidad)

  102. TheCodeShop http://thecodeshop.github.com

  103. Importante

  104. </rant>

  105. Soy parte de Ruby-Core (asi que puedo quejarme)

  106. ¿Preguntas? (yo tengo varias)

  107. Recordar

  108. Ruby != Rails

  109. Ruby es mucho más que Rails

  110. ¡Muchas gracias! CC: attribution, non-commercial, share alike.