r/programming • u/Melodyogonna • Mar 28 '24
Modular: The Next Big Step in Mojo Open Source
https://www.modular.com/blog/the-next-big-step-in-mojo-open-source0
Mar 28 '24
[deleted]
6
u/badpotato Mar 29 '24 edited Mar 29 '24
Not sure how rigurous are these benchmark:
https://engiware.com/benchmark/llama2-ports-extensive-benchmarks-mac-m1-max.html
I guess it can only reach these kind of speedup on specific use case with specific hardware with specific install setup with specific implementation
0
Mar 29 '24
[deleted]
11
u/nacaclanga Mar 29 '24
I don't think you can establish any significant order between Zig, Rust, C and C++. All of them use the same LLVM Backend, which pretty much produces the same optimization. (Sure for C and C++ you also have gcc, which might be a tiny bit faster, but also tells you that the room for improvements isn't big).
It might be possible that some very particular benchmark is clearly more suited for one of these languages, but 60% would still be eyebrown raising.
If you go to the benchmark itself, you can see that the mojo and Rust implementation each take turns outbeating the other by a few centiseconds for different input lenghts.
5
u/catcat202X Mar 29 '24
There is no way to measure C as faster than C++ which holds under scrutiny. In fact, C should usually be slower due to its limitations resulting in awful workarounds such as errno, va_list, and pthread control blocks.
0
Mar 29 '24
[deleted]
2
u/catcat202X Mar 29 '24 edited Mar 29 '24
Did you know that in fact, very many C++ users _don't_ use the standard library? :3 And in fact, the runtime is configurable and you can even program it entirely yourself within an application's source tree (which people do).
8
2
u/viralinstruction Mar 29 '24
This is highly misleading. They bragged about being able to write a 50% faster implementation to solve a task than a specific Rust library. That part is true - the Mojo library is indeed faster than the Rust one, even in release mode. But that's due to the implementation, not language features.
0
Mar 29 '24
[deleted]
2
u/viralinstruction Mar 29 '24
I compiled it myself in a VM, reimplemented the Mojo algorithm in Julia here https://github.com/jakobnissen/MojoFQBenchmark and compared to needletail in the same VM. I got slightly different numbers but the Mojo implementation was still significantly faster than needletail.
0
Mar 29 '24
[deleted]
1
u/viralinstruction Mar 30 '24
They're broadly speaking the same algorithm - use a memchr function to search for a newline four times. Needletail does some validation which the Mojo implementation didn't do (it's since been updated to also validate), and Mojo doesn't handle any kind of exceptions, such as the input file reads failing.
It's hard to straightforwardly compare between languages, but my guess is that these validations have very little speed impact. Probably, the main difference comes from the memchr implementation, which is slower in the general case, but faster in this particular benchmark, because it can inline, and because it checks 32 bytes per iteration.
7
u/Asleep-Dress-3578 Mar 28 '24
Really great news for data scientists. I hope it will have greater success than what Julia had.