Skip to content

Opt-in owned tokio runtime for nodes without ambient executor#1748

Merged
phil-opp merged 1 commit into
claude/apply-remaining-improvements-SMRpEfrom
owned-tokio-runtime
Apr 23, 2026
Merged

Opt-in owned tokio runtime for nodes without ambient executor#1748
phil-opp merged 1 commit into
claude/apply-remaining-improvements-SMRpEfrom
owned-tokio-runtime

Conversation

@phil-opp
Copy link
Copy Markdown
Collaborator

Follow-up to #1745. Embedders without an ambient tokio runtime can set DORA_CREATE_OWNED_TOKIO_RUNTIME=1 to have DoraNode::init build a multi-threaded runtime for the zenoh SHM data plane. Default stays strict — init errors if no runtime is available.

Depends on #1745 being merged first (this branch is based on it).

Embedders that lack an ambient tokio runtime can now set
DORA_CREATE_OWNED_TOKIO_RUNTIME=1 to have the node build its own
multi-threaded runtime for the zenoh SHM data plane. Default remains
strict: init errors when no runtime is available.

Follow-up to #1745.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@phil-opp phil-opp changed the base branch from main to claude/apply-remaining-improvements-SMRpE April 23, 2026 14:36
@phil-opp
Copy link
Copy Markdown
Collaborator Author

@Mergifyio queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 23, 2026

Merge Queue Status

  • 🟠 Waiting for queue conditions
  • ⏳ Enter queue
  • ⏳ Run checks
  • ⏳ Merge
Waiting for:
  • -closed
  • base=main
  • check-success=Audit (cargo-audit + cargo-deny)
  • check-success=Check
  • check-success=Clippy
  • check-success=Format
  • check-success=License check
  • check-success=Typos
  • check-success=Unwrap budget
All conditions
  • -closed [📌 queue requirement]
  • any of [🔀 queue conditions]:
    • all of [📌 queue conditions of queue rule default]:
      • base=main
      • check-success=Audit (cargo-audit + cargo-deny)
      • check-success=Check
      • check-success=Clippy
      • check-success=Format
      • check-success=License check
      • check-success=Typos
      • check-success=Unwrap budget
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of [📌 queue -> configuration change requirements]:
    • -mergify-configuration-changed
    • check-success = Configuration changed
  • any of [📌 queue requirement]:
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
    • check-success = Mergify Merge Protections

@phil-opp phil-opp merged commit e2f5108 into claude/apply-remaining-improvements-SMRpE Apr 23, 2026
23 of 33 checks passed
@phil-opp phil-opp deleted the owned-tokio-runtime branch April 23, 2026 15:59
phil-opp added a commit that referenced this pull request Apr 23, 2026
Node authors shouldn't have to set up a tokio runtime just to call
`DoraNode::init_from_env()`. Drop the `DORA_CREATE_OWNED_TOKIO_RUNTIME`
opt-in gate introduced in #1748 and always build an owned multi-threaded
runtime when `Handle::try_current()` returns `Err`. Callers with an
ambient runtime keep using it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
trunk-io Bot pushed a commit that referenced this pull request Apr 28, 2026
* refactor: remove DropToken system now that zenoh SHM is the data plane

Continuation of #1741, salvaging more from the closed #1378. Zenoh's SHM
provider now handles buffer lifecycle via its own reference counting, so
the custom shmem + DropToken tracking path is pure legacy.

- Node API: zenoh session + SHM provider are now mandatory in standard
  mode (no more DropStream fallback, no custom shmem allocation cache,
  no `DataSampleInner::Shmem`). `allocate_data_sample` always returns a
  heap buffer; zenoh publishes large payloads zero-copy.
- Message types: removed `DataMessage::SharedMemory`, `DropToken`,
  `NodeDropEvent`, `DaemonReply::NextDropEvents`, the
  `SubscribeDrop` / `ReportDropTokens` / `NextFinishedDropTokens`
  requests, and `drop_tokens` on `NextEvent`. `DataMessage` is now
  just `Vec`.
- DaemonCommunication::Shmem drops `daemon_drop_region_id`.
- Daemon: removed `drop_channels`, `pending_drop_tokens`,
  `DropTokenInformation`, `check_drop_token`, the drop listener loop,
  and the SHM mmap+copy fan-out path (only `DataMessage::Vec` remains).
- Dropped the `shared_memory_extended` dependency from dora-node-api.

Nodes that were implicitly relying on the non-tokio fallback will now
fail init with a clear error instead of silently degrading.

* cleanup: remove dead SHM-protocol leftovers from message enums

- DaemonReply::PreparedMessage: no construction or match sites remain
  after the SHM data-plane removal.
- node_to_daemon::InputData: single-variant enum with no callers (the
  InputData used in integration tests comes from a different module).
- Collapse the now-single-arm DataMessage match in the daemon into an
  irrefutable let.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Trigger CI

* Opt-in owned tokio runtime for nodes without ambient executor (#1748)

Support opt-in owned tokio runtime for nodes

Embedders that lack an ambient tokio runtime can now set
DORA_CREATE_OWNED_TOKIO_RUNTIME=1 to have the node build its own
multi-threaded runtime for the zenoh SHM data plane. Default remains
strict: init errors when no runtime is available.

Follow-up to #1745.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Create owned tokio runtime by default when none is ambient

Node authors shouldn't have to set up a tokio runtime just to call
`DoraNode::init_from_env()`. Drop the `DORA_CREATE_OWNED_TOKIO_RUNTIME`
opt-in gate introduced in #1748 and always build an owned multi-threaded
runtime when `Handle::try_current()` returns `Err`. Callers with an
ambient runtime keep using it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Carry ParamUpdate value as JSON bytes over the bincode wire

`NodeEvent` is serialized with bincode on the daemon→node TCP channel.
`serde_json::Value::deserialize` calls `Deserializer::deserialize_any`,
which bincode does not support: the first `ParamUpdate` would kill the
node's event stream with "Bincode does not support the
serde::Deserializer::deserialize_any method".

Change `NodeEvent::ParamUpdate.value` to `value_json: Vec<u8>`
(JSON-encoded), and serialize/deserialize at the daemon and node
boundaries. The public `Event::ParamUpdate.value: serde_json::Value`
stays unchanged for callers.

Adds a bincode round-trip regression test over representative JSON
shapes so we don't slip a `deserialize_any` field back into
`NodeEvent`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Fall back to heap publishes when zenoh SHM provider creation fails

CI runners with a small `/dev/shm` (and tests that spawn many nodes
in sequence without segment cleanup between runs) now hit
`ShmProviderBuilder::default_backend` returning `OS error 12`
(ENOMEM), which used to abort node init outright. Treat the SHM
provider as best-effort instead: log a warning and proceed with
`zenoh_shm_provider = None`. The send path already publishes via
heap buffers when the provider is missing, so messages still flow —
just without the SHM zero-copy fast path.

Restores the contract-test suite that started failing once nodes
actually reached the SHM allocation step (previously they failed
earlier on tokio runtime init, masking the issue).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
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