refactor(users/edef/weave): use swap rather than CAS

We only care about ordering on the same variable, and we rely on the
release barrier provided by rayon's thread joining.

The comparison failing is always an error path, and we're indifferent
about which thread it fails on.

Change-Id: I592a7eaae5b6935cf424c6576a49786f39909fb6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12666
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
edef 2024-10-19 11:17:19 +00:00
parent 25671c284f
commit 549c51f200

View file

@ -43,9 +43,11 @@ fn main() -> Result<()> {
eprint!("… resolve roots\r"); eprint!("… resolve roots\r");
ph_array.par_iter().enumerate().for_each(|(idx, h)| { ph_array.par_iter().enumerate().for_each(|(idx, h)| {
if let Some(idx_slot) = roots.find(h) { if let Some(idx_slot) = roots.find(h) {
idx_slot assert_eq!(
.compare_exchange(INDEX_NULL, idx as u32, Ordering::SeqCst, Ordering::SeqCst) idx_slot.swap(idx as u32, Ordering::Relaxed),
.expect("duplicate entry"); INDEX_NULL,
"duplicate entry"
);
} }
}); });
eprintln!("{DONE}"); eprintln!("{DONE}");