Closed gryznar closed 2 weeks ago
Any benchmark numbers?
I have attached my benchmarks result in issue.
Thanks @gryznar for reporting. We are aware of this issue and will take steps to resolve this ASAP
@abduld another thing to add here (more important than stdout). In some cases Mojo jitted is much slower than python. For example in sth like that:
fn main():
print("sth1")
print('sth2')
...
print('sth1000')
This script compiled AoT takes 0.04s to run, similar code takes in Python 0.08s, but via:
mojo run script.mojo
it takes over 2s, where 2s takes to compile that.
Thanks @gryznar this is good to know. I believe the fix for the above will make compilation faster as well. Let's take one thing at a time ;)
I hope so, cause compilation time here is alarming
Edit: @abduld Yet another thing, but may be very useful. As it was mentioned here: https://discord.com/channels/1087530497313357884/1098713601386233997/1159447998489710643
in this video: https://youtu.be/kgUXfDpAmGQ?si=ddJZ7Po7xRU6lI7i speakers's compiler can compile 3M lines of code/s. Maybe some tricks introduced there may be ported to Mojo? With such speed startup problems may fade into oblivion 😁
@abduld when you will manage to fix this, could you also look at that: https://github.com/modularml/mojo/issues/1216 ? This is another String related problem, in this case connected with allocations. Root cause may be similar
FYI to anyone interested in improved formatting performance, while we don't have buffered IO yet, I recently implemented a Formatter
abstraction for Mojo that avoids needing intermediate String
allocations when trying to format/print a type, see this recent commit:
[stdlib] feature: Add non-allocating formatting abstraction
which includes more information and examples.
Is there an alternative method for printing? Is it possible to use the Python print function?
Bug description
This video (finding prime numbers): https://www.youtube.com/watch?v=D4xX3aS5JjE&pp=ygUTbW9qbyB2cyBnbyB2cyBjb2Rvbg%3D%3D shows that Mojo is fast, but not as fast as other languages like Go or even Codon (compiled Python implementation).
I have performed some benchmarks using similar code as in video:
Results (Go and Mojo compiled AoT):
As you can see in pure computations Mojo is taking 2x less time.
With adding prints: to Mojo:
to Go:
Results (Go and Mojo compiled AoT):
Mojo is loosing its performance benefits, when stdout is involved. Tested on: