Skip to main content
← Back to list
01Issue
FeatureClosedSwamp CLIPublicTeam
AssigneesNone

Relationships

#1733 Skip 50MB monolithic index rewrite on v2 shard-first path

Opened by magistr · 8/19/2026

Summary

On the shard-first (v2) path, the local .datastore-index.json (50MB, 129k entries) is rewritten via atomicWriteTextFile on every slow-path sync — both pull (s3_cache_sync.ts:1682) and push (s3_cache_sync.ts:2018-2021, 2302-2306). This is expensive:

  • JSON.stringify of 129k entries
  • Atomic write (write-to-temp + rename) of 50MB
  • Called twice per command (once in pull, once in push)

In v2 mode, shards are the source of truth. The monolithic local index is only used as an in-memory cache and for the legacy ETag-based fast path fallback. With the commitSeq fast path working (once the companion bugs are fixed), the ETag-based fallback won't be needed.

Suggested fix

  1. When the v2 commitSeq fast path is functional, skip the monolithic index rewrite entirely on the shard path.
  2. As an interim measure, make the rewrite lazy — only write when this.indexMutated is true (zombie entries removed) rather than on every pull/push cycle.
  3. Consider keeping the in-memory index without persisting it when shards are the authority.

References

  • s3_cache_sync.ts:1680-1684 (pullChanged — always rewrites after shard assembly)
  • s3_cache_sync.ts:2015-2023 (pushChanged — always rewrites after shard assembly)
  • .datastore-index.json is 50MB / 129k entries in the observed repo

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
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

8/22/2026, 9:01:32 PM

No activity in this phase yet.

03Sludge Pulse
Editable. Press Enter to edit.

stack72 commented 8/22/2026, 9:01:31 PM

This was due to a migration-index not being run - closing this out

Sign in to post a ripple.