Migrate single-threaded pipelines to Tokio LocalRuntime - #3731
Draft
lquerel wants to merge 15 commits into
Draft
Conversation
# Conflicts: # rust/otap-dataflow/crates/config/src/engine.rs # rust/otap-dataflow/crates/engine/src/extension_lifecycle.rs # rust/otap-dataflow/crates/engine/src/pipeline_ctrl.rs # rust/otap-dataflow/crates/engine/src/runtime_pipeline.rs # rust/otap-dataflow/crates/otap/src/crypto.rs
# Conflicts: # rust/otap-dataflow/.chloggen/fix-otap-exporter-shutdown-deadlock.yaml # rust/otap-dataflow/.chloggen/query-engine-nested-ser-attributes.yaml # rust/otap-dataflow/.chloggen/transform-processor-dropped-flow-metric.yaml # rust/otap-dataflow/Cargo.toml # rust/otap-dataflow/crates/config/src/engine/validate.rs # rust/otap-dataflow/crates/contrib-nodes/src/exporters/azure_monitor_exporter/auth.rs # rust/otap-dataflow/crates/core-nodes/src/processors/content_router/mod.rs # rust/otap-dataflow/crates/engine/src/pipeline_ctrl.rs # rust/otap-dataflow/crates/engine/src/processor.rs # rust/otap-dataflow/crates/engine/src/runtime_pipeline.rs # rust/otap-dataflow/docs/configuration-model.md
# Conflicts: # rust/otap-dataflow/crates/config/src/engine/validate.rs # rust/otap-dataflow/crates/controller/src/lib.rs # rust/otap-dataflow/crates/core-nodes/src/receivers/internal_telemetry_receiver/mod.rs # rust/otap-dataflow/crates/engine/src/pipeline_ctrl.rs # rust/otap-dataflow/crates/engine/src/processor.rs # rust/otap-dataflow/crates/engine/src/runtime_pipeline.rs
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3731 +/- ##
==========================================
- Coverage 87.37% 87.37% -0.01%
==========================================
Files 840 842 +2
Lines 338187 338411 +224
==========================================
+ Hits 295495 295670 +175
- Misses 42160 42209 +49
Partials 532 532
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Migrates the engine from a current-thread Tokio Runtime combined with a LocalSet to Tokio's stable LocalRuntime.
Tokio stabilized LocalRuntime in Tokio 1.51.0 (https://github.com/tokio-rs/tokio/releases/tag/tokio-1.51.0) on April 3, 2026. It is now the recommended direct abstraction for running !Send tasks on a single-threaded Tokio runtime, making this migration several months overdue...
This PR:
What issue does this PR close?
Reviewer guide
Is this mostly mechanical?
Yes, but not entirely.
Most files apply the same
Runtime + LocalSettoLocalRuntimeconversion.The apparent size is inflated primarily by
pipeline_ctrl.rs, mostof that difference comes from removing
LocalSet::run_untilwrappers.Reviewing the final Files changed view with GitHub's Hide whitespace option enabled is strongly recommended.
Suggested review order
Runtime construction and pipeline execution
crates/engine/src/runtime.rscrates/engine/src/runtime_pipeline.rscrates/engine/src/extension_lifecycle.rsConfiguration propagation and validation
crates/config/src/engine.rscrates/config/src/engine/validate.rscrates/controller/src/lib.rsRuntime telemetry
crates/engine/src/pipeline_metrics.rsMechanical migration
Supporting changes
Mechanical conversion pattern
The repeated migration generally follows this pattern:
Runtime + LocalSetbecomesLocalRuntime..build()becomes.build_local(LocalOptions::default()).LocalSet::spawn_localbecomesLocalRuntime::spawn_local.block_on(local_set.run_until(future))becomesblock_on(future).Once this pattern has been reviewed in representative production and test
locations, most remaining occurrences should be safe to skim.
How are these changes tested?
Automated coverage includes:
Performance was evaluated using pinned engine instances and a real OTAP pipeline:
4 traffic generators
-> OTAP receiver
-> attribute processor
-> transform processor
-> parallel fanout
-> 2 OTAP exporters
-> 2 independently pinned OTAP receiver/noop backends
Across five randomized steady-state repetitions at approximately 200K logs/s ingress and 400K logs/s aggregate egress, LocalRuntime maintained equivalent delivery with:
The CPU and context-switch improvements are directional rather than statistically conclusive with five repetitions. The epoll behavior consistently confirms that LocalRuntime avoids frequent short driver polls.
Are there any user-facing changes?
Yes.
The runtime migration is transparent for existing configurations. New optional engine settings are available under engine.runtime.local_runtime:
When omitted, Tokio's defaults remain in effect. The settings and their performance and latency tradeoffs are documented.
Changelog