8000 docs: simplify Python benchmark notes and comments by adityamukho · Pull Request #30 · project-minigraf/minigraf-python · GitHub
[go: up one dir, main page]

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
25 changes: 13 additions & 12 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ maturin develop --release
target/bench-venv/bin/python bench/nightly.py --test
```

`--test` invokes each operation exactly once, checks fixed answers and reads
no timer. Omit it only in GitHub Actions to collect median latency (nanoseconds)
With `--test`, the script runs each operation once and checks the expected result
without timing it. Omit it only in GitHub Actions to collect median latency (nanoseconds)
in `binding-results.json`. Do not run timed cases on a developer laptop or
on the occupied benchmark machine.

Expand All @@ -23,14 +23,15 @@ IDs use `binding/python/` and the six suffixes
`set_roundtrip/2`, `predicate/1k`, `aggregate/1k`.

Fixtures contain 1,000 deterministic integer facts and one two-element set.
Setup, prepare, registration and correctness checks are outside measurement;
foreign result decoding and cursor close are included. Set binding containers
are created per call. Callbacks are implemented in this host language.
Timing excludes setup, query preparation, function registration, and result checks.
It includes decoding results and closing cursors. Each call that takes a set creates
a new one. The callbacks run in Python.

Routing, build provenance, dedicated Bencher testbeds, provisional 5–15 minute
allowance plus setup per job, and manual coverage dispositions are documented
in [the core binding benchmark guide](https://github.com/project-minigraf/minigraf/blob/v3/docs/BINDING_BENCHMARKS.md).
The core `bindings` matrix builds this shim against the measured core SHA
using a temporary Cargo patch; this repository's production dependency pin is
unchanged. Land this PR before the core workflow PRs. Phase B performs the
serial workflow dispatch and upload/history validation.
The [core binding benchmark guide](https://github.com/project-minigraf/minigraf/blob/main/docs/BINDING_BENCHMARKS.md) lists which jobs run where, how each build records and verifies
its source commit, the dedicated Bencher testbeds, and cases that are tested
only by hand. Each job allows a provisional 5–15 minutes plus setup. The
core `bindings` matrix uses a temporary Cargo patch to build this binding against
the core commit it measures, without changing the dependency in this repository.
In the original rollout, the Python binding PR needed to land before the core
workflow PRs. Phase B called for dispatching the core jobs one at a time, then
checking the uploaded measurements and their benchmark history.
2 changes: 1 addition & 1 deletion bench/envelope.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""FFI round trip for the performance envelope (minigraf#394).
"""Wall time and peak memory for core benchmark queries run through Python (minigraf#394).

Runs the query shapes of the core harness (`examples/perf_envelope.rs` in
minigraf) through this binding: `db.query(...)` drained with `next_batch(1000)`,
Expand Down
19 changes: 9 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ pub struct OpenOptions {
/// limit, the default.
#[uniffi(default)]
pub query_memory_limit: Option<i64>,
/// The query keywords query text may use to override these settings.
/// Absent: `overridable_defaults()`. A list replaces the defaults; an
/// empty one refuses every override keyword (API-025).
/// Settings that query text may override. If omitted, use `overridable_defaults()`.
/// A list replaces the defaults. An empty list rejects every override (API-025).
#[uniffi(default)]
pub allow_overrides: Option<Vec<Overridable>>,
/// Facts one transaction stages before a file database writes them in
Expand Down Expand Up @@ -592,7 +591,7 @@ impl MiniGrafDb {

/// Register `predicate` under `name`, called in Datalog as
/// `[(name ?v)]`. A predicate that throws stops the query with QRY-014.
/// Queries already open keep the functions they opened with.
/// Open queries do not see functions registered later.
pub fn register_predicate(
&self,
name: String,
Expand Down Expand Up @@ -727,8 +726,8 @@ impl MiniGrafPreparedQuery {

/// A new prepared query that may derive at most `n` facts; this one is
/// unchanged. An allowed `:max-derived-facts` or `:max-results` in the
/// query still overrides it. `i64::MAX` means no limit; negative is
/// API-017. Not gated by `OpenOptions.allow_overrides`.
/// query still overrides it. `i64::MAX` means no limit. Negative values return
/// API-017. `OpenOptions.allow_overrides` does not restrict this method.
pub fn with_max_derived_facts(
&self,
n: i64,
Expand Down Expand Up @@ -2356,7 +2355,7 @@ mod tests {
#[test]
fn prepared_setters_derive_new_queries() {
let dir = temp_dir("setters");
// The setters are not gated: every override keyword is refused here.
// The setters work even when all overrides in query text are disabled.
let db = reach_db(&dir, "setters", with_overrides(Some(vec![])));
let none = HashMap::new;
let pq = db.prepare(REACH.into()).expect("prepare");
Expand All @@ -2369,7 +2368,7 @@ mod tests {
assert_eq!(code_of(derived.execute(none())), "INT-020");
assert_eq!(code_of(derived.query(none())), "INT-020");
}
// Deriving did not disturb a cursor open on the receiver.
// Changing the limit on the new prepared query leaves the original cursor unchanged.
while let Some(batch) = cursor.next_batch(3).expect("batch") {
cursor_rows += serde_json::from_str::<Vec<serde_json::Value>>(&batch)
.expect("rows")
Expand Down Expand Up @@ -2564,8 +2563,8 @@ mod tests {
tx.rollback().expect("rollback does nothing");
}

// A commit that fails finishes the transaction: a valid-time window
// still ahead when staged has ended at the commit time (API-019).
// The valid-time window ends between staging and commit.
// Commit returns API-019 and closes the transaction.
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.expect("time")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_log_writer_takes_the_new_options(tmp_path):
],
)
def test_setter_derives_a_new_query(tmp_path, setter, n, query, fails):
# The setters are not gated: every override keyword is refused here.
# The setters work even when all overrides in query text are disabled.
db = reach_db(tmp_path, allow_overrides=[])
pq = db.prepare(query)
before = rows(pq.execute())
Expand Down
Loading
0