Bug 1716028 - Update crossbeam-deque. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D121550
This commit is contained in:
Emilio Cobos Álvarez 2021-08-04 08:10:19 +00:00
parent 3c9cf910ab
commit 6c3cce394e
5 changed files with 71 additions and 48 deletions

4
Cargo.lock generated
View File

@ -877,9 +877,9 @@ dependencies = [
[[package]]
name = "crossbeam-deque"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils 0.7.2",

View File

@ -1 +1 @@
{"files":{"CHANGELOG.md":"f917b6e83aed21fcdb7615602b74377374144b6e075d1d96e9dac8c266795cab","Cargo.toml":"d160e0a9f564fa20e503f81a837057b09bdc8632d8b71c6a3d4a0a67c0bcaa21","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"c1e2f0e311bab5c2b82a9346e7b2fdaf17050a66913aad57fac40665fb65bb7b","src/lib.rs":"78b31a8d769607304d5d6250f8b06f257160b7c8b43ced5ef40f4ec3a51e076b","tests/fifo.rs":"7546ce471330a9d928a54f6ca41ddd36e9f4999852fdc4719bf9b24122a1c15f","tests/injector.rs":"c9107b437f790dbfab333f94d7211df29bb9a868d2d86304ad9fd7fa8db57d0a","tests/lifo.rs":"264967bc868870211e12a826f448a6d9e19ab5f7cc0e0bde86496cf76bb96e56","tests/steal.rs":"519549c18429db563c5238d7147e733901336943ca099669af2b553933b82694"},"package":"9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"}
{"files":{"CHANGELOG.md":"f9bf793a24b0cf1e3fe1dc82dd661663510328a36ed69a76a2d63fc93cdd388d","Cargo.toml":"8c05fb784cab5148bf452552393e1897fb5f70a621b11eb0b155526bdfbc6376","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"c1e2f0e311bab5c2b82a9346e7b2fdaf17050a66913aad57fac40665fb65bb7b","src/lib.rs":"bc513a515feceb6edec791381dfdda40e931f390141003cca95b1aea3b6291f6","tests/fifo.rs":"7546ce471330a9d928a54f6ca41ddd36e9f4999852fdc4719bf9b24122a1c15f","tests/injector.rs":"c9107b437f790dbfab333f94d7211df29bb9a868d2d86304ad9fd7fa8db57d0a","tests/lifo.rs":"264967bc868870211e12a826f448a6d9e19ab5f7cc0e0bde86496cf76bb96e56","tests/steal.rs":"519549c18429db563c5238d7147e733901336943ca099669af2b553933b82694"},"package":"c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed"}

View File

@ -1,3 +1,7 @@
# Version 0.7.4
- Fix deque steal race condition.
# Version 0.7.3
- Stop stealing from the same deque. (#448)

View File

@ -3,16 +3,15 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
name = "crossbeam-deque"
version = "0.7.3"
version = "0.7.4"
authors = ["The Crossbeam Project Developers"]
description = "Concurrent work-stealing deque"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-deque"

View File

@ -710,11 +710,13 @@ impl<T> Stealer<T> {
let task = unsafe { buffer.deref().read(f) };
// Try incrementing the front index to steal the task.
if self
.inner
.front
.compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
.is_err()
// If the buffer has been swapped or the increment fails, we retry.
if self.inner.buffer.load(Ordering::Acquire, guard) != buffer
|| self
.inner
.front
.compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
.is_err()
{
// We didn't steal this task, forget it.
mem::forget(task);
@ -816,16 +818,18 @@ impl<T> Stealer<T> {
}
// Try incrementing the front index to steal the batch.
if self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(batch_size),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
// If the buffer has been swapped or the increment fails, we retry.
if self.inner.buffer.load(Ordering::Acquire, guard) != buffer
|| self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(batch_size),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
{
return Steal::Retry;
}
@ -856,11 +860,18 @@ impl<T> Stealer<T> {
let task = unsafe { buffer.deref().read(f) };
// Try incrementing the front index to steal the task.
if self
.inner
.front
.compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
.is_err()
// If the buffer has been swapped or the increment fails, we retry.
if self.inner.buffer.load(Ordering::Acquire, guard) != buffer
|| self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(1),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
{
// We didn't steal this task, forget it and break from the loop.
mem::forget(task);
@ -1002,17 +1013,19 @@ impl<T> Stealer<T> {
}
}
// Try incrementing the front index to steal the batch.
if self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(batch_size + 1),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
// Try incrementing the front index to steal the task.
// If the buffer has been swapped or the increment fails, we retry.
if self.inner.buffer.load(Ordering::Acquire, guard) != buffer
|| self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(batch_size + 1),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
{
// We didn't steal this task, forget it.
mem::forget(task);
@ -1058,11 +1071,18 @@ impl<T> Stealer<T> {
let tmp = unsafe { buffer.deref().read(f) };
// Try incrementing the front index to steal the task.
if self
.inner
.front
.compare_exchange(f, f.wrapping_add(1), Ordering::SeqCst, Ordering::Relaxed)
.is_err()
// If the buffer has been swapped or the increment fails, we retry.
if self.inner.buffer.load(Ordering::Acquire, guard) != buffer
|| self
.inner
.front
.compare_exchange(
f,
f.wrapping_add(1),
Ordering::SeqCst,
Ordering::Relaxed,
)
.is_err()
{
// We didn't steal this task, forget it and break from the loop.
mem::forget(tmp);
@ -1436,9 +1456,9 @@ impl<T> Injector<T> {
// Destroy the block if we've reached the end, or if another thread wanted to destroy
// but couldn't because we were busy reading from the slot.
if offset + 1 == BLOCK_CAP {
Block::destroy(block, offset);
} else if slot.state.fetch_or(READ, Ordering::AcqRel) & DESTROY != 0 {
if (offset + 1 == BLOCK_CAP)
|| (slot.state.fetch_or(READ, Ordering::AcqRel) & DESTROY != 0)
{
Block::destroy(block, offset);
}