LangGraph checkpointer using LMDB
Project description
LangGraph LMDB Checkpointer
A high-performance, local checkpoint saver for LangGraph using LMDB (Lightning Memory-Mapped Database).
🚀 Why LMDB?
LMDB is a transactional, memory-mapped key-value store. It is incredibly fast because it uses the operating system's memory-map (mmap) to provide zero-copy reads and highly efficient writes. For LangGraph, where state persistence can become a bottleneck during complex agentic loops, LMDB offers a near-memory speed with full persistence.
🏢 When to Use?
- High-Performance Local Agents: When running agents on a single machine or edge device where network latency to a database (like Postgres) is unacceptable.
- Embedded Applications: Desktop or mobile apps that need a self-contained, lightweight, and zero-configuration database.
- Development & Prototyping: Fast startup and easy portability of checkpoints during the R&D phase.
🏆 Where it Excels
- Read Latency: Since it maps the database file directly into memory, reading a checkpoint is essentially a memory access.
- Reliability (ACID): Fully ACID compliant with a crash-proof design. If the power fails, your checkpoints stay consistent.
- Multi-Process/Multi-Thread: Highly concurrent reads without blocking, making it perfect for multi-agent workflows.
Features
- Blazing Fast Local Storage: Optimized for high-frequency writes and low-latency state retrieval.
- Binary Key Strategy: Uses a compact binary key layout (
thread_id\x00checkpoint_ns\x00checkpoint_id) for efficient multi-index prefix scanning. - Flexible Serialization: Supports both
msgpack(default) andorjsonfor high-speed state encoding. - Async & Sync Support: Provides both thread-safe synchronous (
LMDBSaver) and non-blocking asynchronous (AsyncLMDBSaver) implementations.
Installation
pip install langgraph-checkpoint-lmdb
Quick Start
import lmdb
from langgraph_checkpoint_lmdb import LMDBSaver
from langgraph.graph import StateGraph
# Initialize LMDB environment
env = lmdb.open("./checkpoints", max_dbs=10)
saver = LMDBSaver(env)
# Use in your LangGraph as a checkpointer
graph = builder.compile(checkpointer=saver)
Real-World Examples
- Customer Support Bot: See examples/customer_support.py for a complete implementation of a multi-turn support agent with state persistence.
- Interactive Chatbot: See examples/chatbot.py for a simple interactive CLI chatbot that remembers your name across sessions.
Performance
Benchmarks conducted on local hardware comparing LMDBSaver with the default MemorySaver.
| Scenario | MemorySaver | LMDBSaver | 🏆 Winner |
|---|---|---|---|
| Sequential Writes (1K) | 30,914 ops/s | 19,619 ops/s | MemorySaver |
| Concurrent Writes (15T×200) | 33,947 ops/s | 8,523 ops/s | MemorySaver |
| History Query (list 100) | 52,672 ops/s | 45,319 ops/s | MemorySaver |
[!TIP]
LMDBSaverhandles persistent storage while maintaining performance within the same magnitude as in-memory storage, making it ideal for edge devices and high-load local agents.
Development
Run Tests
pytest
Run Benchmarks
python benchmark.py
License
MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langgraph_checkpoint_lmdb-0.2.0.tar.gz.
File metadata
- Download URL: langgraph_checkpoint_lmdb-0.2.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
596b7207ff5020e3d70193f60928e057450ae80d7a8dfb7ef1f82bb75ca77059
|
|
| MD5 |
402bca54fad064b1b225cfa4d6bcf210
|
|
| BLAKE2b-256 |
a7ebb93b586c04e6cb24e955a703f781e40406339bbe6fdd6c9bf99a6e11b2c3
|
File details
Details for the file langgraph_checkpoint_lmdb-0.2.0-py3-none-any.whl.
File metadata
- Download URL: langgraph_checkpoint_lmdb-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27e887bccccab6e0cb03fa0ed6c141273c2ba94dab0d0c6cf4a0ad9bc4631092
|
|
| MD5 |
9f4318fc3d02753cfea6b1fbe1af3e4f
|
|
| BLAKE2b-256 |
2a651e676e755df3e51903c774c4fac44b8ac0c75729f1947ef4048f54bce111
|