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
33 changes: 33 additions & 0 deletions crates/ragfs-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,9 @@ fn extract_optional_owned_lease_ref(
/// Convert a PathLockHandoffRef to a Python dict.
fn handoff_ref_to_py_dict(py: Python<'_>, handoff: &PathLockHandoffRef) -> PyResult<Py<PyAny>> {
let dict = PyDict::new(py);
if let Some(holder_id) = &handoff.holder_id {
dict.set_item("holder_id", holder_id)?;
}
if let Some(lease_ref) = &handoff.lease_ref {
dict.set_item("lease_ref", lease_ref)?;
}
Expand Down Expand Up @@ -2936,6 +2939,32 @@ impl RAGFSBindingClient {
})
}

/// Reacquire validated durable coverage under its original logical owner.
#[pyo3(signature = (ctx, requests, owner_id, timeout_secs=0.0))]
fn pathlock_reacquire_batch_async<'py>(
&self,
py: Python<'py>,
ctx: Option<HashMap<String, String>>,
requests: Vec<HashMap<String, String>>,
owner_id: String,
timeout_secs: f64,
) -> PyResult<Bound<'py, PyAny>> {
let fs_ctx = build_fs_context(ctx);
let timeout = validate_timeout_secs(timeout_secs)?;
let requests = parse_pathlock_request_batch(&requests)?;
let manager = self.clone_pathlock_manager();
let task = self.rt.spawn(FS_CTX.scope(fs_ctx, async move {
manager.reacquire_batch(&requests, &owner_id, timeout).await
}));
pyo3_async_runtimes::tokio::future_into_py(py, async move {
let lease = task
.await
.map_err(|error| PyRuntimeError::new_err(error.to_string()))?
.map_err(pathlock_err_to_py)?;
Python::attach(|py| owned_lease_to_py_dict(py, &lease))
})
}

/// Create a borrowed view of an owned lease.
#[pyo3(signature = (ctx, owned_lease_ref))]
fn pathlock_as_borrowed(
Expand Down Expand Up @@ -3176,6 +3205,10 @@ impl RAGFSBindingClient {
})
.transpose()?;
let handoff = PathLockHandoffRef {
holder_id: handoff_ref
.get("holder_id")
.map(|v| v.extract(py))
.transpose()?,
lease_ref,
handle_mode,
owner_id,
Expand Down
21 changes: 21 additions & 0 deletions crates/ragfs/benches/pathlock_perf.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# PathLock performance baselines

Holder-lease comparison on 2026-11-01 (macOS arm64, release native binding,
Python 3.13, local Redis, 200 unrelated live locks in the same namespace).
Each provider used a fresh local workspace, 10 warmup cycles and 300 measured
Exact/Tree acquire cycles; release pooled both kinds (600 samples). The comparison
base was `main` at `f423d8e72`. Times include the synchronous Python binding.

| Provider | Exact acquire P50, µs (main → holders) | Tree acquire P50, µs | Release P50, µs |
| --- | --- | --- | --- |
| Memory | 29.3 → 5.2 | 30.8 → 5.5 | 1.5 → 1.5 |
| Filesystem on local disk | 1975.5 → 1849.6 | 2050.8 → 1931.0 | 329.7 → 334.4 |
| SQLite on local disk | 82.2 → 66.1 | 88.2 → 67.8 | 54.1 → 54.7 |
| Redis | 138.2 → 121.0 | 490.4 → 258.4 | 230.5 → 206.7 |

Filesystem acquire P95 varied (Exact: 3060.6 → 3581.4 µs, Tree:
3256.5 → 3506.3 µs); this small local sample does not establish tail-latency
equivalence. No acquisition or release failed. Holder adoption performs a storage
mutation even locally; its cost is no longer comparable to main's registry-only
local adoption. Redis Tree acquisition still scans HASH fields, although unrelated
holder decoding/cleanup is bounded. Run the concurrency benchmark below for
database writer contention and multi-process behavior.

Run from the repository root:

```sh
Expand Down
Loading
Loading