Skip to content

echonet: store cende blobs as raw bytes with tighter in-memory retention#14712

Open
ron-starkware wants to merge 1 commit into
ron/echonet-os/deploy-recreatefrom
ron/echonet-os/blob-bytes-store
Open

echonet: store cende blobs as raw bytes with tighter in-memory retention#14712
ron-starkware wants to merge 1 commit into
ron/echonet-os/deploy-recreatefrom
ron/echonet-os/blob-bytes-store

Conversation

@ron-starkware

Copy link
Copy Markdown
Contributor

A 6 MB blob parsed into a Python dict costs 30-50 MB of heap; at the
current retention window the parsed-dict store OOMs the pod. Keep the
raw JSON bytes instead (consumers parse just-in-time), evict blob
bodies from memory on a much tighter window than block documents, and
archive evicted bodies to the PVC, serving them back through a new
get_blob_body_with_disk_fallback (also used by the block-dump
endpoint's blob kind).

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@cursor

cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes block-store shape and eviction/archival behavior for a core ingestion path; incorrect eviction or fallback could break blob dumps for older blocks, but derived feeder-gateway outputs are unchanged.

Overview
Reduces echo-center memory pressure by keeping cende blob payloads as raw JSON bytes in the block store instead of parsed dicts, while still parsing once on ingest for transformation.

Retention and archiving now evicts in-memory blob_body on a shorter window (max_blob_bodies_to_keep_in_memory, default 30) than full block entries (100). Evicted bodies are written to the PVC via write_blob_bodies_to_disk while derived block / state_update docs can stay cached longer.

Serving: write_blob passes the request body as blob_body; /echonet/block_dump with kind blob returns those bytes verbatim through get_blob_body_with_disk_fallback (memory or archived blob_{n}.json). Full-block eviction snapshots also persist blobs with write_bytes instead of re-serializing from a dict.

Reviewed by Cursor Bugbot for commit 7dc81ee. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ea3e483. Configure here.

Comment thread echonet/shared_context.py
if evicted_blob_bodies:
_BlockStore.write_blob_bodies_to_disk(
evicted_blob_bodies, base_dir=self._blocks._ensure_archive_dir()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blob dropped before durable archive

Medium Severity

Blob bodies are removed from the in-memory block entry before write_blob_bodies_to_disk runs outside the lock. If that write fails or a reader runs in that gap, the blob is gone from memory while block metadata remains. Later full-block snapshots skip writing a blob file when blob_body was already popped, so there is no second chance to persist it.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ea3e483. Configure here.

Comment thread echonet/shared_context.py
"""Return the raw blob bytes for `block_number`, from memory or the on-disk archive."""
in_mem = self.get_block_field(block_number, "blob_body")
if in_mem:
return in_mem

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty blob treated as missing

Low Severity

get_blob_body_with_disk_fallback and the block-dump handler treat a stored blob_body of empty bytes as falsy, so they skip returning it and respond with not found instead of serving the empty payload.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ea3e483. Configure here.

@ron-starkware ron-starkware left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ron-starkware resolved 2 discussions.
Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on matanl-starkware).

A 6 MB blob parsed into a Python dict costs 30-50 MB of heap; at the
current retention window the parsed-dict store OOMs the pod. Keep the
raw JSON bytes instead (consumers parse just-in-time), evict blob
bodies from memory on a much tighter window than block documents, and
archive evicted bodies to the PVC, serving them back through a new
get_blob_body_with_disk_fallback (also used by the block-dump
endpoint's blob kind).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ron-starkware ron-starkware force-pushed the ron/echonet-os/blob-bytes-store branch from ea3e483 to 7dc81ee Compare July 8, 2026 10:34
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.

2 participants