Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

[upstream-sync] refactor(state_store): LMDB isolation, async I/O, and fn-memo cache series (upstream #1981–#1991) #168

Description

@github-actions

Upstream Change Summary

Type: architectural-change / performance
Difficulty: Hard
Recommendation: Adapt

A six-PR series in the upstream repo (spanning 2026-05-16 to 2026-05-18) completely restructured the Rust state_store module and fn-memo engine subsystem. The structural PRs (#1981–#1983) isolated all LMDB-specific code under state_store/, split StoreAppStore + Storage, and hid TxnBatcher as an implementation detail. The behavioral PRs (#1987, #1990, #1991) then made all public state_store methods async fn, introduced a per-component FnMemoAccessor handle, and replaced on-demand per-fn DB reads with an eager-prefetch FnMemoCache that batches all writes in a single flush — dramatically reducing I/O per build.

Upstream References

Relevant Upstream Files / Areas

  • rust/core/src/state_store/ (all files — new module split)
  • rust/core/src/engine/app.rs, component.rs, context.rs, execution.rs, function.rs
  • rust/core/src/engine/environment.rs, live_component.rs
  • rust/core/src/inspect/db_inspect.rs

Maps to recoco: crates/recoco-core/src/ (engine + state_store equivalent)

Recoco Considerations

  • Module restructure: Recoco's state store (currently organized differently) should adopt the Storage / AppStore split so LMDB-specific code is isolated behind a clean boundary — this will simplify a future swap to a different storage backend.
  • Async I/O: Upstream made every public state_store method async fn (currently synchronous LMDB calls returning immediately-resolved futures). Recoco should evaluate whether the same API-shape change is worth the cascade through engine call sites. The SDK's AppBuilder::build_blocking / App::open_blocking sync wrappers introduced here are a good pattern to adopt for #[test] entry points.
  • FnMemoCache performance: The eager-prefetch + single-flush cache is a pure performance improvement (O(1) prefix scan instead of O(N) per-fn point reads). This is high-value for recoco given its performance focus.
  • No PyO3 impact: Recoco has no Python bindings, so the rust/py/src/app.rs / rust/py/src/environment.rs cascade changes are irrelevant. The py.detach(|| get_runtime().block_on(...)) bridge pattern used in #1987 is not needed.
  • No blake3 opportunity in this specific series, but the LMDB key encoding under state_store/ should be verified against recoco's existing hashing choices.

Integration Notes

These PRs should be adopted in order (#1981 → #1982 → #1983 → #1987 → #1990 → #1991) since each builds on the previous. The structural rename from StoreAppStore propagates through many engine files — do a bulk rename pass first, then layer in the async and caching changes. The FnMemoCache prefetch strategy (one prefix scan at build start, one flush at commit) is directly adoptable and is the highest-value change in the series.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeCreated or actioned by Claude AIupstream-syncIssues for syncing updates with our upstream (cocoindex-io/cocoindex)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions