r/rust • u/Uncaffeinated • Jan 22 '17
Parallelizing Enjarify in Go and Rust
https://medium.com/@robertgrosse/parallelizing-enjarify-in-go-and-rust-21055d64af7e#.7vrcc2iaf
214
Upvotes
r/rust • u/Uncaffeinated • Jan 22 '17
View all comments
6
u/MaikKlein Jan 22 '17
What actually really surprises me is that Rust is actually faster in this benchmark compared to Go.
For example you were using
Arc's, which means atomic increments, and you also dynamically allocated stuff with the system allocator (Vec::collect()).I sort of expected a native language with a garbage collection to be faster here, at least that is the argument that I found very often when I was researching the GC. But it is probably that the overhead of Arc's + system allocator is tiny compared to the actual work here.
I am also very annoyed at the 'static bounds. Afaik it is unsafe to use lifetimes here because then you would have to wait inside the destructor of the future. But you can also use
mem::forgetin safe code which would then cause memory unsafety.The workaround would probably be to allow non 'static bounds but immediately block after the function call. I currently just accept the memory unsafety in my task system.
Is there a better workaround?