Skip to content

Use DocumentTransactions.read_shared on read-only HumanReadCut, ReadLedger, and ChannelCatalog paths - #5279

Merged
trissim merged 1 commit into
mainfrom
perf/shared-read-ledger
Nov 28, 2026
Merged

trissim merged 1 commit into
mainfrom
perf/shared-read-ledger

Conversation

@trissim

@trissim trissim commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Eliminates per-call copy.deepcopy() of the 229 KB read_ledger.json (ReadDocument) and channels.json (CatalogDocument) on read-only observation and bus hot paths by promoting DocumentTransactions._read_shared to DocumentTransactions.read_shared() (mirroring RegistryStore.snapshot_with_pair's existing read_shared_copied path).

Changes

  • src/agent_comms/storage/locked_store.py: factored _read_with helper and exposed DocumentTransactions.read_shared() alongside read().
  • src/agent_comms/messaging/human_read_cut.py: HumanReadCut.document uses self.ledger.read_shared().
  • src/agent_comms/messaging/read_ledger.py: ReadLedger.cursor and ReadLedger.transcript_seen use self.read_shared().
  • src/agent_comms/messaging/historical_views.py: historical view reads use presentation.bus.reads.read_shared().
  • src/agent_comms/messaging/message_bus.py & published_bus.py: read-only ChannelCatalog lookups use self._channels.read_shared().
  • src/agent_comms/transport/connector_store.py: migrated _read_shared() -> read_shared().

Live wall-clock measurements (alternating warm A/B on live /home/ts/.agent-comms)

  • HumanReadCut(live).document (read_ledger.json, 229 KB): 6.3450 ms -> 0.0145 ms (437.6x faster)
  • ChannelCatalog.read() vs read_shared() (channels.json): 0.109 ms -> 0.011 ms (10.1x faster)

Verification

  • 147 passed (test_read_ledger, test_message_notifications, test_notification_recipient_window, test_recipient_activity_index, test_historical_views, test_connector), exit 0.
  • NRA non-dead findings on all 7 touched files: base=10 -> head=10 (0 new findings), REL_IMPORTS=0.

@trissim
trissim merged commit 57b1f93 into main Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant