3 ms·
As someone working on exactly such a query engine, this is very interesting, thanks. It's worth noting that Rust uses iterators extensively, yet is able to get
by atombender 8y ago
As someone working on exactly such a query engine, this is very interesting, thanks.
It's worth noting that Rust uses iterators extensively, yet is able to get around much of the issues with the pull model by being able to optimize and inline iteration loops.
I believe its starting point for getting good performance here is by making iterators — i.e., the std::iter::Iterator trait — a first-class trait. For example, "for v in iter" knows about how to loop over iterators, and "for v in values" sees if "values" implements the IntoIter trait to turn it into an iterator. Rust also avoids vtable lookup when the value is not a polymorphic boxed trait. Together, this means it can aggressively inline and unroll iteration loops. I'm sure they use other tricks, as well.