langgraph/libs/checkpoint-postgres/tests
Elior Nataf Lackritz 3183e90eca
perf(checkpoint-postgres): run a lone store read outside a pipeline (#9635)
`PostgresStore` and `AsyncPostgresStore` always ran a batch inside a
pipeline. For a read that costs two round trips: fetching the result
forces one, and leaving the pipeline sends a Sync and waits for a
second. `store.get()`, `store.search()` and `store.list_namespaces()`
are batches of one read, so each paid two round trips, which is why a
`get` took longer than a `put`.

A batch of exactly one read now runs outside the pipeline, in one round
trip. Batches with several ops or any write still use the pipeline, and
so does a store opened with `pipeline=True`. In the sync store the
non-pipeline cursor now takes the store's lock, as every batch already
did through the pipeline branch, so a lone read never uses a shared
connection while another thread has it in a pipeline. That also covers
`sweep_ttl`, which went through that branch without the lock.

Median of four alternating rounds on main and on this branch, Python
3.14, Postgres 15 in local Docker:

| workload | main | this PR | speedup |
|---|---|---|---|
| round trips for 200 `get` calls, counted with a TCP proxy | 400 | 200
| 2x |
| 200 `PostgresStore.get` | 85.2 ms | 47.8 ms | 1.78x |
| 50 `PostgresStore.search` | 25.7 ms | 16.6 ms | 1.55x |
| 200 `AsyncPostgresStore.aget`, one after another | 103 ms | 59.5 ms |
1.73x |
| the same 200 `get` with 0.5 ms added per round trip | 433 ms | 228 ms
| 1.90x |
| graph node doing one `get` and one `put` per step, 50 steps | 46.8 ms
| 37.2 ms | 1.26x |
| `put`, and many concurrent `aget` batched together | | | about 1x |

## Test plan
- [x] The existing store suites pass for the sync and async stores in
their default, `pipeline=True` and pool setups, which cover the
lone-read path and the pipeline path.
2026-11-13 00:34:51 +00:00
..
__init__.py feat: Add vector search (#2535) 2024-11-28 04:40:12 +00:00
compose-postgres.yml feat: Add vector search (#2535) 2024-11-28 04:40:12 +00:00
conftest.py Fixup initial provisioning of aio postgres db (#2571) (#2600) 2024-12-03 01:55:26 +00:00
embed_test_utils.py feat: Add vector search (#2535) 2024-11-28 04:40:12 +00:00
test_async.py perf(checkpoint-postgres): skip the async saver's lock for connection pools (#9638) 2026-11-13 00:11:29 +00:00
test_async_store.py fix(checkpoint,checkpoint-postgres,checkpoint-sqlite): validate namespace labels before store dispatch (#9217) 2026-10-08 16:10:55 -07:00
test_conformance_delta.py test(checkpoint-postgres,checkpoint-sqlite): run the conformance suite (#8537) 2026-08-07 09:39:20 -04:00
test_delta_pagination.py fix(checkpoint-postgres,checkpoint-sqlite): treat an empty checkpoint_id as the latest in delta history (#9262) 2026-10-09 13:44:51 -04:00
test_delta_plain_value_seed.py fix(checkpoint-postgres): find plain-value seeds when walking delta history (#8535) 2026-08-07 09:07:04 -04:00
test_prune.py feat(checkpoint-postgres): add prune to PostgresSaver and AsyncPostgresSaver (#9290) 2026-10-14 15:09:51 -04:00
test_store.py perf(checkpoint-postgres): run a lone store read outside a pipeline (#9635) 2026-11-13 00:34:51 +00:00
test_sync.py fix(checkpoint): handle metadata.writes when serializing old checkpoints with Jsonb (#6236) 2025-10-06 11:27:34 -07:00