From 4816a2e448619b2b7469441b6daf59094b7ca7af Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 28 Feb 2025 08:10:05 +0100 Subject: [PATCH 1/7] wip --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2333605..124af34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ categories = ["data-structures", "concurrency", "rust-patterns", "no-std"] [dependencies] orx-pseudo-default = { version = "2.0.0", default-features = false } -orx-pinned-vec = "3.15" -orx-fixed-vec = "3.15" -orx-split-vec = "3.15" -orx-pinned-concurrent-col = "2.12" +orx-pinned-vec = { path = "../orx-pinned-vec" } +orx-fixed-vec = { path = "../orx-fixed-vec" } +orx-split-vec = { path = "../orx-split-vec" } +orx-pinned-concurrent-col = { path = "../orx-pinned-concurrent-col" } orx-concurrent-option = "1.4" serde = { version = "1.0.217", optional = true, default-features = false } From b261e2267e5106a07884a84d14c009f2269036c4 Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 4 Apr 2025 22:20:45 +0200 Subject: [PATCH 2/7] constructors fixed for 32bit --- Cargo.toml | 6 +++--- src/new.rs | 2 +- tests/concurrent_read_write.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 124af34..d50b00b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,12 @@ keywords = ["concurrency", "vec", "data-structures", "atomic", "lock-free"] categories = ["data-structures", "concurrency", "rust-patterns", "no-std"] [dependencies] -orx-pseudo-default = { version = "2.0.0", default-features = false } +orx-pseudo-default = { path = "../orx-pseudo-default", default-features = false } orx-pinned-vec = { path = "../orx-pinned-vec" } orx-fixed-vec = { path = "../orx-fixed-vec" } orx-split-vec = { path = "../orx-split-vec" } orx-pinned-concurrent-col = { path = "../orx-pinned-concurrent-col" } -orx-concurrent-option = "1.4" +orx-concurrent-option = { path = "../orx-concurrent-option" } serde = { version = "1.0.217", optional = true, default-features = false } [dev-dependencies] @@ -23,7 +23,7 @@ append-only-vec = "0.1.7" boxcar = "0.2.8" clap = { version = "4.5.28", features = ["derive"] } criterion = "0.5.1" -orx-iterable = "1.2.0" +orx-iterable = { path = "../orx-iterable", default-features = false } rand = "0.9.0" rand_chacha = "0.9.0" rayon = "1.10.0" diff --git a/src/new.rs b/src/new.rs index 02eec97..c71273b 100644 --- a/src/new.rs +++ b/src/new.rs @@ -18,7 +18,7 @@ impl ConcurrentVec, Doubling>> { /// Creates a new concurrent bag by creating and wrapping up a new [`SplitVec`](https://docs.rs/orx-split-vec/latest/orx_split_vec/struct.Doubling.html) as the underlying storage. pub fn with_doubling_growth() -> Self { - Self::new_from_pinned(SplitVec::with_doubling_growth_and_fragments_capacity(32)) + Self::new_from_pinned(SplitVec::with_doubling_growth_and_max_concurrent_capacity()) } } diff --git a/tests/concurrent_read_write.rs b/tests/concurrent_read_write.rs index c4dbce8..a8cc93d 100644 --- a/tests/concurrent_read_write.rs +++ b/tests/concurrent_read_write.rs @@ -218,12 +218,12 @@ where #[cfg(not(miri))] #[test_matrix([500, 1_000, 10_000])] fn concurrent_read_write(num_items_per_thread: usize) { - let pinned = SplitVec::with_doubling_growth_and_fragments_capacity(32); + let pinned = SplitVec::with_doubling_growth_and_max_concurrent_capacity(); spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread); } #[test_matrix([250])] fn miri_concurrent_read_write(num_items_per_thread: usize) { - let pinned = SplitVec::with_doubling_growth_and_fragments_capacity(32); + let pinned = SplitVec::with_doubling_growth_and_max_concurrent_capacity(); spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread); } From dd913304ac4d94d879feab04414c60a404ec4d50 Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 4 Apr 2025 22:23:30 +0200 Subject: [PATCH 3/7] unsafe scopes fixed --- Cargo.toml | 4 ++-- src/concurrent_slice/unsafe_api.rs | 6 +++--- src/unsafe_api.rs | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d50b00b..a56f660 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "orx-concurrent-vec" -version = "3.5.0" -edition = "2021" +version = "4.0.0" +edition = "2024" authors = ["orxfun "] description = "A thread-safe, efficient and lock-free vector allowing concurrent grow, read and update operations." license = "MIT OR Apache-2.0" diff --git a/src/concurrent_slice/unsafe_api.rs b/src/concurrent_slice/unsafe_api.rs index 8b1878e..f4c3308 100644 --- a/src/concurrent_slice/unsafe_api.rs +++ b/src/concurrent_slice/unsafe_api.rs @@ -146,7 +146,7 @@ where /// assert_eq!(averages.len(), 10); /// ``` pub unsafe fn get_ref(&self, i: usize) -> Option<&T> { - self.idx(i).and_then(|i| self.vec.get_ref(i)) + self.idx(i).and_then(|i| unsafe { self.vec.get_ref(i) }) } /// Returns an iterator to references of elements of the vec. @@ -345,7 +345,7 @@ where /// assert_eq!(&vec, &['a', 'x', 'c', 'd']); /// ``` pub unsafe fn get_mut(&self, i: usize) -> Option<&mut T> { - self.idx(i).and_then(|i| self.vec.get_mut(i)) + self.idx(i).and_then(|i| unsafe { self.vec.get_mut(i) }) } /// Returns an iterator to mutable references of elements of the vec. @@ -401,6 +401,6 @@ where pub unsafe fn iter_mut(&self) -> impl Iterator { let b = self.a + self.len; unsafe { self.vec.core.iter_over_range(self.a..b) } - .flat_map(|x| x.0.get_raw_mut().map(|p| &mut *p)) + .flat_map(|x| x.0.get_raw_mut().map(|p| unsafe { &mut *p })) } } diff --git a/src/unsafe_api.rs b/src/unsafe_api.rs index 24c4f29..1392f80 100644 --- a/src/unsafe_api.rs +++ b/src/unsafe_api.rs @@ -158,8 +158,8 @@ where pub unsafe fn get_ref(&self, i: usize) -> Option<&T> { match i < self.reserved_len() { true => { - let maybe = self.core.get(i); - maybe.and_then(|x| x.0.as_ref_with_order(Ordering::SeqCst)) + let maybe = unsafe { self.core.get(i) }; + maybe.and_then(|x| unsafe { x.0.as_ref_with_order(Ordering::SeqCst) }) } false => None, } @@ -269,7 +269,7 @@ where /// assert_eq!(averages.len(), 10); /// ``` pub unsafe fn iter_ref(&self) -> impl Iterator { - let x = self.core.iter(self.reserved_len()); + let x = unsafe { self.core.iter(self.reserved_len()) }; x.flat_map(|x| unsafe { x.0.as_ref_with_order(Ordering::SeqCst) }) } @@ -363,8 +363,8 @@ where pub unsafe fn get_mut(&self, i: usize) -> Option<&mut T> { match i < self.reserved_len() { true => { - let elem = self.core.get(i); - elem.and_then(|option| option.0.get_raw_mut().map(|p| &mut *p)) + let elem = unsafe { self.core.get(i) }; + elem.and_then(|option| option.0.get_raw_mut().map(|p| unsafe { &mut *p })) } false => None, } @@ -419,7 +419,7 @@ where /// assert_eq!(&vec, &[0, 2, 4, 6]); /// ``` pub unsafe fn iter_mut(&self) -> impl Iterator { - let x = self.core.iter(self.reserved_len()); - x.flat_map(|x| x.0.get_raw_mut().map(|p| &mut *p)) + let x = unsafe { self.core.iter(self.reserved_len()) }; + x.flat_map(|x| x.0.get_raw_mut().map(|p| unsafe { &mut *p })) } } From d77272269af35044fb3c4c6bc5329d019df79761 Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 11 Apr 2025 16:17:24 +0200 Subject: [PATCH 4/7] dependencies upgraded --- Cargo.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a56f660..4462d95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orx-concurrent-vec" -version = "4.0.0" +version = "3.6.0" edition = "2024" authors = ["orxfun "] description = "A thread-safe, efficient and lock-free vector allowing concurrent grow, read and update operations." @@ -10,24 +10,24 @@ keywords = ["concurrency", "vec", "data-structures", "atomic", "lock-free"] categories = ["data-structures", "concurrency", "rust-patterns", "no-std"] [dependencies] -orx-pseudo-default = { path = "../orx-pseudo-default", default-features = false } -orx-pinned-vec = { path = "../orx-pinned-vec" } -orx-fixed-vec = { path = "../orx-fixed-vec" } -orx-split-vec = { path = "../orx-split-vec" } -orx-pinned-concurrent-col = { path = "../orx-pinned-concurrent-col" } -orx-concurrent-option = { path = "../orx-concurrent-option" } -serde = { version = "1.0.217", optional = true, default-features = false } +orx-pseudo-default = { version = "2.1.0", default-features = false } +orx-pinned-vec = "3.16.0" +orx-fixed-vec = "3.16.0" +orx-split-vec = "3.16.0" +orx-pinned-concurrent-col = "2.13.0" +orx-concurrent-option = "1.5.0" +serde = { version = "1.0.219", optional = true, default-features = false } [dev-dependencies] append-only-vec = "0.1.7" -boxcar = "0.2.8" -clap = { version = "4.5.28", features = ["derive"] } +boxcar = "0.2.11" +clap = { version = "4.5.35", features = ["derive"] } criterion = "0.5.1" -orx-iterable = { path = "../orx-iterable", default-features = false } +orx-iterable = { version = "1.3.4", default-features = false } rand = "0.9.0" rand_chacha = "0.9.0" rayon = "1.10.0" -serde_json = { version = "1.0.138", default-features = false, features = [ +serde_json = { version = "1.0.140", default-features = false, features = [ "std", ] } test-case = "3.3.1" From 5dae48e8e54a7550a29c7393fdc31bbfac6c5a1e Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 11 Apr 2025 16:19:29 +0200 Subject: [PATCH 5/7] Create ci.yml --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9804dee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: Rust + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: ["stable"] + features: ["", "--features serde"] + + steps: + - uses: actions/checkout@v4 + + - name: Install toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + + - name: Install 32bit target + run: rustup target add i686-unknown-linux-musl + - name: Install wasm target + run: rustup target add wasm32v1-none + - name: Install miri + run: rustup component add --toolchain nightly-x86_64-unknown-linux-gnu miri + - name: Install no-std-check + run: cargo install cargo-no-std-check + + - name: Build + run: cargo build --verbose ${{ matrix.features }} + - name: Build-32bit + run: cargo build --verbose --target i686-unknown-linux-musl ${{ matrix.features }} + - name: Build-wasm + run: cargo build --verbose --target wasm32v1-none ${{ matrix.features }} + + - name: Test + run: cargo test --verbose ${{ matrix.features }} + - name: Test-32bit + run: cargo test --verbose --target i686-unknown-linux-musl ${{ matrix.features }} + - name: Check-wasm + run: cargo check --verbose --target wasm32v1-none ${{ matrix.features }} + + - name: Clippy + run: cargo clippy ${{ matrix.features }} -- -D warnings --verbose + + - name: Miri + run: cargo +nightly miri test --verbose ${{ matrix.features }} + + - name: NoStd + run: cargo +nightly no-std-check ${{ matrix.features }} From cecaa8380cedf47197350ba8fb1cdd34fa2b9085 Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 11 Apr 2025 16:21:15 +0200 Subject: [PATCH 6/7] dependency version fixed --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4462d95..503133b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ append-only-vec = "0.1.7" boxcar = "0.2.11" clap = { version = "4.5.35", features = ["derive"] } criterion = "0.5.1" -orx-iterable = { version = "1.3.4", default-features = false } +orx-iterable = { version = "1.3.0", default-features = false } rand = "0.9.0" rand_chacha = "0.9.0" rayon = "1.10.0" From 3408f789de5664d7b73a8440d104bedde9934b39 Mon Sep 17 00:00:00 2001 From: orxfun Date: Fri, 11 Apr 2025 16:26:42 +0200 Subject: [PATCH 7/7] miri tests shortened --- tests/concurrent_read_write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/concurrent_read_write.rs b/tests/concurrent_read_write.rs index a8cc93d..6391594 100644 --- a/tests/concurrent_read_write.rs +++ b/tests/concurrent_read_write.rs @@ -222,7 +222,7 @@ fn concurrent_read_write(num_items_per_thread: usize) { spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread); } -#[test_matrix([250])] +#[test_matrix([100])] fn miri_concurrent_read_write(num_items_per_thread: usize) { let pinned = SplitVec::with_doubling_growth_and_max_concurrent_capacity(); spawn(pinned, NUM_GROWERS, NUM_USERS, num_items_per_thread);