You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for i in indices {self.rankers[i].update(post_id, score);}
self.rankers: Vec<Ranker> is a vector of the data structure Ranker which calls the function/method pub fn update(&mut self, id: Id, score: Score) which mutate self in Ranker.
But self.rankers is a very large vector so it feels wastefull to have to filter the whole vector when I only need to update a small amout of indices. Is it possible to parallelize the code without filtering the whole vector?
The text was updated successfully, but these errors were encountered:
Maybe par_chunks_mut would be better for you, and then you can serially apply relevant indices to each parallel chunk. That could be imbalanced though if the indices might be clustered in any chunk.
If the indices are sorted, another possibility is to write a custom split performing indices.split_at(midpoint) paired with rankers.split_at_mut at the least of the right indices split. This would have the advantage of parallelizing well for any distribution of indices.
Hello, I am trying to parallelize this code:
self.rankers: Vec<Ranker>
is a vector of the data structureRanker
which calls the function/methodpub fn update(&mut self, id: Id, score: Score)
which mutateself
inRanker
.So far i have gotten this to work:
But
self.rankers
is a very large vector so it feels wastefull to have to filter the whole vector when I only need to update a small amout of indices. Is it possible to parallelize the code without filtering the whole vector?The text was updated successfully, but these errors were encountered: