Open risufaj opened 1 year ago
@risufaj very nice module / issue 😃 Thanks for pinging!
Yes, Rust API is not as polished as C/C++, but there is a plan to improve it, this will help 💪
I'll try to deep-dive in the following days, in the meantime, if you have some suggestions on the API side, feel free to dump them here or make a new PR with the improvements 👀
There are definitely workarounds. For example, in my use case, I'm practically doing random walks as an approximations for personalized pagerank. Then, it is enough to calculate the neighbors for each node and store this information in a HashMap for instance, and use rayon to paralellize the loops over those. This is very likely not optimized, but I just tried it today to show that it works. Also, from what I understand, something similar to this is done for the C++ implementation of pagerank.
However, it makes sense to have a better and more general solution, that also doesn't require to first go over the whole graph and then do what you need to do every time the query module is called. I know I'm not proposing anything concrete yet, but we'll get there.
@risufaj I've put your code into the #336 PR and made it compilable with the Send&Sync
trait implementations (just "hints"). But, the underlying object has to be implemented to be safe.
It's not a huge priority for me now, but I'll try to figure out / implement thread safety in the following days/weeks.
If you have any suggestions, just put them here or contribute directly to the PR 😃
Thank you @gitbuda This does allow now for parallel access to the graph. However, there is no speedup when compared to the workaround that I mentioned before. That's probably to do with the larger usecase though.
Hello,
I've been trying to develop a query module in rust that tries to parallelize some loops using the rayon library. The parallelization loops involve accessing nodes and edges. However, I get this error :
G cannot be shared between threads
safely where G is a MemgraphGraph object. I've seen that some of the query modules in C++ have parallelisation, but I haven't been able to find anything for rust.Here is some code to reproduce this.
Cargo.toml
The src folder contains these files:
lib.rs
example.rs
Any help on how to move this forward would be great.