Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unconditional use of optional rayon dependency #272

Open
NinoScript opened this issue Jul 9, 2024 · 1 comment
Open

Unconditional use of optional rayon dependency #272

NinoScript opened this issue Jul 9, 2024 · 1 comment

Comments

@NinoScript
Copy link

There's code that unconditionally uses rayon even though it is an optional dependency.
This makes me unable to build cozo-lib-python, as it fails with this error message:

error[E0599]: no method named `par_iter` found for reference `&BTreeMap<MagicSymbol, CompiledRuleSet>` in the current scope
   --> cozo-core/src/query/eval.rs:200:26
    |
199 |                       let execs = prog
    |  _________________________________-
200 | |                         .par_iter()
    | |_________________________-^^^^^^^^
    |
@NinoScript
Copy link
Author

NinoScript commented Jul 9, 2024

One possible solution would be to use the rayon feature of cozo-core in the cozo-lib-python crate:

[dependencies]
- cozo = { version = "0.7.6", path = "../cozo-core", default-features = false }
+ cozo = { version = "0.7.6", path = "../cozo-core", features = ["rayon"] }

(maybe it affects other crates too, I haven't checked)


The code that uses rayon is already conditional, but it is testing for not(wasm32) instead of rayon itself.
So, another possible solution would be to change these to check for rayon directly:

- #[cfg(not(target_arch = "wasm32"))]
+ #[cfg(rayon)]
use rayon::prelude::*;
-               #[cfg(not(target_arch = "wasm32"))]
+               #[cfg(rayon)]
                { /* ... */
                    let execs = prog
                        .par_iter()

(assuming there's no other reason for those target_arch checks)


Let me know you're ok with any of these solutions and I'll contribute with a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant