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

Potential to modify ordering for split_count and tour_counter #1139

Closed
wang384670111 opened this issue Mar 4, 2024 · 2 comments
Closed

Potential to modify ordering for split_count and tour_counter #1139

wang384670111 opened this issue Mar 4, 2024 · 2 comments

Comments

@wang384670111
Copy link
Contributor

wang384670111 commented Mar 4, 2024

let update = self
.split_count
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |c| c.checked_sub(1));

SeqCst is overly restrictive. I believe that the ordering can be appropriately modified.

In par_bridge model, I believe that split_count is just a counter across threads and does not synchronize with other locals. Therefore, using Relaxed ordering should suffice.

let counter = self.tour_counter.fetch_add(1, Ordering::SeqCst);

Similarly, In solver model, tour_counter is just a counter across threads, using Relaxed ordering should suffice.

(happy to make a PR if this looks reasonable)

@wang384670111 wang384670111 changed the title Potential to modify ordering for split_count in par_bridge module Potential to modify ordering for split_count and tour_counter Mar 4, 2024
@cuviper
Copy link
Member

cuviper commented Mar 4, 2024

It's been this way in par_bridge since it was first added in #550, but I don't think we paid much attention to that ordering. I agree that Relaxed should be fine, but I also think it won't make much difference, as this only executes once per thread for a given par_bridge. The real contention comes when they all wait on the same Mutex<Iter>.

The tsp counter is fine to change too. You're welcome to make a PR!

@wang384670111
Copy link
Contributor Author

Related Link for PR:
#1140

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

2 participants