Skip to content

Fast update and synching #56

Open
Open

Description

@thorwhalen

See this recipe to copy data over from src to targ:

src = ... # make source store
targ = ... # make target store 
targ.update(src)

Note that unless a specialized mechanism is implemented this update will be performed by looping through src.items(), and write all items in targ, regardless of the existence of the key. With many items this can be quite inefficient.

targ could implement a specialized efficient mechanism for the update method, but this would only affect the "writing to targ" part in the general case (if our update method remains insensitive to the particulars of src). Part of the inefficiencies come from iterating through src, so (since targ has control here) we could implement targ.update in such a way that it uses some special features of src to coordinate an efficient copying of data.

In sshdol we have a ssh_files.sync_to method to be able to perform an efficient synching of remote (ssh files) to local files (where the ssh_files instance is made). This is a way to circumvent the fact that to make local_files.update(ssh_files) we'd need to implement a specialized local_files class that knows how ssh_files work. A clean design is not clear here, and may not be worth it just to maintain the update interface, avoiding an extra method name. But a design could be envisioned whereby all base dol Stores have a mechanism that enables coordination between both sides of the update to be implemented.

Activity

  1. thorwhalen commented on Jul 2, 2026

    @thorwhalen
    MemberAuthor

    Triage (2026-07): priority: low, Wave 3. targ.update(src) currently falls back to the generic MutableMapping loop (iterate src, write each item) — slow for large/remote stores. A clean solution needs a duck-typed "fast-sync" protocol: targ.update detects whether src (and itself) expose an optimized transfer (e.g. rsync-backed sshdol) and negotiates it, while preserving the plain Mapping interface for the general case. Design still open — no source change yet. See misc/docs/dol_issues_report.md (#71).

  2. thorwhalen commented on Sep 22, 2026

    @thorwhalen
    MemberAuthor

    Update: #93 (2026-08-21) did the concrete verification this issue was asking for, under its "The update() case (#56) — what we verified" section. Summary for anyone landing here first:

    • Store never overrides update; the MutableMapping mixin runs per-item self[k] = v through the wrapped __setitem__ -- transform-correct, but never bulk.
    • A commented-out raw self.store.update(...) delegation in base.py would bypass all transforms -- correctly left disabled.
    • Backend-native bulk writes are structurally unreachable through today's wrappers (update is found by MRO before __getattr__ delegation).
    • cached_keys' generated update (forwards per item, batch-maintains its cache once) is the in-tree proof that bulk ops need layer cooperation, not a single override.
    • Conclusion: keep the mixin loop as the universal fallback; a real fast path needs the flat proxy / spec route from Robustly wrapping stores that have key- and value-taking methods #86, tracked as P3 in misc/docs/dol_roadmap.md alongside Beyond codecs: layer kinds for filters/caches in the flat model, and fast-op hook placement #93's layer-kind work.

    No action needed here beyond this pointer -- #93 is now the live design home for this.

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

    enhancementNew feature or requestpriority: lowNice to have / small win / niche

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions