Donations

BTC: bc1qxv3stg0xha9upurf7h4aqnmg3xjn3h0zk28kpe

ETH: 0x01870296774Fb0A2DbF9b44d2E6a57fb8Ccea070

LTC: LQ44CP6xDDkX5bAiKd3yqmDB4c23U7orrQ

DOGE: DCpu9v1bkTXj8VKUDG97LHdV2qipDPyZsR

ADA: addr1qx4q7348dv2ju5zshee9ru23ssmqhyyjlnxe0xlezjq5we42par2w6c49eg9p0nj28c4rppkpwgf9lxdj7dlj9ypganqtmuu2p

sexta-feira, 19 de janeiro de 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.


















Continue reading


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

0 comentários:

Postar um comentário

Donations

BTC: bc1qxv3stg0xha9upurf7h4aqnmg3xjn3h0zk28kpe

ETH: 0x01870296774Fb0A2DbF9b44d2E6a57fb8Ccea070

LTC: LQ44CP6xDDkX5bAiKd3yqmDB4c23U7orrQ

DOGE: DCpu9v1bkTXj8VKUDG97LHdV2qipDPyZsR

ADA: addr1qx4q7348dv2ju5zshee9ru23ssmqhyyjlnxe0xlezjq5we42par2w6c49eg9p0nj28c4rppkpwgf9lxdj7dlj9ypganqtmuu2p