Repository navigation
bench: investigate repeatability of tiny Signal session measurements #1655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6b9143
bench: diagnose session fixture repeatability through CodSpeed CI
jlucaso1 f36956d
bench: record fixed diagnostic source and runner metadata
jlucaso1 6ab8ad5
bench: measure session helpers across 32 independent records
jlucaso1 308c204
bench: retain original cases and slowdown controls during validation
jlucaso1 ba86132
bench: test isolated session helpers and successive updates
jlucaso1 4c6b11f
bench: preserve cold-call controls in unfiltered isolated targets
jlucaso1 35c60b9
ci: match diagnostic source and build graph to normal benchmarks
jlucaso1 4667b45
ci: bound R03 original-session walltime validation to fixed revisions
jlucaso1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime base 1 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: f1080df166bbc2c88e762eda6eb5bb7f6efc2f05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime head 1 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: c42dd44c59acff7825eae7d09e940a08c71d91a2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime base 2 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: f1080df166bbc2c88e762eda6eb5bb7f6efc2f05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime head 2 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: c42dd44c59acff7825eae7d09e940a08c71d91a2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime base 3 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: f1080df166bbc2c88e762eda6eb5bb7f6efc2f05 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: R03 original session walltime head 3 | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| if: >- | ||
| github.head_ref == 'bench/session-repeatability' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.label.name == 'r03-walltime-fixed-revisions' | ||
| uses: ./.github/workflows/codspeed-repeatability-run.yml | ||
| with: | ||
| source-revision: c42dd44c59acff7825eae7d09e940a08c71d91a2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Fixed-revision original session walltime | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| source-revision: | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: never | ||
| PROTOC_VERSION: "3.25.3" | ||
| MALLOC_ARENA_MAX: "1" | ||
| MALLOC_MMAP_THRESHOLD_: "131072" | ||
| MALLOC_TRIM_THRESHOLD_: "131072" | ||
| MALLOC_TOP_PAD_: "131072" | ||
|
|
||
| jobs: | ||
| diagnostic: | ||
| # Only the two reviewed same-repository revisions may execute with OIDC. | ||
| if: >- | ||
| github.repository == 'oxidezap/whatsapp-rust' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| (inputs.source-revision == 'f1080df166bbc2c88e762eda6eb5bb7f6efc2f05' || | ||
| inputs.source-revision == 'c42dd44c59acff7825eae7d09e940a08c71d91a2') | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 25 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| repository: oxidezap/whatsapp-rust | ||
| ref: ${{ inputs.source-revision }} | ||
| persist-credentials: false | ||
| - uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: nightly-2026-06-16 | ||
| - name: Key libc debug cache | ||
| id: libc6 | ||
| run: cargo xt ci workflow libc-version | ||
| - uses: actions/cache@v6 | ||
| with: | ||
| path: ~/.cache/libc6-dbg | ||
| key: libc6-dbg-${{ runner.arch }}-${{ steps.libc6.outputs.version }} | ||
| - name: Install libc debug symbols | ||
| env: | ||
| LIBC6_VERSION: ${{ steps.libc6.outputs.version }} | ||
| run: cargo xt ci workflow install-libc-debug | ||
| - uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: protoc@${{ env.PROTOC_VERSION }},cargo-codspeed@5.0.1 | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| prefix-key: Linux-cargo-codspeed-repeatability | ||
| cache-targets: "false" | ||
| - name: Build diagnostic targets | ||
| # Match the normal proto-signal shard's dependency feature unification. | ||
| run: > | ||
| cargo codspeed build -m walltime | ||
| -p wacore-binary -p wacore-libsignal -p wacore-appstate | ||
| -p whatsapp-rust-sqlite-storage | ||
| - name: Record fixed source and toolchain | ||
| run: | | ||
| git rev-parse HEAD | ||
| sha256sum Cargo.lock wacore/libsignal/benches/libsignal_benchmark.rs | ||
| find target/codspeed -maxdepth 3 -type f -executable -exec sha256sum {} + | ||
| rustc -Vv | ||
| ldd --version | ||
| lscpu | ||
| # CodSpeed's run is attached to this diagnostic PR. The recorded checkout | ||
| # above, not that PR's head label, identifies the source being measured. | ||
| - name: Measure only original self and non-self session cases | ||
| uses: CodSpeedHQ/action@v5 | ||
| with: | ||
| runner-version: 5.4.0 | ||
| mode: walltime | ||
| run: cargo codspeed run -p wacore-libsignal --bench libsignal_benchmark 'bench_session_with_self' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| use divan::black_box; | ||
| use wacore_libsignal::protocol::{IdentityKey, KeyPair, RootKey, SessionState}; | ||
|
|
||
| #[path = "support/session_fixture.rs"] | ||
| mod session_fixture; | ||
|
|
||
| fn main() { | ||
| divan::main(); | ||
| } | ||
|
|
||
| // Retain the original single-call workload while testing process isolation. | ||
| #[divan::bench(args = [false, true])] | ||
| fn bench_session_with_self(bencher: divan::Bencher, is_self: bool) { | ||
| bencher | ||
| .with_inputs(|| { | ||
| let mut rng = <rand::rngs::StdRng as rand::SeedableRng>::seed_from_u64(0x5345_4c46); | ||
| let local = IdentityKey::new(KeyPair::generate(&mut rng).public_key); | ||
| let remote = if is_self { | ||
| local | ||
| } else { | ||
| IdentityKey::new(KeyPair::generate(&mut rng).public_key) | ||
| }; | ||
| SessionState::new( | ||
| 3, | ||
| &local, | ||
| &remote, | ||
| &RootKey::new([0x11; 32]), | ||
| local.public_key(), | ||
| ) | ||
| }) | ||
| .bench_refs(|state| black_box(state.session_with_self().expect("identities"))); | ||
| } | ||
|
|
||
| // A separate binary removes unrelated benchmark code and allocator history. | ||
| // The original cold-call cases remain in libsignal_benchmark. | ||
| #[divan::bench(args = [(false, 1), (true, 1), (false, 2), (true, 2)])] | ||
| fn independent_sessions_32(bencher: divan::Bencher, (is_self, passes): (bool, usize)) { | ||
| bencher | ||
| .with_inputs(|| session_fixture::sessions(32, is_self)) | ||
| .bench_refs(|states| { | ||
| for _ in 0..passes { | ||
| for state in states.iter() { | ||
| black_box(black_box(state).session_with_self().expect("identities")); | ||
| } | ||
| } | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| use divan::black_box; | ||
| use wacore_libsignal::protocol::{IdentityKey, KeyPair, RootKey, SessionState}; | ||
|
|
||
| #[path = "support/session_fixture.rs"] | ||
| mod session_fixture; | ||
|
|
||
| fn main() { | ||
| divan::main(); | ||
| } | ||
|
|
||
| // Retain the original single-call workload while testing process isolation. | ||
| #[divan::bench] | ||
| fn bench_session_root_key_update(bencher: divan::Bencher) { | ||
| bencher | ||
| .with_inputs(|| { | ||
| let mut rng = <rand::rngs::StdRng as rand::SeedableRng>::seed_from_u64(0x524f_4f54); | ||
| let local = IdentityKey::new(KeyPair::generate(&mut rng).public_key); | ||
| SessionState::new( | ||
| 3, | ||
| &local, | ||
| &local, | ||
| &RootKey::new([0x11; 32]), | ||
| local.public_key(), | ||
| ) | ||
| }) | ||
| .bench_refs(|state| { | ||
| state.set_root_key(black_box(&RootKey::new([0x22; 32]))); | ||
| black_box(&*state); | ||
| }); | ||
| } | ||
|
|
||
| // One pass preserves the independent-record experiment. Thirty-two passes | ||
| // separately measure successive updates on resident sessions; neither replaces | ||
| // the original cold-call case. Doubling passes is an explicit slowdown control. | ||
| #[divan::bench(args = [1, 2, 32, 64])] | ||
| fn successive_updates_32_sessions(bencher: divan::Bencher, passes: usize) { | ||
| bencher | ||
| .with_inputs(|| session_fixture::sessions(32, true)) | ||
| .bench_refs(|states| { | ||
| for pass in 0..passes { | ||
| let key = RootKey::new([0x22 + pass as u8; 32]); | ||
| for state in states.iter_mut() { | ||
| black_box(&mut *state).set_root_key(black_box(&key)); | ||
| black_box(&*state); | ||
| } | ||
| } | ||
| }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.