Skip to content
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

checkpoint postgres: add a shallow checkpointer #2826

Merged
merged 14 commits into from
Dec 20, 2024
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import threading

Check notice on line 1 in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 59.9 ms +- 0.9 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 51.5 ms +- 0.7 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 72.7 ms +- 0.9 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 92.6 ms +- 1.3 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 588 ms +- 21 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 504 ms +- 7 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 731 ms +- 25 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 922 ms +- 15 ms ......................................... react_agent_10x: Mean +- std dev: 30.2 ms +- 0.5 ms ......................................... react_agent_10x_sync: Mean +- std dev: 22.5 ms +- 0.2 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 37.7 ms +- 0.8 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 36.4 ms +- 0.4 ms ......................................... react_agent_100x: Mean +- std dev: 333 ms +- 6 ms ......................................... react_agent_100x_sync: Mean +- std dev: 272 ms +- 6 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 831 ms +- 8 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 831 ms +- 11 ms ......................................... wide_state_25x300: Mean +- std dev: 22.6 ms +- 0.5 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 14.6 ms +- 0.1 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 274 ms +- 13 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 273 ms +- 14 ms ......................................... wide_state_15x600: Mean +- std dev: 26.4 ms +- 0.5 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 17.0 ms +- 0.1 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 470 ms +- 13 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 470 ms +- 14 ms ......................................... wide_state_9x1200: Mean +- std dev: 26.3 ms +- 0.5 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 17.1 ms +- 0.3 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 307 ms +- 13 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 304 ms +- 13 ms

Check notice on line 1 in libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +=========================================+=========+=======================+ | fanout_to_subgraph_100x_checkpoint | 791 ms | 731 ms: 1.08x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x | 619 ms | 588 ms: 1.05x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 97.0 ms | 92.6 ms: 1.05x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 75.3 ms | 72.7 ms: 1.04x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 858 ms | 831 ms: 1.03x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 948 ms | 922 ms: 1.03x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 30.9 ms | 30.2 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200 | 27.0 ms | 26.3 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_100x | 341 ms | 333 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x | 61.3 ms | 59.9 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 23.0 ms | 22.5 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_sync | 52.6 ms | 51.5 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint_sync | 37.1 ms | 36.4 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 513 ms | 504 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint | 38.2 ms | 37.7 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_sync | 17.3 ms | 17.1 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 841 ms | 831 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 26.7 ms | 26.4 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 22.8 ms | 22.6 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 17.1 ms | 17.0 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 14.7 ms | 14.6 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_sync | 273 ms | 272 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.02x faster | +-----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (6): wide_state_9x1200_checkpoint_sync, wide_state_25x300_checkpoint, wide_state_9x1200_checkpoint, wide_state_15x600_checkpoint, wide_state_25x300_checkpoint_sync, wide_state_15x600_checkpoint_sync
from collections.abc import Iterator, Sequence
from contextlib import contextmanager
from typing import Any, Optional
Expand All @@ -19,6 +19,7 @@
)
from langgraph.checkpoint.postgres import _internal
from langgraph.checkpoint.postgres.base import BasePostgresSaver
from langgraph.checkpoint.postgres.shallow import ShallowPostgresSaver
from langgraph.checkpoint.serde.base import SerializerProtocol

Conn = _internal.Conn # For backward compatibility
Expand Down Expand Up @@ -396,4 +397,4 @@
yield cur


__all__ = ["PostgresSaver", "BasePostgresSaver", "Conn"]
__all__ = ["PostgresSaver", "BasePostgresSaver", "ShallowPostgresSaver", "Conn"]
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
)
from langgraph.checkpoint.postgres import _ainternal
from langgraph.checkpoint.postgres.base import BasePostgresSaver
from langgraph.checkpoint.postgres.shallow import AsyncShallowPostgresSaver
from langgraph.checkpoint.serde.base import SerializerProtocol

Conn = _ainternal.Conn # For backward compatibility
Expand Down Expand Up @@ -464,4 +465,4 @@ def put_writes(
).result()


__all__ = ["AsyncPostgresSaver", "Conn"]
__all__ = ["AsyncPostgresSaver", "AsyncShallowPostgresSaver", "Conn"]
Loading
Loading