Relationships
#1731 Double shard assembly per command lifecycle (pull + push both read all shards)
Opened by magistr · 8/19/2026
Summary
Both pullChanged (line 1672) and pushChanged (line 2009) independently call assembleIndexFromShards(), each reading _meta.json + N partition shard files from S3. When the fast path is broken (see companion issues), this happens on every command — the shards are fetched twice.
pullChanged populates this.index with the assembled entries, but pushChanged ignores it and re-fetches everything from S3 to get a fresh view. For read-only commands where nothing was dirtied between pull and push, this is wasted work.
Impact
With the fast path broken, every command does 2x the S3 reads for shard assembly. For a repo with ~20-30 shards, that's 40-60+ S3 GetObject calls instead of 20-30.
Suggested fix
Two options:
Cache-aware assembly: If
this.indexis already populated from a recentpullChangedin the same process lifecycle andlocalDirtyis false (nothing was written between pull and push), skip the push-side assembly and reuse the pull's index.Two-phase sync refactor: Core already supports
preparePush/commitPush(two-phase sync). If core uses two-phase, the same assembly can serve both pull verification and push preparation.
References
s3_cache_sync.ts:1672(pullChanged shard assembly)s3_cache_sync.ts:2009(pushChanged shard assembly)assembleIndexFromShards()reads _meta.json + all partition files
Upstream repository: https://github.com/systeminit/swamp-extensions
Environment
- Extension:
@swamp/s3-datastore@2026.08.12.1 - swamp:
20260819.011806.0-sha.a9c7ee9a - OS:
darwin(x86_64) - Deno:
2.8.3 - Shell:
/bin/zsh
Closed
No activity in this phase yet.
stack72 commented 8/27/2026, 4:48:48 PM
Hey @magistr, both pullChanged (line 1686) and pushChanged (line 2023) do call assembleIndexFromShards() independently — that's accurate. The push path re-reads intentionally to get a fresh view of remote state for correctness in concurrent-writer scenarios. The push path can't blindly reuse the pull's index because another writer may have pushed between the two calls.
This is an optimization opportunity, not a bug. Closing this — if we revisit the caching idea in the future we'll open a dedicated enhancement issue.
Sign in to post a ripple.