Skip to content

buffer-prop: cross-graph shared buffer communication#9

Draft
treere wants to merge 3 commits into
masterfrom
buffer-prop
Draft

buffer-prop: cross-graph shared buffer communication#9
treere wants to merge 3 commits into
masterfrom
buffer-prop

Conversation

@treere

@treere treere commented May 30, 2026

Copy link
Copy Markdown
Owner

Problem

Some graphs generate bursts of data faster than downstream graphs can consume. The existing link protocol only reads the last value of a property — values produced between consumption cycles are lost. Consumer graphs that need to accumulate or batch-process every value have no way to do so without missing intermediate data.

Solution

This PR introduces a shared buffer mechanism. A producer graph writes values into a named buffer; a consumer graph reads from the same buffer. Each value is delivered exactly once — the buffer acts as a decoupling queue between producers and consumers.

Configuration is declarative: define buffers and their capacities in the system config, then declare which node properties are linked to which buffer. Wiring happens automatically when the system starts.

The design is non-invasive — no changes to the existing graph pipeline, worker loop, or cross-graph link protocol. Buffers coexist with the existing pull-based links, letting each graph use the right communication pattern for each connection.

Comment thread cytos/benches/my_benchmark.rs Outdated
@@ -63,6 +63,7 @@ fn create_graph(nodes_count: u64) -> Graph {
node: NodeRepr {
typ: "add".to_string(),
props: HashMap::default(),

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Suggested change
props: HashMap::default(),

The Default::default) should already include this.

This is true for many places where we add Default::default()

@treere treere force-pushed the buffer-prop branch 2 times, most recently from 91aa073 to 6f353d9 Compare May 30, 2026 13:20
- BoundedQueue: VecDeque<GenericOwnedProp> with bounded capacity
- BufferHandle: Arc<Mutex<BoundedQueue>> for thread-safe sharing
- BufferProp<T>: push/pop interface wrapping Prop<T> + BufferHandle
- GenericPropInterface::link_buffer(): wiring method for system init
- BufferRepr + SystemRepr.buffers: buffer config serialization
- NodeRepr.buffer_links: maps param IDs to named buffer references
- System buffer registry: creates handles from config, wires to nodes
- System::buffer_stats(): query buffer (len, capacity) by name
- 10 unit tests + 1 integration test (producer/consumer, two graphs)
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