Skip to content

Commit 2ce7155

Browse files
authored
Merge pull request #5 from Milerius/feat/spsc-ring-buffer
feat: SPSC ring buffer with copy-optimized SIMD variant
2 parents b737df3 + 6f6f270 commit 2ce7155

64 files changed

Lines changed: 13155 additions & 99 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.cargo/config.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Enable native CPU features for benchmarks (NEON on aarch64, SSE2/AVX on x86_64).
2+
# This is a local config — CI overrides via RUSTFLAGS if needed.
3+
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))']
4+
rustflags = ["-C", "target-cpu=native"]

‎.config/nextest.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[profile.ci]
2+
default-filter = "all()"
3+
4+
[profile.ci.junit]
5+
path = "junit.xml"

‎.github/workflows/bench.yml‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,43 @@ env:
99

1010
jobs:
1111
benchmark:
12-
name: Benchmark Regression
13-
runs-on: ubuntu-latest
12+
name: Benchmark (${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
permissions:
18+
contents: write
19+
pull-requests: write
1420
steps:
1521
- name: Checkout PR
1622
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1723
with:
1824
persist-credentials: false
19-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
25+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
2026
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
21-
- name: Run benchmarks
22-
run: cargo bench --all-features -- --output-format bencher | tee bench-output.txt
27+
- name: Run SPSC benchmarks
28+
run: cargo +nightly bench --bench spsc --all-features
29+
- name: Convert report for CI tracking
30+
run: |
31+
jq '[.results[] | {name: .workload, unit: "ns/op", value: .ns_per_op}]' \
32+
target/bench-report-spsc.json > bench-output.json
33+
- name: Store benchmark result
34+
uses: benchmark-action/github-action-benchmark@a7bc2366eda11037936ea57d811a43b3418d3073 # v1.21.0
35+
with:
36+
name: SPSC Ring Benchmarks (${{ matrix.os }})
37+
tool: customSmallerIsBetter
38+
output-file-path: bench-output.json
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
auto-push: false
41+
alert-threshold: "105%"
42+
comment-on-alert: true
43+
fail-on-alert: true
44+
alert-comment-cc-users: "@mantis-maintainers"
2345
- name: Upload benchmark results
2446
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
2547
with:
26-
name: benchmark-results
27-
path: bench-output.txt
28-
# TODO: Add baseline comparison (bench-baseline, bench-candidate,
29-
# bench-contenders, bench-report jobs) when SPSC ring benchmarks exist.
48+
name: benchmark-results-${{ matrix.os }}
49+
path: |
50+
target/bench-report-spsc.json
51+
bench-output.json

‎.github/workflows/ci.yml‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: [main]
88

9+
permissions:
10+
checks: write
11+
contents: read
12+
913
env:
1014
CARGO_TERM_COLOR: always
1115
RUSTFLAGS: -Dwarnings
@@ -18,10 +22,10 @@ jobs:
1822
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1923
with:
2024
persist-credentials: false
21-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
25+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
2226
with:
2327
components: rustfmt
24-
- run: cargo fmt --all --check
28+
- run: cargo +nightly fmt --all --check
2529

2630
clippy:
2731
name: Clippy (${{ matrix.os }})
@@ -33,11 +37,11 @@ jobs:
3337
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3438
with:
3539
persist-credentials: false
36-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
40+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
3741
with:
3842
components: clippy
3943
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
40-
- run: cargo clippy --all-targets --all-features -- -D warnings
44+
- run: cargo +nightly clippy --all-targets --all-features -- -D warnings
4145

4246
test:
4347
name: Test (${{ matrix.os }})
@@ -49,9 +53,25 @@ jobs:
4953
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5054
with:
5155
persist-credentials: false
52-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
56+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
5357
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
54-
- run: cargo test --all-features
58+
- name: Install nextest
59+
uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2
60+
with:
61+
tool: cargo-nextest
62+
- name: Run tests
63+
run: cargo +nightly nextest run --all-features --profile ci
64+
- name: Test Report
65+
uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
66+
if: success() || failure()
67+
with:
68+
name: Rust Tests (${{ matrix.os }})
69+
path: target/nextest/ci/junit.xml
70+
reporter: java-junit
71+
- name: Test with ASM feature
72+
run: cargo +nightly test --features asm
73+
- name: Test without ASM (portable fallback)
74+
run: cargo +nightly test --no-default-features -p mantis-queue -p mantis-core -p mantis-types
5575

5676
test-no-std:
5777
name: Test no_std (${{ matrix.os }})
@@ -63,9 +83,9 @@ jobs:
6383
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
6484
with:
6585
persist-credentials: false
66-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
86+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
6787
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
68-
- run: cargo test -p mantis-core -p mantis-types -p mantis-queue --no-default-features
88+
- run: cargo +nightly test -p mantis-core -p mantis-types -p mantis-queue --no-default-features
6989

7090
doc:
7191
name: Documentation
@@ -74,9 +94,9 @@ jobs:
7494
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
7595
with:
7696
persist-credentials: false
77-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
97+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
7898
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
79-
- run: cargo doc --no-deps --all-features
99+
- run: cargo +nightly doc --no-deps --all-features
80100
env:
81101
RUSTDOCFLAGS: -Dwarnings
82102

@@ -139,7 +159,14 @@ jobs:
139159
run: cargo +nightly llvm-cov --all-features --codecov --output-path codecov.json
140160
- name: Branch coverage
141161
run: cargo +nightly llvm-cov --all-features --branch --lcov --output-path lcov-branch.info
142-
- name: Upload coverage
162+
- name: Upload to Codecov
163+
if: github.event_name == 'pull_request'
164+
uses: codecov/codecov-action@1af58845a975a7985b0beb0cbe6fbbb71a41dbad # v5.5.3
165+
with:
166+
files: codecov.json
167+
token: ${{ secrets.CODECOV_TOKEN }}
168+
fail_ci_if_error: false
169+
- name: Upload coverage artifacts
143170
if: github.event_name == 'pull_request'
144171
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
145172
with:

‎.github/workflows/nightly.yml‎

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
1717
with:
1818
persist-credentials: false
19-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
19+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
2020
- uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2
2121
with:
2222
tool: cargo-mutants
2323
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
24-
- run: cargo mutants --timeout 60 -- --all-features
24+
- run: cargo +nightly mutants --timeout 60 -- --all-features
2525
continue-on-error: true
2626
- name: Upload mutants report
2727
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
@@ -56,14 +56,14 @@ jobs:
5656
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5757
with:
5858
persist-credentials: false
59-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
59+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
6060
with:
6161
components: llvm-tools-preview
6262
- uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2
6363
with:
6464
tool: cargo-llvm-cov
6565
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
66-
- run: cargo llvm-cov --all-features --branch --html
66+
- run: cargo +nightly llvm-cov --all-features --branch --html
6767
- name: Upload coverage report
6868
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
6969
with:
@@ -80,11 +80,86 @@ jobs:
8080
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
8181
with:
8282
persist-credentials: false
83-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
83+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
8484
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
8585
- name: Test with default features
86-
run: cargo test --all-features
86+
run: cargo +nightly test --all-features
8787
- name: Test with no default features
88-
run: cargo test -p mantis-core -p mantis-types -p mantis-queue --no-default-features
88+
run: cargo +nightly test -p mantis-core -p mantis-types -p mantis-queue --no-default-features
89+
- name: Install cargo-show-asm
90+
uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2
91+
with:
92+
tool: cargo-show-asm
93+
- name: Run ASM inspection
94+
run: ./scripts/check-asm.sh
95+
- name: Upload ASM artifacts
96+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
97+
with:
98+
name: asm-output-${{ matrix.os }}
99+
path: target/asm/
100+
retention-days: 30
101+
102+
kani:
103+
name: Kani Proofs
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
107+
with:
108+
persist-credentials: false
109+
- name: Install Kani
110+
run: |
111+
cargo install --locked kani-verifier
112+
cargo kani setup
113+
- name: Run proofs
114+
run: cargo kani -p mantis-verify 2>&1 | tee kani-output.txt
115+
- name: Kani Summary
116+
if: always()
117+
run: |
118+
echo "## Kani Proof Results" >> "$GITHUB_STEP_SUMMARY"
119+
grep -E "(VERIFIED|FAILED|harness)" kani-output.txt >> "$GITHUB_STEP_SUMMARY" || true
120+
- name: Upload proof output
121+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
122+
if: always()
123+
with:
124+
name: kani-proofs
125+
path: kani-output.txt
89126

90-
# TODO: Add fuzz, bench-matrix, fuzz-coverage jobs when SPSC ring exists.
127+
fuzz:
128+
name: Fuzz Testing
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
132+
with:
133+
persist-credentials: false
134+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
135+
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
136+
- name: Install cargo-fuzz
137+
uses: taiki-e/install-action@328a871ad8f62ecac78390391f463ccabc974b72 # v2
138+
with:
139+
tool: cargo-fuzz
140+
- name: Run fuzz targets
141+
run: |
142+
for target in $(cargo +nightly fuzz list 2>/dev/null || true); do
143+
echo "Fuzzing: $target (10 min)"
144+
cargo +nightly fuzz run "$target" -- -max_total_time=600 || true
145+
done
146+
continue-on-error: true
147+
- name: Upload corpus
148+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
149+
if: always()
150+
with:
151+
name: fuzz-corpus
152+
path: fuzz/corpus/
153+
retention-days: 90
154+
- name: Upload crashes
155+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
156+
if: failure()
157+
with:
158+
name: fuzz-crashes
159+
path: fuzz/artifacts/
160+
- name: Fuzz Summary
161+
if: always()
162+
run: |
163+
echo "## Fuzz Results" >> "$GITHUB_STEP_SUMMARY"
164+
echo "Duration: 10 minutes per target" >> "$GITHUB_STEP_SUMMARY"
165+
echo "Corpus size: $(find fuzz/corpus -type f 2>/dev/null | wc -l) inputs" >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/verify.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
3434
with:
3535
persist-credentials: false
36-
- uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 # stable
36+
- uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f # nightly
3737
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
3838
- name: Run property tests
39-
run: cargo test -p mantis-verify --all-features -- --test-threads=1
39+
run: cargo +nightly test -p mantis-verify --all-features -- --test-threads=1

‎CLAUDE.md‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
## Quick Reference
44

55
```
6-
Build: cargo build --all-features
7-
Test: cargo test --all-features
6+
Build: cargo build --features alloc,std
7+
Build nightly: cargo +nightly build --all-features
8+
Test: cargo test --features alloc,std
9+
Test nightly: cargo +nightly test --all-features
810
Test no_std: cargo test -p mantis-core -p mantis-types -p mantis-queue --no-default-features
9-
Lint: cargo clippy --all-targets --all-features -- -D warnings
11+
Lint: cargo clippy --all-targets --features alloc,std -- -D warnings
12+
Lint nightly: cargo +nightly clippy --all-targets --all-features -- -D warnings
1013
Format: cargo fmt --all
1114
Format check: cargo fmt --all --check
1215
Deny: cargo deny check
1316
Miri: cargo +nightly miri test -p mantis-queue
1417
Careful: cargo +nightly careful test
15-
Bench: cargo bench
16-
Bench + ext: cargo bench --features bench-contenders
18+
Bench: cargo bench --bench spsc
19+
Bench + ext: cargo bench --bench spsc --features bench-contenders
1720
Fuzz: cargo +nightly fuzz run <target>
1821
Layout: cargo run -p mantis-layout
1922
Kani: cargo kani -p mantis-verify
@@ -25,6 +28,15 @@ Coverage: cargo llvm-cov --all-features
2528
See `philosophy/fin_sdk_oss_blueprint.md` for full SDK vision.
2629
See `philosophy/benchmark_tooling_modular_strategy_design.md` for container strategy.
2730
See `.claude/memory/constantine-reference.md` for reference architecture patterns.
31+
See `docs/PROGRESS.md` for current project status and phase tracking.
32+
33+
## Progress Tracking
34+
35+
**Update `docs/PROGRESS.md` after completing meaningful work:**
36+
- Check off completed items
37+
- Update the crate status table (test counts, benchmark status, verification status)
38+
- Move phase status from "Not Started" to "In Progress" / "Complete" with dates
39+
- Add new sub-items if scope is discovered during implementation
2840

2941
## Workspace Layout
3042

‎Cargo.lock‎

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)