Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:1kbgz Tributary Tick Policy Selection

From Leeroopedia
Knowledge Sources
Domains Streaming, Optimization
Last Updated 2026-10-14 09:15 GMT

Overview

Choose `drop`, `replace`, or `repeat` tick policies to control backpressure behavior when upstream nodes produce data at mismatched rates.

Description

In tributary streaming graphs, upstream nodes may produce ticks at different rates. When a downstream node has unprocessed input, the tick policy determines what happens to new incoming data. Three policies are available:

  • Drop (`drop=True`): New ticks are silently discarded if the downstream queue already has data or an active value. Best for lossy real-time feeds where only the latest data matters.
  • Replace (`replace=True`): New ticks overwrite pending queued values and replace active values. Best for stateful processing where only the most recent value is relevant.
  • Repeat (`repeat=True`): When no new input is available, the node repeats its last value instead of propagating `StreamNone`. Best for filling gaps in sparse streams.
  • None (default): Standard backpressure — upstream nodes wait for downstream to drain. Best when no data loss is acceptable.

The `drop` and `replace` policies are mutually exclusive (`assert not (self._drop and self._replace)`).

Usage

Use this heuristic when designing streaming pipelines with mismatched production rates:

  • Drop for high-frequency sensor data where stale values are useless.
  • Replace for price feeds where only the latest tick matters.
  • Repeat for indicators that should hold their last value during gaps.
  • Default (none) for transactional pipelines where every tick must be processed.

The Insight (Rule of Thumb)

  • Action: Set `drop=True`, `replace=True`, or `repeat=True` on the `Node` constructor.
  • Value: Boolean flags — `drop` and `replace` are mutually exclusive.
  • Trade-off: Drop and replace trade data completeness for throughput; repeat trades correctness for continuity; default (backpressure) trades throughput for completeness.
  • Compatibility: Works with all streaming node types. When `drop` or `replace` is set, `_backpressure()` returns `False` (never blocks upstream).

Reasoning

Without backpressure control, a slow downstream node causes upstream queues to grow unboundedly, leading to memory exhaustion. The `drop` policy is the cheapest — it simply skips pushing. The `replace` policy is slightly more expensive — it pops and discards the old value before pushing. Both disable the `_backpressure()` check so the upstream node never waits. The `repeat` policy keeps the last valid value in `self._last` and propagates it when input is `StreamNone`, ensuring downstream nodes always receive a value.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment