1 2 Ambtion.com 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 Ambtion.com 279 280 281 Advertise Free on Auto-pilot!
Watch the latest videos on YouTube.com
newgoldenjewels: Mojo Vs Rust, Basic Test And Binary Perspective.

Friday, January 26, 2024

Mojo Vs Rust, Basic Test And Binary Perspective.

Hello, In first place I'm not going to do an algorithmic benchmark, just a simple loop + print test and some checks on the generated binaries.

The system is a Debian12 Linux and the architecture is: x86 64bits.



Rust

Mojo


Mojo don't allow .py extension it has to be .mojo so no default nvim highlighting ...


$ mojo build mojo_benchmark.mojo

$ time ./mojo_benchmark

...

real 0m0.342s

user 0m0.080s

sys 0m0.252s



$ rustc rust_benchmark.rs

$ time ./rust_benchmark

...

real 0m0.107s

user 0m0.012s

sys 0m0.049s


I noticed a speed increase using fish shell instead of bash but could be the environment variable stack overload.


So in this specific test rust is much faster. And also the compiler suggests using _ instead i, that mojo compiler doesn't.

The rust binary is bigger, but is because the allocator is embedded:

-rwxr-xr-x 1 sha0 sha0 1063352 Jan 10 08:55 mojo_benchmark

-rwxr-xr-x 1 sha0 sha0 4632872 Jan 10 08:57 rust_benchmark


But Look this, mojo uses libstdc++ and libc  and rust only uses libc.

$ ldd -d mojo_benchmark

linux-vdso.so.1 (0x00007ffd94917000)

libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fe899cb1000)

libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe899a00000)

libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe899921000)

libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe899c91000)

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe899740000)

/lib64/ld-linux-x86-64.so.2 (0x00007fe899d2c000)


$ ldd -d rust_benchmark

linux-vdso.so.1 (0x00007ffde67b7000)

libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8b3881b000)

libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8b3863a000)

/lib64/ld-linux-x86-64.so.2 (0x00007f8b388ae000)



Lets check the binary.
All the python non used built-ins are written to the binary, so does rust in this case.

mojo

rust




Steps until libc write:

Mojo



Rust


Ok wait, rustc like cargo by default is on debug-mode which is the slower version, the way to do cargo --release which is much faster is  rustc -O rust_benchmark.rs

real 0m0.107s
user 0m0.005s
sys 0m0.056s


This simple program don't make profit of the optimizations.


Rust


We reduced from 30 calls to 27.
I'm not going to criticize the number of calls because rust does his magic and result faster.

Mojo only 7 calls but runtime seems slower.

Regarding memory operations, seems that is rust like compiler-time borrow checked.

https://docs.modular.com/mojo/programming-manual.html#behavior-of-destructors


Rust decompiled


Rust disassembled





Mojo decompiled





Mojo disassembled



So we have two things: the crafted assembly speed, and specially the runtime speed.

Looking the Rust assembly, it's writing the string pointer to stack on every iteration which is same pointer in every iteration.

However Mojo loop is more optimized, param and address to call are pre-calculated before the loop.


So Mojo is generating optimized code, but its c++ API seems slower, at least the print() 

Regards.


















Related links


  1. Hack Tools
  2. Hacker Tools Linux
  3. Black Hat Hacker Tools
  4. Hacker Tools Apk Download
  5. How To Hack
  6. Hack Tools Mac
  7. Hack And Tools
  8. Nsa Hack Tools
  9. Pentest Tools Online
  10. Hacker Tools List
  11. Hacking Tools Pc
  12. Pentest Recon Tools
  13. Android Hack Tools Github
  14. Tools Used For Hacking
  15. Pentest Tools
  16. Hacker
  17. Hacking Tools Github
  18. Hacking Tools Windows 10
  19. Hackrf Tools
  20. Best Pentesting Tools 2018
  21. Hack Tools For Mac
  22. Nsa Hack Tools
  23. Pentest Automation Tools
  24. Hacker Tools Apk Download
  25. Pentest Tools Url Fuzzer
  26. Physical Pentest Tools
  27. Pentest Tools Website Vulnerability
  28. Hacker Tools For Windows
  29. Underground Hacker Sites
  30. Hacking Tools For Beginners
  31. Hacker
  32. Pentest Automation Tools
  33. Android Hack Tools Github
  34. Hacker Tools 2019
  35. Hacking Tools Hardware
  36. Hacker Tools Apk
  37. Hacker Tools 2019
  38. Hacking App
  39. Hacking Tools Pc
  40. Hak5 Tools
  41. Hack And Tools
  42. Hack Tools For Mac
  43. Hacking Tools Kit
  44. Hacker Tools Mac
  45. Pentest Tools Kali Linux
  46. Hacker Tools Linux
  47. Best Pentesting Tools 2018
  48. Pentest Tools Open Source
  49. Hacking Tools Github
  50. Hacker Tools Apk Download
  51. Hack Tools For Pc
  52. Hack Tools For Ubuntu
  53. Nsa Hack Tools
  54. Hack Tools For Ubuntu
  55. Hacker Tools Apk
  56. Pentest Automation Tools
  57. Hacker Tools For Pc
  58. Ethical Hacker Tools
  59. Hacker Tools Github
  60. How To Install Pentest Tools In Ubuntu
  61. Hacker Search Tools
  62. Pentest Tools For Windows
  63. Hacking Tools Download
  64. Pentest Tools Website Vulnerability
  65. Pentest Tools For Mac
  66. What Is Hacking Tools
  67. Beginner Hacker Tools
  68. Install Pentest Tools Ubuntu
  69. Hacker Tools Hardware
  70. Pentest Tools Windows
  71. Hack Tools Github
  72. Hacking Tools Software
  73. Hacking Tools Download
  74. Usb Pentest Tools
  75. Easy Hack Tools
  76. Hack Tool Apk No Root
  77. Hack Tools For Games
  78. Pentest Tools For Ubuntu
  79. Best Hacking Tools 2019
  80. Nsa Hack Tools Download
  81. Hack Tool Apk No Root
  82. Hack Tool Apk No Root
  83. Pentest Tools Url Fuzzer
  84. Hacking Tools Online
  85. Kik Hack Tools
  86. Hacker Tools List
  87. Hacking App
  88. Hack Tools Github
  89. Underground Hacker Sites
  90. Hack Tools Pc
  91. Hack Tools For Games
  92. Hack Tools Pc
  93. Pentest Tools Kali Linux
  94. Wifi Hacker Tools For Windows
  95. Kik Hack Tools
  96. Hacks And Tools
  97. Pentest Tools Port Scanner
  98. Android Hack Tools Github
  99. Hacking Tools Software
  100. Github Hacking Tools
  101. Hak5 Tools
  102. Pentest Box Tools Download
  103. Computer Hacker
  104. Hack Tools For Mac
  105. Pentest Recon Tools
  106. Hack Tools For Pc
  107. Pentest Tools Download
  108. Hack And Tools
  109. Hacker Tools Free
  110. What Is Hacking Tools
  111. Hacker Tools Linux
  112. Hacking Tools 2020
  113. Pentest Tools Website
  114. Hacking Tools Usb
  115. Hacking Tools And Software
  116. Hack Tools Github
  117. Pentest Tools Url Fuzzer
  118. Hack Tools For Ubuntu
  119. Hacker Tools Github
  120. Hacker Security Tools
  121. Hacker Tools Apk Download
  122. Pentest Tools Review
  123. Hack Tools Github
  124. Github Hacking Tools
  125. New Hacker Tools
  126. Hacking Tools For Games
  127. Pentest Tools Github
  128. Pentest Tools For Android
  129. Bluetooth Hacking Tools Kali
  130. Hacking Tools For Games
  131. Pentest Tools Review
  132. World No 1 Hacker Software
  133. Pentest Tools For Windows
  134. Hacking Tools Kit
  135. Hacking Tools 2019
  136. Hacking Tools Free Download
  137. Hacker Security Tools
  138. Hacker Techniques Tools And Incident Handling
  139. Hacker Security Tools
  140. Wifi Hacker Tools For Windows
  141. Hacker
  142. Pentest Tools Linux
  143. Hacker Security Tools
  144. Nsa Hacker Tools
  145. Hack Tools For Games
  146. Hack Rom Tools
  147. Hack Website Online Tool
  148. Growth Hacker Tools
  149. Hack Tools Github
  150. Hack Tools Download
  151. Ethical Hacker Tools
  152. Usb Pentest Tools
  153. Hacking App
  154. Hacker Tools Windows
  155. Hack Tools For Ubuntu
  156. Top Pentest Tools
  157. Nsa Hack Tools
  158. How To Make Hacking Tools
  159. Hacking Tools For Kali Linux
  160. Hacker Tools Github
  161. Hack And Tools
  162. Hacking Tools Usb
  163. World No 1 Hacker Software
  164. Pentest Tools Download
  165. Hacker Tools Online
  166. Hacker Search Tools
  167. Hack Rom Tools
  168. Pentest Tools Website Vulnerability
  169. Beginner Hacker Tools
  170. Pentest Recon Tools
  171. Hack Tools For Windows
  172. Pentest Tools Tcp Port Scanner
  173. Hacker Tools Apk Download
  174. Pentest Tools Apk
  175. Hacking Tools And Software
  176. Pentest Reporting Tools
  177. Hacking Tools Download
  178. Hacker Security Tools

No comments: