Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
jobs:
check:
name: Check
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
strategy:
fail-fast: false
matrix:
Expand All @@ -32,7 +32,7 @@ jobs:

test:
name: Test suite
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -45,7 +45,7 @@ jobs:

loom:
name: Test suite (Loom)
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -61,7 +61,7 @@ jobs:

miri:
name: Miri
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -78,7 +78,7 @@ jobs:

lints:
name: Lints
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -96,7 +96,7 @@ jobs:

docs:
name: Docs
runs-on: ubuntu-latest
runs-on: ubicloud-standard-2
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish

# House scheme: a version bump on the default branch is the release. No tags,
# no manual step. Publishing is irreversible, so the trigger has to be
# something you cannot do by accident, and editing the version field is that.
on:
push:
branches: [main]
paths: ['Cargo.toml']

jobs:
publish:
runs-on: ubicloud-standard-2
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: dtolnay/rust-toolchain@stable

- id: version
run: |
new=$(sed -nE '0,/^version = "(.*)"/s//\1/p' Cargo.toml)
old=$(git show HEAD^:Cargo.toml | sed -nE '0,/^version = "(.*)"/s//\1/p')
if [ "$new" = "$old" ]; then
echo "version unchanged at $new, nothing to publish"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "version $old -> $new"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

# The gate runs on this commit too, but a release must not depend on job
# ordering, so it is re-run here rather than assumed.
- if: steps.version.outputs.changed == 'true'
run: cargo test --release

- if: steps.version.outputs.changed == 'true'
run: cargo publish --token "$CARGO_REGISTRY_TOKEN"
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[package]
name = "st3"
name = "ps-st3"
# When incrementing version and releasing to crates.io:
# - Update crate version in README.md
# - Update CHANGELOG.md
# - Update if necessary copyright notice in LICENSE-MIT
# - Create a "vX.Y.Z" git tag
version = "0.4.1"
version = "0.4.2"
authors = ["Serge Barral <serge.barral@asynchronics.com>"]
edition = "2021"
rust-version = "1.60"
license = "MIT OR Apache-2.0"
repository = "https://github.com/asynchronics/st3"
repository = "https://github.com/pathscale/st3"
readme = "README.md"
description = """
A very fast lock-free, bounded, work-stealing LIFO queue.
Expand All @@ -20,6 +20,11 @@ keywords = ["queue", "stack", "bounded", "lock-free", "work-stealing"]
autotests = false
autobenches = false

[lib]
# The crate is renamed but the library is not, so `use st3::...` and the
# `st3_loom` cfg both keep working unchanged against the fork.
name = "st3"

[dependencies]
crossbeam-utils = { version = "0.8.14", default-features = false }

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# St³ — the Stealing Static Stack

> A PathScale fork of [asynchronics/st3](https://github.com/asynchronics/st3), published as
> `ps-st3`. The library is still named `st3`, so `use st3::lifo::Worker` is unchanged.
> It carries upstream PR #12 (bulk segmented copies on steal) ahead of a release, plus a
> differential test holding that bulk path against the per-element reference.

Lock-free, bounded, work-stealing queues with FIFO stealing and LIFO or FIFO
semantic for the worker thread.

Expand Down Expand Up @@ -34,7 +39,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
st3 = "0.4.1"
ps-st3 = "0.4.1"
```


Expand Down
32 changes: 22 additions & 10 deletions src/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,16 @@ impl<T> Stealer<T> {
debug_or_loom_assert!(transfer_count <= dest_free_capacity);

// Move all items but the last to the destination queue.
for offset in 0..transfer_count {
unsafe {
let item = self.queue.read_at(stealer_head.wrapping_add(offset));
dest.queue.write_at(dest_tail.wrapping_add(offset), item);
}
unsafe {
crate::transfer::transfer_items(
&self.queue.buffer,
self.queue.mask,
stealer_head,
&dest.queue.buffer,
dest.queue.mask,
dest_tail,
transfer_count,
);
}

// Make the moved items visible by updating the destination tail position.
Expand Down Expand Up @@ -664,11 +669,18 @@ impl<T> Stealer<T> {
debug_or_loom_assert!(transfer_count <= dest_free_capacity);

// Move all items but the last to the destination queue.
for offset in 0..transfer_count {
unsafe {
let item = self.queue.read_at(stealer_head.wrapping_add(offset));
dest.queue.write_at(dest_tail.wrapping_add(offset), item);
}
//
// Safety: see the `steal()` method.
unsafe {
crate::transfer::transfer_items(
&self.queue.buffer,
self.queue.mask,
stealer_head,
&dest.queue.buffer,
dest.queue.mask,
dest_tail,
transfer_count,
);
}

// Read the last item.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ mod config;
pub mod fifo;
pub mod lifo;
mod loom_exports;
mod transfer;

/// Error returned when stealing is unsuccessful.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
32 changes: 22 additions & 10 deletions src/lifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,16 @@ impl<T> Stealer<T> {
debug_or_loom_assert!(transfer_count <= dest_free_capacity);

// Move all items but the last to the destination queue.
for offset in 0..transfer_count {
unsafe {
let item = self.queue.read_at(old_head.wrapping_add(offset));
dest.queue.write_at(dest_tail.wrapping_add(offset), item);
}
unsafe {
crate::transfer::transfer_items(
&self.queue.buffer,
self.queue.mask,
old_head,
&dest.queue.buffer,
dest.queue.mask,
dest_tail,
transfer_count,
);
}

// Make the moved items visible by updating the destination tail position.
Expand Down Expand Up @@ -732,11 +737,18 @@ impl<T> Stealer<T> {
debug_or_loom_assert!(transfer_count <= dest_free_capacity);

// Move all items but the last to the destination queue.
for offset in 0..transfer_count {
unsafe {
let item = self.queue.read_at(old_head.wrapping_add(offset));
dest.queue.write_at(dest_tail.wrapping_add(offset), item);
}
//
// Safety: see the `steal()` method.
unsafe {
crate::transfer::transfer_items(
&self.queue.buffer,
self.queue.mask,
old_head,
&dest.queue.buffer,
dest.queue.mask,
dest_tail,
transfer_count,
);
}

// Read the last item.
Expand Down
Loading
Loading