Skip to content
Open
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ to a hot path (hashing, storage, snapshots, transfer) should come with a
benchmark, and its numbers in the pull request.

- `just bench`: the divan micro-benchmarks (encoding, store writes,
snapshots, input digests and promotion, landing).
snapshots, input digests and promotion, landing, reading events).
- `just bench-git`: times origin against git on a 20,000-file tree with
hyperfine, and rewrites `docs/benchmarks.md`.

Expand Down
31 changes: 29 additions & 2 deletions apps/origin-src/benches/store.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Store throughput: durable writes with and without batching, verified
//! reads, target appends, and the record index. Run on a real disk: syncs
//! cost nothing on a RAM-backed file system.
//! reads, target appends, the record index, and reading events from the op
//! log. Run on a real disk: syncs cost nothing on a RAM-backed file system.

use std::fs::File;
use std::io;
Expand All @@ -16,6 +16,7 @@ use origin_shared::{
AcceptanceBody, Base, ChangeId, EncodedObject, Kind, NodeKey, Record, RecordId, Revision,
Statement, TargetName, Tree, TreeId, Verdict,
};
use origin_src::events::{Events, Filter};
use origin_src::index::Index;
use origin_src::store::Store;

Expand Down Expand Up @@ -262,3 +263,29 @@ fn rebuild_index(bencher: Bencher<'_, '_>) {
.counter(ItemsCount::new(20_000_usize))
.bench(|| Index::rebuild(&store).unwrap());
}

/// Reading the events of 10k records, each written in its own batch, as
/// issuing statements does: what a subscriber catching up pays.
#[divan::bench(sample_count = 20)]
fn read_events(bencher: Bencher<'_, '_>) {
let (_dir, store) = store_on(NoSync);
for record in records(10_000) {
store.write_all(slice::from_ref(&record)).unwrap();
}
let events = Events::new(&store);
bencher
.counter(ItemsCount::new(10_000_usize))
.bench(|| events.after(0, &Filter::default(), usize::MAX).unwrap());
}

/// Polling for events when there are none, as `watch` does every 50 ms.
#[divan::bench]
fn poll_events(bencher: Bencher<'_, '_>) {
let (_dir, store) = store_on(NoSync);
for record in records(10_000) {
store.write_all(slice::from_ref(&record)).unwrap();
}
let events = Events::new(&store);
let end = events.end().unwrap();
bencher.bench(|| events.after(end, &Filter::default(), usize::MAX).unwrap());
}
Loading