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

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Earn Money With Your Website