rust-lang / datafrog

A lightweight Datalog engine in Rust
Apache License 2.0
796 stars 43 forks source link

Specialize creating Relations from Vecs #10

Closed lqd closed 5 years ago

lqd commented 6 years ago

While this makes 🐸 rely on an unstable feature, it can help avoiding consuming Vecs and collecting them immediately afterwards.

For example, it should prevent 81k of such cases in Polonius' clap benchmark, for the datafrogopt variant. (It's not a huge time saving in this case, but still)

Thoughts ? (especially if we'd want to add a rust-toolchain file, or still support stable by having different functions for IntoInter and Vec)

frankmcsherry commented 6 years ago

I think the code used to have a from_vec in it, if you want to avoid specialization (I would, because I've been bit by "nightly isn't stable" enough). It is less fabulous, but perhaps clearer?

lqd commented 6 years ago

I don't mind either way :) That's why I was interested in y'all's opinion, and will update this PR accordingly!

Sticking to stable is worth it, so I'll pubthe from_vec fn which is still here of course, and use that instead.

lqd commented 6 years ago

Although, if I do this now it'll break the treefrog PR, as the leapjoin creates non-empty Relations (and so will benefit from bypassing the Vec consumption) — so it might be interesting to wait a bit, say for #11 to possibly land, in order to update both this PR and then Polonius.

nikomatsakis commented 5 years ago

I too think it would be wise to stick to stable if possible — since this lives outside the rust-lang repo, it will make coordinating breaking changes much easier.

lqd commented 5 years ago

agreed, I'll reopen this PR once #11 lands so that I can switch from specialization to using from_vec everywhere in one fell swoop in datafrog and then in Polonius.