From a865b44a3a7aa8b1919654b6a9b31eb636cd8a06 Mon Sep 17 00:00:00 2001 From: Shadaj Laddad Date: Thu, 21 Nov 2024 09:14:15 -0800 Subject: [PATCH] feat(hydroflow_plus, stageleft)!: allow cluster self ID to be referenced as a global constant This eliminates the need to store `cluster.self_id()` in a local variable first, instead you can directly reference `CLUSTER_SELF_ID`. --- hydroflow_plus/src/builder/compiled.rs | 25 ++- hydroflow_plus/src/builder/deploy.rs | 2 +- hydroflow_plus/src/deploy/deploy_graph.rs | 124 +---------- hydroflow_plus/src/deploy/deploy_runtime.rs | 26 +-- hydroflow_plus/src/deploy/macro_runtime.rs | 6 +- hydroflow_plus/src/deploy/mod.rs | 11 +- hydroflow_plus/src/deploy/trybuild.rs | 80 ++++++- .../src/deploy/trybuild_rewriters.rs | 35 +++ hydroflow_plus/src/lib.rs | 1 + hydroflow_plus/src/location/cluster.rs | 207 ------------------ .../src/location/cluster/cluster_id.rs | 85 +++++++ hydroflow_plus/src/location/cluster/mod.rs | 147 +++++++++++++ .../src/location/external_process.rs | 6 + hydroflow_plus/src/location/mod.rs | 27 ++- hydroflow_plus/src/location/process.rs | 6 + hydroflow_plus/src/location/tick.rs | 19 +- hydroflow_plus/src/optional.rs | 27 ++- hydroflow_plus/src/rewrites/profiler.rs | 2 +- hydroflow_plus/src/rewrites/properties.rs | 24 +- ...ts__profiler_wrapping_all_operators-2.snap | 4 +- hydroflow_plus/src/runtime_context.rs | 8 +- hydroflow_plus/src/singleton.rs | 27 ++- hydroflow_plus/src/stream.rs | 159 ++++++++------ hydroflow_plus_test/src/cluster/paxos.rs | 11 +- .../src/cluster/paxos_bench.rs | 3 +- .../src/cluster/simple_cluster.rs | 10 +- ...ter__compute_pi__tests__compute_pi_ir.snap | 6 +- ..._tests__compute_pi_ir@surface_graph_0.snap | 4 +- ..._tests__compute_pi_ir@surface_graph_1.snap | 6 +- ...er__many_to_many__tests__many_to_many.snap | 4 +- ...ter__map_reduce__tests__map_reduce_ir.snap | 4 +- ..._tests__map_reduce_ir@surface_graph_0.snap | 8 +- ..._tests__map_reduce_ir@surface_graph_1.snap | 4 +- ...cluster__paxos_bench__tests__paxos_ir.snap | 192 ++++++++-------- ...simple_cluster__tests__simple_cluster.snap | 16 +- .../src/local/count_elems.rs | 2 +- ...ests__chat_app_no_replay@graphvis_dot.snap | 2 +- ...__chat_app_no_replay@graphvis_mermaid.snap | 2 +- ...__tests__chat_app_replay@graphvis_dot.snap | 2 +- ...sts__chat_app_replay@graphvis_mermaid.snap | 2 +- ...ount_elems__tests__count@graphvis_dot.snap | 2 +- ..._elems__tests__count@graphvis_mermaid.snap | 2 +- ...ity__tests__reachability@graphvis_dot.snap | 2 +- ..._tests__reachability@graphvis_mermaid.snap | 2 +- ..._anti_join_static_static@graphvis_dot.snap | 2 +- ...i_join_static_static@graphvis_mermaid.snap | 2 +- ...s__anti_join_static_tick@graphvis_dot.snap | 2 +- ...nti_join_static_tick@graphvis_mermaid.snap | 2 +- ...s__anti_join_tick_static@graphvis_dot.snap | 2 +- ...nti_join_tick_static@graphvis_mermaid.snap | 2 +- ...sts__anti_join_tick_tick@graphvis_dot.snap | 2 +- ..._anti_join_tick_tick@graphvis_mermaid.snap | 2 +- ...difference_static_static@graphvis_dot.snap | 2 +- ...erence_static_static@graphvis_mermaid.snap | 2 +- ...__difference_static_tick@graphvis_dot.snap | 2 +- ...fference_static_tick@graphvis_mermaid.snap | 2 +- ...__difference_tick_static@graphvis_dot.snap | 2 +- ...fference_tick_static@graphvis_mermaid.snap | 2 +- ...ts__difference_tick_tick@graphvis_dot.snap | 2 +- ...difference_tick_tick@graphvis_mermaid.snap | 2 +- ...d_join__tests__teed_join@graphvis_dot.snap | 2 +- ...in__tests__teed_join@graphvis_mermaid.snap | 2 +- ...ts__teed_join_multi_node@graphvis_dot.snap | 2 +- ...teed_join_multi_node@graphvis_mermaid.snap | 2 +- ...__tests__teed_join_twice@graphvis_dot.snap | 4 +- ...sts__teed_join_twice@graphvis_mermaid.snap | 4 +- stageleft/src/lib.rs | 185 ++++++++++++++-- stageleft/src/runtime_support.rs | 46 +++- stageleft_macro/src/lib.rs | 2 +- .../src/quote_impl/free_variable/mod.rs | 172 ++++++++------- stageleft_macro/src/quote_impl/mod.rs | 26 ++- ...ests__capture_copy_local@macro_tokens.snap | 22 +- ...capture_copy_local_block@macro_tokens.snap | 23 +- ...ure_copy_local_block_let@macro_tokens.snap | 21 +- ..._tests__capture_in_macro@macro_tokens.snap | 21 +- ...pl__tests__capture_local@macro_tokens.snap | 21 +- ...tests__capture_local_mut@macro_tokens.snap | 21 +- ...on_capture_enum_creation@macro_tokens.snap | 1 + ...tests__non_capture_local@macro_tokens.snap | 1 + ..._capture_struct_creation@macro_tokens.snap | 1 + ..._prelude_enum_variants@macro_tokens-2.snap | 1 + ..._prelude_enum_variants@macro_tokens-3.snap | 1 + ..._prelude_enum_variants@macro_tokens-4.snap | 1 + ...s__prelude_enum_variants@macro_tokens.snap | 1 + ...uote_impl__tests__simple@macro_tokens.snap | 1 + stageleft_tool/src/lib.rs | 12 + 86 files changed, 1167 insertions(+), 805 deletions(-) create mode 100644 hydroflow_plus/src/deploy/trybuild_rewriters.rs delete mode 100644 hydroflow_plus/src/location/cluster.rs create mode 100644 hydroflow_plus/src/location/cluster/cluster_id.rs create mode 100644 hydroflow_plus/src/location/cluster/mod.rs diff --git a/hydroflow_plus/src/builder/compiled.rs b/hydroflow_plus/src/builder/compiled.rs index 1db322926722..5e4164e6c796 100644 --- a/hydroflow_plus/src/builder/compiled.rs +++ b/hydroflow_plus/src/builder/compiled.rs @@ -5,8 +5,8 @@ use hydroflow::scheduled::graph::Hydroflow; use hydroflow_lang::graph::{partition_graph, HydroflowGraph}; use proc_macro2::TokenStream; use quote::quote; -use stageleft::runtime_support::FreeVariable; -use stageleft::Quoted; +use stageleft::runtime_support::FreeVariableWithContext; +use stageleft::QuotedWithContext; use crate::staging_util::Invariant; @@ -27,7 +27,10 @@ impl CompiledFlow<'_, ID> { } impl<'a> CompiledFlow<'a, usize> { - pub fn with_dynamic_id(self, id: impl Quoted<'a, usize>) -> CompiledFlowWithId<'a> { + pub fn with_dynamic_id( + self, + id: impl QuotedWithContext<'a, usize, ()>, + ) -> CompiledFlowWithId<'a> { let hydroflow_crate = proc_macro_crate::crate_name("hydroflow_plus") .expect("hydroflow_plus should be present in `Cargo.toml`"); let root = match hydroflow_crate { @@ -82,10 +85,12 @@ impl<'a> CompiledFlow<'a, usize> { } } -impl<'a> Quoted<'a, Hydroflow<'a>> for CompiledFlow<'a, ()> {} +impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlow<'a, ()> {} -impl<'a> FreeVariable> for CompiledFlow<'a, ()> { - fn to_tokens(mut self) -> (Option, Option) { +impl<'a, Ctx> FreeVariableWithContext for CompiledFlow<'a, ()> { + type O = Hydroflow<'a>; + + fn to_tokens(mut self, _ctx: &Ctx) -> (Option, Option) { let hydroflow_crate = proc_macro_crate::crate_name("hydroflow_plus") .expect("hydroflow_plus should be present in `Cargo.toml`"); let root = match hydroflow_crate { @@ -116,10 +121,12 @@ pub struct CompiledFlowWithId<'a> { _phantom: Invariant<'a>, } -impl<'a> Quoted<'a, Hydroflow<'a>> for CompiledFlowWithId<'a> {} +impl<'a, Ctx> QuotedWithContext<'a, Hydroflow<'a>, Ctx> for CompiledFlowWithId<'a> {} + +impl<'a, Ctx> FreeVariableWithContext for CompiledFlowWithId<'a> { + type O = Hydroflow<'a>; -impl<'a> FreeVariable> for CompiledFlowWithId<'a> { - fn to_tokens(self) -> (Option, Option) { + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { (None, Some(self.tokens)) } } diff --git a/hydroflow_plus/src/builder/deploy.rs b/hydroflow_plus/src/builder/deploy.rs index b44936ac2a6a..6e11e8935dcb 100644 --- a/hydroflow_plus/src/builder/deploy.rs +++ b/hydroflow_plus/src/builder/deploy.rs @@ -8,7 +8,7 @@ use hydroflow::futures::{Sink, Stream}; use proc_macro2::Span; use serde::de::DeserializeOwned; use serde::Serialize; -use stageleft::Quoted; +use stageleft::QuotedWithContext; use super::built::build_inner; use super::compiled::CompiledFlow; diff --git a/hydroflow_plus/src/deploy/deploy_graph.rs b/hydroflow_plus/src/deploy/deploy_graph.rs index 44be80c17f58..15cb6f1aaf91 100644 --- a/hydroflow_plus/src/deploy/deploy_graph.rs +++ b/hydroflow_plus/src/deploy/deploy_graph.rs @@ -20,14 +20,11 @@ use hydroflow::util::deploy::{ConnectedSink, ConnectedSource}; use nameof::name_of; use serde::de::DeserializeOwned; use serde::Serialize; -use sha2::{Digest, Sha256}; -use stageleft::{Quoted, RuntimeData}; -use syn::visit_mut::VisitMut; +use stageleft::{QuotedWithContext, RuntimeData}; use tokio::sync::RwLock; -use trybuild_internals_api::path; use super::deploy_runtime::*; -use super::trybuild::{compile_graph_trybuild, create_trybuild}; +use super::trybuild::create_graph_trybuild; use super::{ClusterSpec, Deploy, ExternalSpec, IntoProcessSpec, Node, ProcessSpec, RegisterPort}; pub struct HydroDeploy {} @@ -373,14 +370,14 @@ impl<'a> Deploy<'a> for HydroDeploy { fn cluster_ids( _env: &Self::CompileEnv, of_cluster: usize, - ) -> impl Quoted<'a, &'a Vec> + Copy + 'a { + ) -> impl QuotedWithContext<'a, &'a Vec, ()> + Copy + 'a { cluster_members( RuntimeData::new("__hydroflow_plus_trybuild_cli"), of_cluster, ) } - fn cluster_self_id(_env: &Self::CompileEnv) -> impl Quoted<'a, u32> + Copy + 'a { + fn cluster_self_id(_env: &Self::CompileEnv) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a { cluster_self_id(RuntimeData::new("__hydroflow_plus_trybuild_cli")) } } @@ -872,119 +869,6 @@ impl, I: IntoIterator> ClusterSpec<'_, HydroDepl } } -fn clean_name_hint(name_hint: &str) -> String { - name_hint - .replace("::", "__") - .replace(" ", "_") - .replace(",", "_") - .replace("<", "_") - .replace(">", "") - .replace("(", "") - .replace(")", "") -} - -// TODO(shadaj): has to be public due to stageleft limitations -#[doc(hidden)] -pub struct ReplaceCrateNameWithStaged { - pub crate_name: String, -} - -impl VisitMut for ReplaceCrateNameWithStaged { - fn visit_type_path_mut(&mut self, i: &mut syn::TypePath) { - if let Some(first) = i.path.segments.first() { - if first.ident == self.crate_name { - let tail = i.path.segments.iter().skip(1).collect::>(); - *i = syn::parse_quote!(crate::__staged #(::#tail)*); - } - } - - syn::visit_mut::visit_type_path_mut(self, i); - } -} - -// TODO(shadaj): has to be public due to stageleft limitations -#[doc(hidden)] -pub struct ReplaceCrateWithOrig { - pub crate_name: String, -} - -impl VisitMut for ReplaceCrateWithOrig { - fn visit_item_use_mut(&mut self, i: &mut syn::ItemUse) { - if let syn::UseTree::Path(p) = &mut i.tree { - if p.ident == "crate" { - p.ident = syn::Ident::new(&self.crate_name, p.ident.span()); - i.leading_colon = Some(Default::default()); - } - } - - syn::visit_mut::visit_item_use_mut(self, i); - } -} - -fn create_graph_trybuild( - graph: HydroflowGraph, - extra_stmts: Vec, - name_hint: &Option, -) -> ( - String, - (std::path::PathBuf, std::path::PathBuf, Option>), -) { - let source_dir = trybuild_internals_api::cargo::manifest_dir().unwrap(); - let source_manifest = trybuild_internals_api::dependencies::get_manifest(&source_dir).unwrap(); - let crate_name = &source_manifest.package.name.to_string().replace("-", "_"); - - let is_test = super::trybuild::IS_TEST.load(std::sync::atomic::Ordering::Relaxed); - - let mut generated_code = compile_graph_trybuild(graph, extra_stmts); - - ReplaceCrateNameWithStaged { - crate_name: crate_name.clone(), - } - .visit_file_mut(&mut generated_code); - - let mut inlined_staged = stageleft_tool::gen_staged_trybuild( - &path!(source_dir / "src" / "lib.rs"), - crate_name.clone(), - is_test, - ); - - ReplaceCrateWithOrig { - crate_name: crate_name.clone(), - } - .visit_file_mut(&mut inlined_staged); - - let source = prettyplease::unparse(&syn::parse_quote! { - #generated_code - - #[allow( - unused, - ambiguous_glob_reexports, - clippy::suspicious_else_formatting, - unexpected_cfgs, - reason = "generated code" - )] - pub mod __staged { - #inlined_staged - } - }); - - let mut hasher = Sha256::new(); - hasher.update(&source); - let hash = format!("{:X}", hasher.finalize()) - .chars() - .take(8) - .collect::(); - - let bin_name = if let Some(name_hint) = &name_hint { - format!("{}_{}", clean_name_hint(name_hint), &hash) - } else { - hash - }; - - let trybuild_created = create_trybuild(&source, &bin_name, is_test).unwrap(); - (bin_name, trybuild_created) -} - fn create_trybuild_service( trybuild: TrybuildHost, dir: &std::path::PathBuf, diff --git a/hydroflow_plus/src/deploy/deploy_runtime.rs b/hydroflow_plus/src/deploy/deploy_runtime.rs index ad81b8b76d22..14b383c42d03 100644 --- a/hydroflow_plus/src/deploy/deploy_runtime.rs +++ b/hydroflow_plus/src/deploy/deploy_runtime.rs @@ -4,7 +4,7 @@ use hydroflow::util::deploy::{ ConnectedDemux, ConnectedDirect, ConnectedSink, ConnectedSource, ConnectedTagged, DeployPorts, }; use serde::{Deserialize, Serialize}; -use stageleft::{q, Quoted, RuntimeData}; +use stageleft::{q, QuotedWithContext, RuntimeData}; #[derive(Default, Serialize, Deserialize)] pub struct HydroflowPlusMeta { @@ -16,13 +16,13 @@ pub struct HydroflowPlusMeta { pub fn cluster_members( cli: RuntimeData<&DeployPorts>, of_cluster: usize, -) -> impl Quoted<&Vec> + Copy { +) -> impl QuotedWithContext<&Vec, ()> + Copy { q!(cli.meta.clusters.get(&of_cluster).unwrap()) } pub fn cluster_self_id( cli: RuntimeData<&DeployPorts>, -) -> impl Quoted + Copy { +) -> impl QuotedWithContext + Copy { q!(cli .meta .cluster_id @@ -41,7 +41,7 @@ pub fn deploy_o2o( .connect_local_blocking::() .into_sink() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, { q!({ @@ -49,7 +49,7 @@ pub fn deploy_o2o( .connect_local_blocking::() .into_source() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, ) } @@ -66,7 +66,7 @@ pub fn deploy_o2m( .connect_local_blocking::>() .into_sink() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, { q!({ @@ -74,7 +74,7 @@ pub fn deploy_o2m( .connect_local_blocking::() .into_source() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, ) } @@ -91,7 +91,7 @@ pub fn deploy_m2o( .connect_local_blocking::() .into_sink() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, { q!({ @@ -99,7 +99,7 @@ pub fn deploy_m2o( .connect_local_blocking::>() .into_source() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, ) } @@ -116,7 +116,7 @@ pub fn deploy_m2m( .connect_local_blocking::>() .into_sink() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, { q!({ @@ -124,7 +124,7 @@ pub fn deploy_m2m( .connect_local_blocking::>() .into_source() }) - .splice_untyped() + .splice_untyped_ctx(&()) }, ) } @@ -139,7 +139,7 @@ pub fn deploy_e2o( .connect_local_blocking::() .into_source() }) - .splice_untyped() + .splice_untyped_ctx(&()) } pub fn deploy_o2e( @@ -152,5 +152,5 @@ pub fn deploy_o2e( .connect_local_blocking::() .into_sink() }) - .splice_untyped() + .splice_untyped_ctx(&()) } diff --git a/hydroflow_plus/src/deploy/macro_runtime.rs b/hydroflow_plus/src/deploy/macro_runtime.rs index 5ff3c2533177..50eb298d971a 100644 --- a/hydroflow_plus/src/deploy/macro_runtime.rs +++ b/hydroflow_plus/src/deploy/macro_runtime.rs @@ -7,7 +7,7 @@ use hydroflow::bytes::Bytes; use hydroflow::futures::{Sink, Stream}; use hydroflow::util::deploy::DeployPorts; use hydroflow_lang::graph::HydroflowGraph; -use stageleft::{Quoted, RuntimeData}; +use stageleft::{QuotedWithContext, RuntimeData}; use super::HydroflowPlusMeta; use crate::deploy::{ClusterSpec, Deploy, ExternalSpec, Node, ProcessSpec, RegisterPort}; @@ -170,11 +170,11 @@ impl<'a> Deploy<'a> for DeployRuntime { fn cluster_ids( env: &Self::CompileEnv, of_cluster: usize, - ) -> impl Quoted<'a, &'a Vec> + Copy + 'a { + ) -> impl QuotedWithContext<'a, &'a Vec, ()> + Copy + 'a { super::deploy_runtime::cluster_members(*env, of_cluster) } - fn cluster_self_id(env: &Self::CompileEnv) -> impl Quoted<'a, u32> + Copy + 'a { + fn cluster_self_id(env: &Self::CompileEnv) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a { super::deploy_runtime::cluster_self_id(*env) } } diff --git a/hydroflow_plus/src/deploy/mod.rs b/hydroflow_plus/src/deploy/mod.rs index d447bd23722a..8eee87ff035e 100644 --- a/hydroflow_plus/src/deploy/mod.rs +++ b/hydroflow_plus/src/deploy/mod.rs @@ -7,7 +7,7 @@ use hydroflow::futures::{Sink, Stream}; use hydroflow_lang::graph::HydroflowGraph; use serde::de::DeserializeOwned; use serde::Serialize; -use stageleft::Quoted; +use stageleft::QuotedWithContext; #[cfg(feature = "deploy_runtime")] pub mod macro_runtime; @@ -15,6 +15,11 @@ pub mod macro_runtime; #[cfg(feature = "deploy")] pub(crate) mod trybuild; +// TODO(shadaj): has to be public due to stageleft limitations +#[cfg(feature = "deploy")] +#[doc(hidden)] +pub mod trybuild_rewriters; + pub use macro_runtime::*; #[cfg(feature = "deploy")] pub use trybuild::init_test; @@ -171,8 +176,8 @@ pub trait Deploy<'a> { fn cluster_ids( env: &Self::CompileEnv, of_cluster: usize, - ) -> impl Quoted<'a, &'a Vec> + Copy + 'a; - fn cluster_self_id(env: &Self::CompileEnv) -> impl Quoted<'a, u32> + Copy + 'a; + ) -> impl QuotedWithContext<'a, &'a Vec, ()> + Copy + 'a; + fn cluster_self_id(env: &Self::CompileEnv) -> impl QuotedWithContext<'a, u32, ()> + Copy + 'a; } impl< diff --git a/hydroflow_plus/src/deploy/trybuild.rs b/hydroflow_plus/src/deploy/trybuild.rs index a517659579e3..479d25962e92 100644 --- a/hydroflow_plus/src/deploy/trybuild.rs +++ b/hydroflow_plus/src/deploy/trybuild.rs @@ -2,18 +2,94 @@ use std::fs; use std::path::PathBuf; use hydroflow_lang::graph::{partition_graph, HydroflowGraph}; +use sha2::{Digest, Sha256}; use stageleft::internal::quote; +use syn::visit_mut::VisitMut; use trybuild_internals_api::cargo::{self, Metadata}; use trybuild_internals_api::env::Update; use trybuild_internals_api::run::{PathDependency, Project}; use trybuild_internals_api::{dependencies, features, path, Runner}; -pub static IS_TEST: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); +use super::trybuild_rewriters::{ReplaceCrateNameWithStaged, ReplaceCrateWithOrig}; + +static IS_TEST: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); pub fn init_test() { IS_TEST.store(true, std::sync::atomic::Ordering::Relaxed); } +fn clean_name_hint(name_hint: &str) -> String { + name_hint + .replace("::", "__") + .replace(" ", "_") + .replace(",", "_") + .replace("<", "_") + .replace(">", "") + .replace("(", "") + .replace(")", "") +} + +pub fn create_graph_trybuild( + graph: HydroflowGraph, + extra_stmts: Vec, + name_hint: &Option, +) -> (String, (PathBuf, PathBuf, Option>)) { + let source_dir = cargo::manifest_dir().unwrap(); + let source_manifest = dependencies::get_manifest(&source_dir).unwrap(); + let crate_name = &source_manifest.package.name.to_string().replace("-", "_"); + + let is_test = IS_TEST.load(std::sync::atomic::Ordering::Relaxed); + + let mut generated_code = compile_graph_trybuild(graph, extra_stmts); + + ReplaceCrateNameWithStaged { + crate_name: crate_name.clone(), + } + .visit_file_mut(&mut generated_code); + + let mut inlined_staged = stageleft_tool::gen_staged_trybuild( + &path!(source_dir / "src" / "lib.rs"), + crate_name.clone(), + is_test, + ); + + ReplaceCrateWithOrig { + crate_name: crate_name.clone(), + } + .visit_file_mut(&mut inlined_staged); + + let source = prettyplease::unparse(&syn::parse_quote! { + #generated_code + + #[allow( + unused, + ambiguous_glob_reexports, + clippy::suspicious_else_formatting, + unexpected_cfgs, + reason = "generated code" + )] + pub mod __staged { + #inlined_staged + } + }); + + let mut hasher = Sha256::new(); + hasher.update(&source); + let hash = format!("{:X}", hasher.finalize()) + .chars() + .take(8) + .collect::(); + + let bin_name = if let Some(name_hint) = &name_hint { + format!("{}_{}", clean_name_hint(name_hint), &hash) + } else { + hash + }; + + let trybuild_created = create_trybuild(&source, &bin_name, is_test).unwrap(); + (bin_name, trybuild_created) +} + pub fn compile_graph_trybuild(graph: HydroflowGraph, extra_stmts: Vec) -> syn::File { let partitioned_graph = partition_graph(graph).expect("Failed to partition (cycle detected)."); @@ -27,7 +103,7 @@ pub fn compile_graph_trybuild(graph: HydroflowGraph, extra_stmts: Vec let source_ast: syn::File = syn::parse_quote! { #![feature(box_patterns)] - #![allow(unused_imports, unused_crate_dependencies, missing_docs)] + #![allow(unused_imports, unused_crate_dependencies, missing_docs, non_snake_case)] use hydroflow_plus::*; #[allow(unused)] diff --git a/hydroflow_plus/src/deploy/trybuild_rewriters.rs b/hydroflow_plus/src/deploy/trybuild_rewriters.rs new file mode 100644 index 000000000000..6a9a14cafe73 --- /dev/null +++ b/hydroflow_plus/src/deploy/trybuild_rewriters.rs @@ -0,0 +1,35 @@ +use syn::visit_mut::VisitMut; + +pub struct ReplaceCrateNameWithStaged { + pub crate_name: String, +} + +impl VisitMut for ReplaceCrateNameWithStaged { + fn visit_type_path_mut(&mut self, i: &mut syn::TypePath) { + if let Some(first) = i.path.segments.first() { + if first.ident == self.crate_name { + let tail = i.path.segments.iter().skip(1).collect::>(); + *i = syn::parse_quote!(crate::__staged #(::#tail)*); + } + } + + syn::visit_mut::visit_type_path_mut(self, i); + } +} + +pub struct ReplaceCrateWithOrig { + pub crate_name: String, +} + +impl VisitMut for ReplaceCrateWithOrig { + fn visit_item_use_mut(&mut self, i: &mut syn::ItemUse) { + if let syn::UseTree::Path(p) = &mut i.tree { + if p.ident == "crate" { + p.ident = syn::Ident::new(&self.crate_name, p.ident.span()); + i.leading_colon = Some(Default::default()); + } + } + + syn::visit_mut::visit_item_use_mut(self, i); + } +} diff --git a/hydroflow_plus/src/lib.rs b/hydroflow_plus/src/lib.rs index 3a0161107214..e6e4af74fd81 100644 --- a/hydroflow_plus/src/lib.rs +++ b/hydroflow_plus/src/lib.rs @@ -26,6 +26,7 @@ pub mod optional; pub use optional::Optional; pub mod location; +pub use location::cluster::CLUSTER_SELF_ID; pub use location::{Cluster, ClusterId, Location, Process, Tick}; pub mod deploy; diff --git a/hydroflow_plus/src/location/cluster.rs b/hydroflow_plus/src/location/cluster.rs deleted file mode 100644 index 695bce5d875a..000000000000 --- a/hydroflow_plus/src/location/cluster.rs +++ /dev/null @@ -1,207 +0,0 @@ -use std::fmt::{Debug, Display}; -use std::hash::Hash; -use std::marker::PhantomData; - -use proc_macro2::{Span, TokenStream}; -use quote::quote; -use serde::{Deserialize, Serialize}; -use stageleft::runtime_support::FreeVariable; -use stageleft::{quote_type, Quoted}; - -use super::{Location, LocationId}; -use crate::builder::FlowState; -use crate::staging_util::{get_this_crate, Invariant}; - -pub struct Cluster<'a, C> { - pub(crate) id: usize, - pub(crate) flow_state: FlowState, - pub(crate) _phantom: Invariant<'a, C>, -} - -impl<'a, C> Cluster<'a, C> { - pub fn self_id(&self) -> impl Quoted<'a, ClusterId> + Copy { - ClusterSelfId { - id: self.id, - _phantom: PhantomData, - } - } - - pub fn members(&self) -> impl Quoted<'a, &'a Vec>> + Copy { - ClusterIds { - id: self.id, - _phantom: PhantomData, - } - } -} - -impl Clone for Cluster<'_, C> { - fn clone(&self) -> Self { - Cluster { - id: self.id, - flow_state: self.flow_state.clone(), - _phantom: PhantomData, - } - } -} - -impl<'a, C> Location<'a> for Cluster<'a, C> { - fn id(&self) -> LocationId { - LocationId::Cluster(self.id) - } - - fn flow_state(&self) -> &FlowState { - &self.flow_state - } - - fn is_top_level() -> bool { - true - } -} - -#[repr(transparent)] -pub struct ClusterId { - pub raw_id: u32, - pub(crate) _phantom: PhantomData, -} - -impl Debug for ClusterId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "ClusterId::<{}>({})", - std::any::type_name::(), - self.raw_id - ) - } -} - -impl Display for ClusterId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "ClusterId::<{}>({})", - std::any::type_name::(), - self.raw_id - ) - } -} - -impl Clone for ClusterId { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterId {} - -impl Serialize for ClusterId { - fn serialize(&self, serializer: S) -> Result - where - S: serde::ser::Serializer, - { - self.raw_id.serialize(serializer) - } -} - -impl<'de, C> Deserialize<'de> for ClusterId { - fn deserialize(deserializer: D) -> Result - where - D: serde::de::Deserializer<'de>, - { - u32::deserialize(deserializer).map(|id| ClusterId { - raw_id: id, - _phantom: PhantomData, - }) - } -} - -impl PartialEq for ClusterId { - fn eq(&self, other: &Self) -> bool { - self.raw_id == other.raw_id - } -} - -impl Eq for ClusterId {} - -impl Hash for ClusterId { - fn hash(&self, state: &mut H) { - self.raw_id.hash(state) - } -} - -impl ClusterId { - pub fn from_raw(id: u32) -> Self { - ClusterId { - raw_id: id, - _phantom: PhantomData, - } - } -} - -pub struct ClusterIds<'a, C> { - pub(crate) id: usize, - _phantom: Invariant<'a, C>, -} - -impl Clone for ClusterIds<'_, C> { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterIds<'_, C> {} - -impl<'a, C> FreeVariable<&'a Vec>> for ClusterIds<'a, C> { - fn to_tokens(self) -> (Option, Option) - where - Self: Sized, - { - let ident = syn::Ident::new( - &format!("__hydroflow_plus_cluster_ids_{}", self.id), - Span::call_site(), - ); - let root = get_this_crate(); - let c_type = quote_type::(); - ( - None, - Some( - quote! { unsafe { ::std::mem::transmute::<_, &::std::vec::Vec<#root::ClusterId<#c_type>>>(#ident) } }, - ), - ) - } -} - -impl<'a, C> Quoted<'a, &'a Vec>> for ClusterIds<'a, C> {} - -pub struct ClusterSelfId<'a, C> { - pub(crate) id: usize, - pub(crate) _phantom: Invariant<'a, C>, -} - -impl Clone for ClusterSelfId<'_, C> { - fn clone(&self) -> Self { - *self - } -} - -impl Copy for ClusterSelfId<'_, C> {} - -impl FreeVariable> for ClusterSelfId<'_, C> { - fn to_tokens(self) -> (Option, Option) - where - Self: Sized, - { - let ident = syn::Ident::new( - &format!("__hydroflow_plus_cluster_self_id_{}", self.id), - Span::call_site(), - ); - let root = get_this_crate(); - let c_type: syn::Type = quote_type::(); - ( - None, - Some(quote! { #root::ClusterId::<#c_type>::from_raw(#ident) }), - ) - } -} - -impl<'a, C> Quoted<'a, ClusterId> for ClusterSelfId<'a, C> {} diff --git a/hydroflow_plus/src/location/cluster/cluster_id.rs b/hydroflow_plus/src/location/cluster/cluster_id.rs new file mode 100644 index 000000000000..3fb3b2d91cb5 --- /dev/null +++ b/hydroflow_plus/src/location/cluster/cluster_id.rs @@ -0,0 +1,85 @@ +use std::fmt::{Debug, Display}; +use std::hash::Hash; +use std::marker::PhantomData; + +use serde::{Deserialize, Serialize}; + +#[repr(transparent)] +pub struct ClusterId { + pub raw_id: u32, + pub(crate) _phantom: PhantomData, +} + +impl Debug for ClusterId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "ClusterId::<{}>({})", + std::any::type_name::(), + self.raw_id + ) + } +} + +impl Display for ClusterId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "ClusterId::<{}>({})", + std::any::type_name::(), + self.raw_id + ) + } +} + +impl Clone for ClusterId { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for ClusterId {} + +impl Serialize for ClusterId { + fn serialize(&self, serializer: S) -> Result + where + S: serde::ser::Serializer, + { + self.raw_id.serialize(serializer) + } +} + +impl<'de, C> Deserialize<'de> for ClusterId { + fn deserialize(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + u32::deserialize(deserializer).map(|id| ClusterId { + raw_id: id, + _phantom: PhantomData, + }) + } +} + +impl PartialEq for ClusterId { + fn eq(&self, other: &Self) -> bool { + self.raw_id == other.raw_id + } +} + +impl Eq for ClusterId {} + +impl Hash for ClusterId { + fn hash(&self, state: &mut H) { + self.raw_id.hash(state) + } +} + +impl ClusterId { + pub fn from_raw(id: u32) -> Self { + ClusterId { + raw_id: id, + _phantom: PhantomData, + } + } +} diff --git a/hydroflow_plus/src/location/cluster/mod.rs b/hydroflow_plus/src/location/cluster/mod.rs new file mode 100644 index 000000000000..cfd83e195d8d --- /dev/null +++ b/hydroflow_plus/src/location/cluster/mod.rs @@ -0,0 +1,147 @@ +use std::marker::PhantomData; + +use proc_macro2::{Span, TokenStream}; +use quote::quote; +use stageleft::runtime_support::FreeVariableWithContext; +use stageleft::{quote_type, QuotedWithContext}; + +use super::{Location, LocationId}; +use crate::builder::FlowState; +use crate::staging_util::{get_this_crate, Invariant}; + +pub mod cluster_id; +pub use cluster_id::ClusterId; + +pub struct Cluster<'a, C> { + pub(crate) id: usize, + pub(crate) flow_state: FlowState, + pub(crate) _phantom: Invariant<'a, C>, +} + +pub trait IsCluster { + type Tag; + fn id(&self) -> usize; +} + +impl IsCluster for Cluster<'_, C> { + type Tag = C; + fn id(&self) -> usize { + self.id + } +} + +impl<'a, C> Cluster<'a, C> { + pub fn members(&self) -> ClusterIds<'a, C> { + ClusterIds { + id: self.id, + _phantom: PhantomData, + } + } +} + +impl Clone for Cluster<'_, C> { + fn clone(&self) -> Self { + Cluster { + id: self.id, + flow_state: self.flow_state.clone(), + _phantom: PhantomData, + } + } +} + +impl<'a, C> Location<'a> for Cluster<'a, C> { + type Root = Cluster<'a, C>; + + fn root(&self) -> Self::Root { + self.clone() + } + + fn id(&self) -> LocationId { + LocationId::Cluster(self.id) + } + + fn flow_state(&self) -> &FlowState { + &self.flow_state + } + + fn is_top_level() -> bool { + true + } +} + +pub struct ClusterIds<'a, C> { + pub(crate) id: usize, + _phantom: Invariant<'a, C>, +} + +impl Clone for ClusterIds<'_, C> { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for ClusterIds<'_, C> {} + +impl<'a, C: 'a, Ctx> FreeVariableWithContext for ClusterIds<'a, C> { + type O = &'a Vec>; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) + where + Self: Sized, + { + let ident = syn::Ident::new( + &format!("__hydroflow_plus_cluster_ids_{}", self.id), + Span::call_site(), + ); + let root = get_this_crate(); + let c_type = quote_type::(); + ( + None, + Some( + quote! { unsafe { ::std::mem::transmute::<_, &::std::vec::Vec<#root::ClusterId<#c_type>>>(#ident) } }, + ), + ) + } +} + +impl<'a, C, Ctx> QuotedWithContext<'a, &'a Vec>, Ctx> for ClusterIds<'a, C> {} + +/// A free variable representing the cluster's own ID. When spliced in +/// a quoted snippet that will run on a cluster, this turns into a [`ClusterId`]. +pub static CLUSTER_SELF_ID: ClusterSelfId = ClusterSelfId { _private: &() }; + +#[derive(Clone, Copy)] +pub struct ClusterSelfId<'a> { + _private: &'a (), +} + +impl<'a, L: Location<'a>> FreeVariableWithContext for ClusterSelfId<'a> +where + >::Root: IsCluster, +{ + type O = ClusterId<<>::Root as IsCluster>::Tag>; + + fn to_tokens(self, ctx: &L) -> (Option, Option) + where + Self: Sized, + { + let ident = syn::Ident::new( + &format!("__hydroflow_plus_cluster_self_id_{}", ctx.root().id()), + Span::call_site(), + ); + let root = get_this_crate(); + let c_type: syn::Type = quote_type::<<>::Root as IsCluster>::Tag>(); + ( + None, + Some(quote! { #root::ClusterId::<#c_type>::from_raw(#ident) }), + ) + } +} + +impl<'a, L: Location<'a>> + QuotedWithContext<'a, ClusterId<<>::Root as IsCluster>::Tag>, L> + for ClusterSelfId<'a> +where + >::Root: IsCluster, +{ +} diff --git a/hydroflow_plus/src/location/external_process.rs b/hydroflow_plus/src/location/external_process.rs index cb6d24f95b49..103aabef8695 100644 --- a/hydroflow_plus/src/location/external_process.rs +++ b/hydroflow_plus/src/location/external_process.rs @@ -46,6 +46,12 @@ impl

Clone for ExternalProcess<'_, P> { } impl<'a, P> Location<'a> for ExternalProcess<'a, P> { + type Root = Self; + + fn root(&self) -> Self::Root { + self.clone() + } + fn id(&self) -> LocationId { LocationId::ExternalProcess(self.id) } diff --git a/hydroflow_plus/src/location/mod.rs b/hydroflow_plus/src/location/mod.rs index 061dfd1016cb..61693cb7c66f 100644 --- a/hydroflow_plus/src/location/mod.rs +++ b/hydroflow_plus/src/location/mod.rs @@ -5,7 +5,7 @@ use std::time::Duration; use hydroflow::futures::stream::Stream as FuturesStream; use hydroflow::{tokio, tokio_stream}; use proc_macro2::Span; -use stageleft::{q, Quoted}; +use stageleft::{q, QuotedWithContext}; use super::builder::FlowState; use crate::cycle::{CycleCollection, ForwardRef, ForwardRefMarker}; @@ -60,6 +60,10 @@ pub fn check_matching_location<'a, L: Location<'a>>(l1: &L, l2: &L) { } pub trait Location<'a>: Clone { + type Root; + + fn root(&self) -> Self::Root; + fn id(&self) -> LocationId; fn flow_state(&self) -> &FlowState; @@ -93,12 +97,12 @@ pub trait Location<'a>: Clone { fn source_stream + Unpin>( &self, - e: impl Quoted<'a, E>, + e: impl QuotedWithContext<'a, E, Self>, ) -> Stream where Self: Sized + NoTick, { - let e = e.splice_untyped(); + let e = e.splice_untyped_ctx(self); Stream::new( self.clone(), @@ -111,14 +115,14 @@ pub trait Location<'a>: Clone { fn source_iter>( &self, - e: impl Quoted<'a, E>, + e: impl QuotedWithContext<'a, E, Self>, ) -> Stream where Self: Sized + NoTick, { // TODO(shadaj): we mark this as unbounded because we do not yet have a representation // for bounded top-level streams, and this is the only way to generate one - let e = e.splice_untyped(); + let e = e.splice_untyped_ctx(self); Stream::new( self.clone(), @@ -129,7 +133,10 @@ pub trait Location<'a>: Clone { ) } - fn singleton(&self, e: impl Quoted<'a, T>) -> Singleton + fn singleton( + &self, + e: impl QuotedWithContext<'a, T, Self>, + ) -> Singleton where Self: Sized + NoTick, { @@ -137,7 +144,7 @@ pub trait Location<'a>: Clone { // for bounded top-level singletons, and this is the only way to generate one let e_arr = q!([e]); - let e = e_arr.splice_untyped(); + let e = e_arr.splice_untyped_ctx(self); // we do a double persist here because if the singleton shows up on every tick, // we first persist the source so that we store that value and then persist again @@ -155,7 +162,7 @@ pub trait Location<'a>: Clone { fn source_interval( &self, - interval: impl Quoted<'a, Duration> + Copy + 'a, + interval: impl QuotedWithContext<'a, Duration, Self> + Copy + 'a, ) -> Stream where Self: Sized + NoTick, @@ -167,8 +174,8 @@ pub trait Location<'a>: Clone { fn source_interval_delayed( &self, - delay: impl Quoted<'a, Duration> + Copy + 'a, - interval: impl Quoted<'a, Duration> + Copy + 'a, + delay: impl QuotedWithContext<'a, Duration, Self> + Copy + 'a, + interval: impl QuotedWithContext<'a, Duration, Self> + Copy + 'a, ) -> Stream where Self: Sized + NoTick, diff --git a/hydroflow_plus/src/location/process.rs b/hydroflow_plus/src/location/process.rs index dcac7c3b0bc7..417cc92165cd 100644 --- a/hydroflow_plus/src/location/process.rs +++ b/hydroflow_plus/src/location/process.rs @@ -21,6 +21,12 @@ impl

Clone for Process<'_, P> { } impl<'a, P> Location<'a> for Process<'a, P> { + type Root = Self; + + fn root(&self) -> Self::Root { + self.clone() + } + fn id(&self) -> LocationId { LocationId::Process(self.id) } diff --git a/hydroflow_plus/src/location/tick.rs b/hydroflow_plus/src/location/tick.rs index 3e9e8074baf3..809a750c9bca 100644 --- a/hydroflow_plus/src/location/tick.rs +++ b/hydroflow_plus/src/location/tick.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use proc_macro2::Span; -use stageleft::{q, Quoted}; +use stageleft::{q, QuotedWithContext}; use super::{Cluster, Location, LocationId, Process}; use crate::builder::FlowState; @@ -24,6 +24,12 @@ pub struct Tick { } impl<'a, L: Location<'a>> Location<'a> for Tick { + type Root = L::Root; + + fn root(&self) -> Self::Root { + self.l.root() + } + fn id(&self) -> LocationId { LocationId::Tick(self.id, Box::new(self.l.id())) } @@ -44,7 +50,7 @@ impl<'a, L: Location<'a>> Tick { pub fn spin_batch( &self, - batch_size: impl Quoted<'a, usize> + Copy + 'a, + batch_size: impl QuotedWithContext<'a, usize, L> + Copy + 'a, ) -> Stream<(), Self, Bounded> where L: NoTick, @@ -56,7 +62,10 @@ impl<'a, L: Location<'a>> Tick { .tick_batch(self) } - pub fn singleton(&self, e: impl Quoted<'a, T>) -> Singleton + pub fn singleton( + &self, + e: impl QuotedWithContext<'a, T, L>, + ) -> Singleton where L: NoTick, { @@ -65,13 +74,13 @@ impl<'a, L: Location<'a>> Tick { pub fn singleton_first_tick( &self, - e: impl Quoted<'a, T>, + e: impl QuotedWithContext<'a, T, Tick>, ) -> Optional where L: NoTick, { let e_arr = q!([e]); - let e = e_arr.splice_untyped(); + let e = e_arr.splice_untyped_ctx(self); Optional::new( self.clone(), diff --git a/hydroflow_plus/src/optional.rs b/hydroflow_plus/src/optional.rs index 4387101308bd..9fa8609d5297 100644 --- a/hydroflow_plus/src/optional.rs +++ b/hydroflow_plus/src/optional.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use std::ops::Deref; use std::rc::Rc; -use stageleft::{q, IntoQuotedMut, Quoted}; +use stageleft::{q, IntoQuotedMut, QuotedWithContext}; use syn::parse_quote; use crate::builder::FLOW_USED_MESSAGE; @@ -188,11 +188,12 @@ impl<'a, T, L: Location<'a>, B> Optional { Stream::new(self.location, self.ir_node.into_inner()) } - pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { + pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F, L>) -> Optional { + let f = f.splice_fn1_ctx(&self.location).into(); Optional::new( self.location, HfPlusNode::Map { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -200,22 +201,27 @@ impl<'a, T, L: Location<'a>, B> Optional { pub fn flat_map, F: Fn(T) -> I + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::FlatMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) } - pub fn filter bool + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { + pub fn filter bool + 'a>( + self, + f: impl IntoQuotedMut<'a, F, L>, + ) -> Optional { + let f = f.splice_fn1_borrow_ctx(&self.location).into(); Optional::new( self.location, HfPlusNode::Filter { - f: f.splice_fn1_borrow().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -223,12 +229,13 @@ impl<'a, T, L: Location<'a>, B> Optional { pub fn filter_map Option + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Optional { + let f = f.splice_fn1_ctx(&self.location).into(); Optional::new( self.location, HfPlusNode::FilterMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -356,7 +363,7 @@ impl<'a, T, L: Location<'a> + NoTick, B> Optional { pub fn sample_every( self, - interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl QuotedWithContext<'a, std::time::Duration, L> + Copy + 'a, ) -> Stream { let samples = self.location.source_interval(interval); let tick = self.location.tick(); diff --git a/hydroflow_plus/src/rewrites/profiler.rs b/hydroflow_plus/src/rewrites/profiler.rs index be9b030bd83b..e7d344a8f459 100644 --- a/hydroflow_plus/src/rewrites/profiler.rs +++ b/hydroflow_plus/src/rewrites/profiler.rs @@ -11,7 +11,7 @@ pub fn increment_counter(count: &mut u64) { *count += 1; } -fn quoted_any_fn<'a, F: Fn(&usize) + 'a, Q: IntoQuotedMut<'a, F>>(q: Q) -> Q { +fn quoted_any_fn<'a, F: Fn(&usize) + 'a, Q: IntoQuotedMut<'a, F, ()>>(q: Q) -> Q { q } diff --git a/hydroflow_plus/src/rewrites/properties.rs b/hydroflow_plus/src/rewrites/properties.rs index 5d5ce0d3edf5..f09b8a119266 100644 --- a/hydroflow_plus/src/rewrites/properties.rs +++ b/hydroflow_plus/src/rewrites/properties.rs @@ -34,12 +34,20 @@ fn convert_hf_to_binary(f: F) -> impl Fn(I, I) impl PropertyDatabase { /// Tags the expression as commutative. - pub fn add_commutative_tag<'a, I, A, F: Fn(&mut A, I), Q: Quoted<'a, F> + Clone>( + pub fn add_commutative_tag< + 'a, + I, + A, + F: Fn(&mut A, I), + Ctx, + Q: QuotedWithContext<'a, F, Ctx> + Clone, + >( &mut self, expr: Q, + ctx: &Ctx, ) -> Q { let expr_clone = expr.clone(); - self.commutative.insert(expr_clone.splice_untyped()); + self.commutative.insert(expr_clone.splice_untyped_ctx(ctx)); expr } @@ -91,11 +99,15 @@ mod tests { fn test_property_database() { let mut db = PropertyDatabase::default(); - assert!(!db.is_tagged_commutative(&(q!(|a: &mut i32, b: i32| *a += b).splice_untyped()))); + assert!( + !db.is_tagged_commutative(&(q!(|a: &mut i32, b: i32| *a += b).splice_untyped_ctx(&()))) + ); - let _ = db.add_commutative_tag(q!(|a: &mut i32, b: i32| *a += b)); + let _ = db.add_commutative_tag(q!(|a: &mut i32, b: i32| *a += b), &()); - assert!(db.is_tagged_commutative(&(q!(|a: &mut i32, b: i32| *a += b).splice_untyped()))); + assert!( + db.is_tagged_commutative(&(q!(|a: &mut i32, b: i32| *a += b).splice_untyped_ctx(&()))) + ); } #[test] @@ -107,7 +119,7 @@ mod tests { let tick = process.tick(); let counter_func = q!(|count: &mut i32, _| *count += 1); - let _ = database.add_commutative_tag(counter_func); + let _ = database.add_commutative_tag(counter_func, &tick); process .source_iter(q!(vec![])) diff --git a/hydroflow_plus/src/rewrites/snapshots/hydroflow_plus__rewrites__profiler__tests__profiler_wrapping_all_operators-2.snap b/hydroflow_plus/src/rewrites/snapshots/hydroflow_plus__rewrites__profiler__tests__profiler_wrapping_all_operators-2.snap index 627f53dd38ed..cb1775df747b 100644 --- a/hydroflow_plus/src/rewrites/snapshots/hydroflow_plus__rewrites__profiler__tests__profiler_wrapping_all_operators-2.snap +++ b/hydroflow_plus/src/rewrites/snapshots/hydroflow_plus__rewrites__profiler__tests__profiler_wrapping_all_operators-2.snap @@ -6,11 +6,11 @@ expression: "&pushed_down.ir()" ForEach { f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , () > ({ use crate :: __staged :: rewrites :: profiler :: tests :: * ; | n | println ! ("{}" , n) }), input: Inspect { - f: { use crate :: __staged :: rewrites :: profiler :: * ; let counter_queue = Fake ; let counters = Fake ; let my_id = 0u32 ; { counter_queue . borrow () . unbounded_send ((my_id as usize , counters . borrow () [my_id as usize])) . unwrap () ; counters . borrow_mut () [my_id as usize] = 0 ; move | _ | { myself :: increment_counter (& mut counters . borrow_mut () [my_id as usize]) ; } } }, + f: { use crate :: __staged :: rewrites :: profiler :: * ; let counter_queue__free = Fake ; let counters__free = Fake ; let my_id__free = 0u32 ; { counter_queue__free . borrow () . unbounded_send ((my_id__free as usize , counters__free . borrow () [my_id__free as usize])) . unwrap () ; counters__free . borrow_mut () [my_id__free as usize] = 0 ; move | _ | { myself :: increment_counter (& mut counters__free . borrow_mut () [my_id__free as usize]) ; } } }, input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , i32 > ({ use crate :: __staged :: rewrites :: profiler :: tests :: * ; | v | v + 1 }), input: Inspect { - f: { use crate :: __staged :: rewrites :: profiler :: * ; let counter_queue = Fake ; let counters = Fake ; let my_id = 1u32 ; { counter_queue . borrow () . unbounded_send ((my_id as usize , counters . borrow () [my_id as usize])) . unwrap () ; counters . borrow_mut () [my_id as usize] = 0 ; move | _ | { myself :: increment_counter (& mut counters . borrow_mut () [my_id as usize]) ; } } }, + f: { use crate :: __staged :: rewrites :: profiler :: * ; let counter_queue__free = Fake ; let counters__free = Fake ; let my_id__free = 1u32 ; { counter_queue__free . borrow () . unbounded_send ((my_id__free as usize , counters__free . borrow () [my_id__free as usize])) . unwrap () ; counters__free . borrow_mut () [my_id__free as usize] = 0 ; move | _ | { myself :: increment_counter (& mut counters__free . borrow_mut () [my_id__free as usize]) ; } } }, input: Source { source: Iter( { use crate :: __staged :: rewrites :: profiler :: tests :: * ; 0 .. 10 }, diff --git a/hydroflow_plus/src/runtime_context.rs b/hydroflow_plus/src/runtime_context.rs index 50e3db945035..6f93a186cbb3 100644 --- a/hydroflow_plus/src/runtime_context.rs +++ b/hydroflow_plus/src/runtime_context.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use hydroflow::scheduled::context::Context; use proc_macro2::TokenStream; use quote::quote; -use stageleft::runtime_support::FreeVariable; +use stageleft::runtime_support::FreeVariableWithContext; use crate::staging_util::Invariant; @@ -28,8 +28,10 @@ impl Default for RuntimeContext<'_> { } } -impl<'a> FreeVariable<&'a Context> for RuntimeContext<'a> { - fn to_tokens(self) -> (Option, Option) { +impl<'a, Ctx> FreeVariableWithContext for RuntimeContext<'a> { + type O = &'a Context; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { (None, Some(quote!(&context))) } } diff --git a/hydroflow_plus/src/singleton.rs b/hydroflow_plus/src/singleton.rs index 35dcdcb08377..f89957e51dc2 100644 --- a/hydroflow_plus/src/singleton.rs +++ b/hydroflow_plus/src/singleton.rs @@ -3,7 +3,7 @@ use std::marker::PhantomData; use std::ops::Deref; use std::rc::Rc; -use stageleft::{q, IntoQuotedMut, Quoted}; +use stageleft::{q, IntoQuotedMut, QuotedWithContext}; use crate::builder::FLOW_USED_MESSAGE; use crate::cycle::{ @@ -148,11 +148,12 @@ impl<'a, T, L: Location<'a>, B> Singleton { Stream::new(self.location, self.ir_node.into_inner()) } - pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Singleton { + pub fn map U + 'a>(self, f: impl IntoQuotedMut<'a, F, L>) -> Singleton { + let f = f.splice_fn1_ctx(&self.location).into(); Singleton::new( self.location, HfPlusNode::Map { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -160,22 +161,27 @@ impl<'a, T, L: Location<'a>, B> Singleton { pub fn flat_map, F: Fn(T) -> I + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::FlatMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) } - pub fn filter bool + 'a>(self, f: impl IntoQuotedMut<'a, F>) -> Optional { + pub fn filter bool + 'a>( + self, + f: impl IntoQuotedMut<'a, F, L>, + ) -> Optional { + let f = f.splice_fn1_borrow_ctx(&self.location).into(); Optional::new( self.location, HfPlusNode::Filter { - f: f.splice_fn1_borrow().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -183,12 +189,13 @@ impl<'a, T, L: Location<'a>, B> Singleton { pub fn filter_map Option + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Optional { + let f = f.splice_fn1_ctx(&self.location).into(); Optional::new( self.location, HfPlusNode::FilterMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -245,7 +252,7 @@ impl<'a, T, L: Location<'a> + NoTick, B> Singleton { pub fn sample_every( self, - interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl QuotedWithContext<'a, std::time::Duration, L> + Copy + 'a, ) -> Stream { let samples = self.location.source_interval(interval); let tick = self.location.tick(); diff --git a/hydroflow_plus/src/stream.rs b/hydroflow_plus/src/stream.rs index 0ec265a48f5d..266c64500e16 100644 --- a/hydroflow_plus/src/stream.rs +++ b/hydroflow_plus/src/stream.rs @@ -9,13 +9,13 @@ use hydroflow::futures; use hydroflow_lang::parse::Pipeline; use serde::de::DeserializeOwned; use serde::Serialize; -use stageleft::{q, IntoQuotedMut, Quoted}; +use stageleft::{q, IntoQuotedMut, QuotedWithContext}; use syn::parse_quote; use crate::builder::FLOW_USED_MESSAGE; use crate::cycle::{CycleCollection, CycleComplete, DeferTick, ForwardRefMarker, TickCycleMarker}; use crate::ir::{DebugInstantiate, HfPlusLeaf, HfPlusNode, TeeNode}; -use crate::location::cluster::ClusterSelfId; +use crate::location::cluster::CLUSTER_SELF_ID; use crate::location::external_process::{ExternalBincodeStream, ExternalBytesPort}; use crate::location::{ check_matching_location, CanSend, ExternalProcess, Location, LocationId, NoTick, Tick, @@ -192,12 +192,13 @@ impl<'a, T: Clone, L: Location<'a>, B, Order> Clone for Stream { impl<'a, T, L: Location<'a>, B, Order> Stream { pub fn map U + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::Map { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -212,12 +213,13 @@ impl<'a, T, L: Location<'a>, B, Order> Stream { pub fn flat_map, F: Fn(T) -> I + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::FlatMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -232,12 +234,13 @@ impl<'a, T, L: Location<'a>, B, Order> Stream { pub fn filter bool + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_borrow_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::Filter { - f: f.splice_fn1_borrow().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -245,12 +248,13 @@ impl<'a, T, L: Location<'a>, B, Order> Stream { pub fn filter_map Option + 'a>( self, - f: impl IntoQuotedMut<'a, F>, + f: impl IntoQuotedMut<'a, F, L>, ) -> Stream { + let f = f.splice_fn1_ctx(&self.location).into(); Stream::new( self.location, HfPlusNode::FilterMap { - f: f.splice_fn1().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -327,12 +331,17 @@ impl<'a, T, L: Location<'a>, B, Order> Stream { ) } - pub fn inspect(self, f: impl IntoQuotedMut<'a, F>) -> Stream { + pub fn inspect( + self, + f: impl IntoQuotedMut<'a, F, L>, + ) -> Stream { + let f = f.splice_fn1_borrow_ctx(&self.location).into(); + if L::is_top_level() { Stream::new( self.location, HfPlusNode::Persist(Box::new(HfPlusNode::Inspect { - f: f.splice_fn1_borrow().into(), + f, input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), })), ) @@ -340,7 +349,7 @@ impl<'a, T, L: Location<'a>, B, Order> Stream { Stream::new( self.location, HfPlusNode::Inspect { - f: f.splice_fn1_borrow().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -358,12 +367,15 @@ where { pub fn fold_commutative A + 'a, F: Fn(&mut A, T)>( self, - init: impl IntoQuotedMut<'a, I>, - comb: impl IntoQuotedMut<'a, F>, + init: impl IntoQuotedMut<'a, I, L>, + comb: impl IntoQuotedMut<'a, F, L>, ) -> Singleton { + let init = init.splice_fn0_ctx(&self.location).into(); + let comb = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + let mut core = HfPlusNode::Fold { - init: init.splice_fn0().into(), - acc: comb.splice_fn2_borrow_mut().into(), + init, + acc: comb, input: Box::new(self.ir_node.into_inner()), }; @@ -379,10 +391,11 @@ where pub fn reduce_commutative( self, - comb: impl IntoQuotedMut<'a, F>, + comb: impl IntoQuotedMut<'a, F, L>, ) -> Optional { + let f = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); let mut core = HfPlusNode::Reduce { - f: comb.splice_fn2_borrow_mut().into(), + f, input: Box::new(self.ir_node.into_inner()), }; @@ -451,12 +464,15 @@ impl<'a, T, L: Location<'a>, B> Stream { pub fn fold A + 'a, F: Fn(&mut A, T)>( self, - init: impl IntoQuotedMut<'a, I>, - comb: impl IntoQuotedMut<'a, F>, + init: impl IntoQuotedMut<'a, I, L>, + comb: impl IntoQuotedMut<'a, F, L>, ) -> Singleton { + let init = init.splice_fn0_ctx(&self.location).into(); + let comb = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + let mut core = HfPlusNode::Fold { - init: init.splice_fn0().into(), - acc: comb.splice_fn2_borrow_mut().into(), + init, + acc: comb, input: Box::new(self.ir_node.into_inner()), }; @@ -472,10 +488,11 @@ impl<'a, T, L: Location<'a>, B> Stream { pub fn reduce( self, - comb: impl IntoQuotedMut<'a, F>, + comb: impl IntoQuotedMut<'a, F, L>, ) -> Optional { + let f = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); let mut core = HfPlusNode::Reduce { - f: comb.splice_fn2_borrow_mut().into(), + f, input: Box::new(self.ir_node.into_inner()), }; @@ -549,14 +566,17 @@ impl<'a, K, V1, L: Location<'a>, B, Order> Stream<(K, V1), L, B, Order> { impl<'a, K: Eq + Hash, V, L: Location<'a>> Stream<(K, V), Tick, Bounded> { pub fn fold_keyed A + 'a, F: Fn(&mut A, V) + 'a>( self, - init: impl IntoQuotedMut<'a, I>, - comb: impl IntoQuotedMut<'a, F>, + init: impl IntoQuotedMut<'a, I, Tick>, + comb: impl IntoQuotedMut<'a, F, Tick>, ) -> Stream<(K, A), Tick, Bounded> { + let init = init.splice_fn0_ctx(&self.location).into(); + let comb = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + Stream::new( self.location, HfPlusNode::FoldKeyed { - init: init.splice_fn0().into(), - acc: comb.splice_fn2_borrow_mut().into(), + init, + acc: comb, input: Box::new(self.ir_node.into_inner()), }, ) @@ -564,12 +584,14 @@ impl<'a, K: Eq + Hash, V, L: Location<'a>> Stream<(K, V), Tick, Bounded> { pub fn reduce_keyed( self, - comb: impl IntoQuotedMut<'a, F>, + comb: impl IntoQuotedMut<'a, F, Tick>, ) -> Stream<(K, V), Tick, Bounded> { + let f = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + Stream::new( self.location, HfPlusNode::ReduceKeyed { - f: comb.splice_fn2_borrow_mut().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -582,14 +604,17 @@ where { pub fn fold_keyed_commutative A + 'a, F: Fn(&mut A, V) + 'a>( self, - init: impl IntoQuotedMut<'a, I>, - comb: impl IntoQuotedMut<'a, F>, + init: impl IntoQuotedMut<'a, I, Tick>, + comb: impl IntoQuotedMut<'a, F, Tick>, ) -> Stream<(K, A), Tick, Bounded, Order> { + let init = init.splice_fn0_ctx(&self.location).into(); + let comb = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + Stream::new( self.location, HfPlusNode::FoldKeyed { - init: init.splice_fn0().into(), - acc: comb.splice_fn2_borrow_mut().into(), + init, + acc: comb, input: Box::new(self.ir_node.into_inner()), }, ) @@ -597,12 +622,14 @@ where pub fn reduce_keyed_commutative( self, - comb: impl IntoQuotedMut<'a, F>, + comb: impl IntoQuotedMut<'a, F, Tick>, ) -> Stream<(K, V), Tick, Bounded, Order> { + let f = comb.splice_fn2_borrow_mut_ctx(&self.location).into(); + Stream::new( self.location, HfPlusNode::ReduceKeyed { - f: comb.splice_fn2_borrow_mut().into(), + f, input: Box::new(self.ir_node.into_inner()), }, ) @@ -626,7 +653,7 @@ impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { pub fn sample_every( self, - interval: impl Quoted<'a, std::time::Duration> + Copy + 'a, + interval: impl QuotedWithContext<'a, std::time::Duration, L> + Copy + 'a, ) -> Stream { let samples = self.location.source_interval(interval); let tick = self.location.tick(); @@ -635,7 +662,8 @@ impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { .all_ticks() } - pub fn for_each(self, f: impl IntoQuotedMut<'a, F>) { + pub fn for_each(self, f: impl IntoQuotedMut<'a, F, L>) { + let f = f.splice_fn1_ctx(&self.location).into(); self.location .flow_state() .borrow_mut() @@ -644,11 +672,14 @@ impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { .expect(FLOW_USED_MESSAGE) .push(HfPlusLeaf::ForEach { input: Box::new(HfPlusNode::Unpersist(Box::new(self.ir_node.into_inner()))), - f: f.splice_fn1().into(), + f, }); } - pub fn dest_sink + 'a>(self, sink: impl Quoted<'a, S>) { + pub fn dest_sink + 'a>( + self, + sink: impl QuotedWithContext<'a, S, L>, + ) { self.location .flow_state() .borrow_mut() @@ -656,7 +687,7 @@ impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { .as_mut() .expect(FLOW_USED_MESSAGE) .push(HfPlusLeaf::DestSink { - sink: sink.splice_typed().into(), + sink: sink.splice_typed_ctx(&self.location).into(), input: Box::new(self.ir_node.into_inner()), }); } @@ -736,6 +767,28 @@ pub(super) fn deserialize_bincode(tagged: Option } } +impl<'a, T, C1, B, Order> Stream, B, Order> { + pub fn decouple_cluster( + self, + other: &Cluster<'a, C2>, + ) -> Stream, Unbounded, Order> + where + Cluster<'a, C1>: Location<'a, Root = Cluster<'a, C1>>, + Cluster<'a, C1>: + CanSend<'a, Cluster<'a, C2>, In = (ClusterId, T), Out = (Tag, T)>, + T: Clone + Serialize + DeserializeOwned, + Order: + MinOrder< as CanSend<'a, Cluster<'a, C2>>>::OutStrongestOrder>, + { + self.map(q!(move |b| ( + ClusterId::from_raw(CLUSTER_SELF_ID.raw_id), + b.clone() + ))) + .send_bincode_interleaved(other) + .assume_ordering() // this is safe because we are mapping clusters 1:1 + } +} + impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { pub fn decouple_process( self, @@ -749,28 +802,6 @@ impl<'a, T, L: Location<'a> + NoTick, B, Order> Stream { self.send_bincode::, T>(other) } - pub fn decouple_cluster( - self, - other: &Cluster<'a, C2>, - ) -> Stream, Unbounded, Order> - where - L: CanSend<'a, Cluster<'a, C2>, In = (ClusterId, T), Out = (Tag, T)>, - T: Clone + Serialize + DeserializeOwned, - Order: MinOrder>, - { - let self_node_id = match self.location_kind() { - LocationId::Cluster(cluster_id) => ClusterSelfId { - id: cluster_id, - _phantom: PhantomData, - }, - _ => panic!("decouple_cluster must be called on a cluster"), - }; - - self.map(q!(move |b| (self_node_id, b.clone()))) - .send_bincode_interleaved(other) - .assume_ordering() // this is safe because we are mapping clusters 1:1 - } - pub fn send_bincode, CoreType>( self, other: &L2, diff --git a/hydroflow_plus_test/src/cluster/paxos.rs b/hydroflow_plus_test/src/cluster/paxos.rs index f575ee1c3f13..060775f8af83 100644 --- a/hydroflow_plus_test/src/cluster/paxos.rs +++ b/hydroflow_plus_test/src/cluster/paxos.rs @@ -197,7 +197,6 @@ fn leader_election<'a, L: Clone + Debug + Serialize + DeserializeOwned>( p_to_proposers_i_am_leader_forward_ref, ); let (p_ballot, p_has_largest_ballot) = p_ballot_calc( - proposers, proposer_tick, p_received_max_ballot.latest_tick(proposer_tick), ); @@ -255,14 +254,12 @@ fn p_max_ballot<'a>( // Proposer logic to calculate the next ballot number. Expects p_received_max_ballot, the largest ballot received so far. Outputs streams: ballot_num, and has_largest_ballot, which only contains a value if we have the largest ballot. #[expect(clippy::type_complexity, reason = "internal paxos code // TODO")] fn p_ballot_calc<'a>( - proposers: &Cluster<'a, Proposer>, proposer_tick: &Tick>, p_received_max_ballot: Singleton>, Bounded>, ) -> ( Singleton>, Bounded>, Optional<(), Tick>, Bounded>, ) { - let p_id = proposers.self_id(); let (p_ballot_num_complete_cycle, p_ballot_num) = proposer_tick.cycle_with_initial(proposer_tick.singleton(q!(0))); @@ -273,7 +270,7 @@ fn p_ballot_calc<'a>( if received_max_ballot > (Ballot { num: ballot_num, - proposer_id: p_id, + proposer_id: CLUSTER_SELF_ID, }) { received_max_ballot.num + 1 @@ -285,7 +282,7 @@ fn p_ballot_calc<'a>( let p_ballot = p_ballot_num.clone().map(q!(move |num| Ballot { num, - proposer_id: p_id + proposer_id: CLUSTER_SELF_ID })); let p_has_largest_ballot = p_received_max_ballot @@ -340,7 +337,6 @@ fn p_leader_heartbeat<'a>( Stream, Unbounded, NoOrder>, Optional, Tick>, Bounded>, ) { - let p_id = proposers.self_id(); let p_to_proposers_i_am_leader = p_is_leader .clone() .then(p_ballot) @@ -360,7 +356,8 @@ fn p_leader_heartbeat<'a>( proposers .source_interval_delayed( q!(Duration::from_secs( - (p_id.raw_id * i_am_leader_check_timeout_delay_multiplier as u32).into() + (CLUSTER_SELF_ID.raw_id * i_am_leader_check_timeout_delay_multiplier as u32) + .into() )), q!(Duration::from_secs(i_am_leader_check_timeout)), ) diff --git a/hydroflow_plus_test/src/cluster/paxos_bench.rs b/hydroflow_plus_test/src/cluster/paxos_bench.rs index 649706f48123..fb763ff60ce3 100644 --- a/hydroflow_plus_test/src/cluster/paxos_bench.rs +++ b/hydroflow_plus_test/src/cluster/paxos_bench.rs @@ -52,7 +52,6 @@ pub fn paxos_bench<'a>( &clients, leader_changed, |c_to_proposers| { - let client_self_id = clients.self_id(); let (new_leader_elected, processed_payloads) = paxos_kv( &proposers, &acceptors, @@ -64,7 +63,7 @@ pub fn paxos_bench<'a>( .map(q!(move |(key, leader_id)| (leader_id, KvPayload { key, // we use our ID as the value and use that so the replica only notifies us - value: client_self_id + value: CLUSTER_SELF_ID }))) .send_bincode_interleaved(&proposers) // clients "own" certain keys, so interleaving elements from clients will not affect diff --git a/hydroflow_plus_test/src/cluster/simple_cluster.rs b/hydroflow_plus_test/src/cluster/simple_cluster.rs index 074230631b69..0a65ae3e81af 100644 --- a/hydroflow_plus_test/src/cluster/simple_cluster.rs +++ b/hydroflow_plus_test/src/cluster/simple_cluster.rs @@ -3,16 +3,14 @@ use hydroflow_plus::*; pub fn decouple_cluster<'a>(flow: &FlowBuilder<'a>) -> (Cluster<'a, ()>, Cluster<'a, ()>) { let cluster1 = flow.cluster(); let cluster2 = flow.cluster(); - let cluster_self_id = cluster2.self_id(); - let cluster1_self_id = cluster1.self_id(); cluster1 - .source_iter(q!(vec!(cluster1_self_id))) + .source_iter(q!(vec!(CLUSTER_SELF_ID))) // .for_each(q!(|message| println!("hey, {}", message))) .inspect(q!(|message| println!("Cluster1 node sending message: {}", message))) .decouple_cluster(&cluster2) .for_each(q!(move |message| println!( "My self id is {}, my message is {}", - cluster_self_id, message + CLUSTER_SELF_ID, message ))); (cluster1, cluster2) } @@ -34,15 +32,13 @@ pub fn simple_cluster<'a>(flow: &FlowBuilder<'a>) -> (Process<'a, ()>, Cluster<' let numbers = process.source_iter(q!(0..5)); let ids = process.source_iter(cluster.members()).map(q!(|&id| id)); - let cluster_self_id = cluster.self_id(); - ids.cross_product(numbers) .map(q!(|(id, n)| (id, (id, n)))) .send_bincode(&cluster) .tick_batch(&cluster.tick()) .inspect(q!(move |n| println!( "cluster received: {:?} (self cluster id: {})", - n, cluster_self_id + n, CLUSTER_SELF_ID ))) .all_ticks() .send_bincode(&process) diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap index a9bac21e29da..751772daad6c 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir.snap @@ -12,7 +12,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (u64 , u64) , (u64 , u64) , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) , (inside_batch , total_batch) | { * inside += inside_batch ; * total += total_batch ; } }), input: Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -53,7 +53,7 @@ expression: built.ir() input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < usize , () > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; | _ | () }), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: ops :: Range < usize > > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; let batch_size = { use crate :: __staged :: cluster :: compute_pi :: * ; let batch_size = 8192usize ; batch_size } ; move | _ | 0 .. batch_size }), + f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: ops :: Range < usize > > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; let batch_size__free = { use crate :: __staged :: cluster :: compute_pi :: * ; let batch_size__free = 8192usize ; batch_size__free } ; move | _ | 0 .. batch_size__free }), input: Source { source: Spin, location_kind: Cluster( @@ -73,7 +73,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: optional :: * ; | _u | () }), input: Source { source: Stream( - { use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }, + { use hydroflow_plus :: __staged :: location :: * ; let interval__free = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval__free)) }, ), location_kind: Process( 1, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_0.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_0.snap index 0df52aa01c95..6e5ae9003103 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_0.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_0.snap @@ -3,13 +3,13 @@ source: hydroflow_plus_test/src/cluster/compute_pi.rs expression: ir.surface_syntax_string() --- 1v1 = spin (); -2v1 = flat_map (stageleft :: runtime_support :: fn1_type_hint :: < () , std :: ops :: Range < usize > > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; let batch_size = { use crate :: __staged :: cluster :: compute_pi :: * ; let batch_size = 8192usize ; batch_size } ; move | _ | 0 .. batch_size })); +2v1 = flat_map (stageleft :: runtime_support :: fn1_type_hint :: < () , std :: ops :: Range < usize > > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; let batch_size__free = { use crate :: __staged :: cluster :: compute_pi :: * ; let batch_size__free = 8192usize ; batch_size__free } ; move | _ | 0 .. batch_size__free })); 3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < usize , () > ({ use hydroflow_plus :: __staged :: location :: tick :: * ; | _ | () })); 4v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < () , (f64 , f64) > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | _ | rand :: random :: < (f64 , f64) > () })); 5v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (f64 , f64) , bool > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (x , y) | x * x + y * y < 1.0 })); 6v1 = fold :: < 'tick > (stageleft :: runtime_support :: fn0_type_hint :: < (u64 , u64) > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | | (0u64 , 0u64) }) , stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (u64 , u64) , bool , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) , sample_inside | { if sample_inside { * inside += 1 ; } * total += 1 ; } })); 7v1 = map (| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (u64 , u64) > (& data) . unwrap () . into () }); -8v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c1_port = "port_0" ; let env = FAKE ; { env . port (c1_port) . connect_local_blocking :: < ConnectedDirect > () . into_sink () } }); +8v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c1_port__free = "port_0" ; let env__free = FAKE ; { env__free . port (c1_port__free) . connect_local_blocking :: < ConnectedDirect > () . into_sink () } }); 1v1 -> 2v1; 2v1 -> 3v1; diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap index debe85fe030f..d884f0ba97ca 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__compute_pi__tests__compute_pi_ir@surface_graph_1.snap @@ -2,11 +2,11 @@ source: hydroflow_plus_test/src/cluster/compute_pi.rs expression: ir.surface_syntax_string() --- -1v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p2_port = "port_0" ; { env . port (p2_port) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); +1v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env__free = FAKE ; let p2_port__free = "port_0" ; { env__free . port (p2_port__free) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); 2v1 = map (| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: compute_pi :: Worker > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (u64 , u64) > (& b) . unwrap ()) }); -3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); +3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: compute_pi :: Worker > , (u64 , u64)) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); 4v1 = reduce :: < 'static > (stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (u64 , u64) , (u64 , u64) , () > ({ use crate :: __staged :: cluster :: compute_pi :: * ; | (inside , total) , (inside_batch , total_batch) | { * inside += inside_batch ; * total += total_batch ; } })); -5v1 = source_stream ({ use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }); +5v1 = source_stream ({ use hydroflow_plus :: __staged :: location :: * ; let interval__free = { use crate :: __staged :: cluster :: compute_pi :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval__free)) }); 6v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: optional :: * ; | _u | () })); 7v1 = cross_singleton (); 8v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < ((u64 , u64) , ()) , (u64 , u64) > ({ use hydroflow_plus :: __staged :: optional :: * ; | (d , _signal) | d })); diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap index e10ab16062d6..6c202ced1d14 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__many_to_many__tests__many_to_many.snap @@ -4,7 +4,7 @@ expression: built.ir() --- [ ForEach { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: many_to_many :: * ; | n | println ! ("cluster received: {:?}" , n) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: many_to_many :: * ; | n | println ! ("cluster received: {:?}" , n) }), input: Network { from_location: Cluster( 0, @@ -36,7 +36,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < () > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < i32 , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Source { source: Iter( { use crate :: __staged :: cluster :: many_to_many :: * ; 0 .. 2 }, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap index 86e08bc03193..2f1d441de9d8 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir.snap @@ -9,7 +9,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < i32 , i32 , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | total , count | * total += count }), input: Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -78,7 +78,7 @@ expression: built.ir() ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ids [i % ids . len ()] , w) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ids__free [i % ids__free . len ()] , w) }), input: Enumerate { is_static: true, input: Map { diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap index 329c9c167fe9..417b0bc0ff76 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_0.snap @@ -5,12 +5,12 @@ expression: ir.surface_syntax_string() 1v1 = source_iter ({ use crate :: __staged :: cluster :: map_reduce :: * ; vec ! ["abc" , "abc" , "xyz" , "abc"] }); 2v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < & str , std :: string :: String > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | s | s . to_string () })); 3v1 = enumerate :: < 'static > (); -4v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ids [i % ids . len ()] , w) })); +4v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (usize , std :: string :: String) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , std :: string :: String) > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > > > (__hydroflow_plus_cluster_ids_1) } ; | (i , w) | (ids__free [i % ids__free . len ()] , w) })); 5v1 = map (| (id , data) : (hydroflow_plus :: ClusterId < _ > , std :: string :: String) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < std :: string :: String > (& data) . unwrap () . into ()) }); -6v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p1_port = "port_0" ; { env . port (p1_port) . connect_local_blocking :: < ConnectedDemux < ConnectedDirect > > () . into_sink () } }); -7v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env = FAKE ; let p2_port = "port_1" ; { env . port (p2_port) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); +6v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env__free = FAKE ; let p1_port__free = "port_0" ; { env__free . port (p1_port__free) . connect_local_blocking :: < ConnectedDemux < ConnectedDirect > > () . into_sink () } }); +7v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let env__free = FAKE ; let p2_port__free = "port_1" ; { env__free . port (p2_port__free) . connect_local_blocking :: < ConnectedTagged < ConnectedDirect > > () . into_source () } }); 8v1 = map (| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: map_reduce :: Worker > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (std :: string :: String , i32) > (& b) . unwrap ()) }); -9v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); +9v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: map_reduce :: Worker > , (std :: string :: String , i32)) , (std :: string :: String , i32) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b })); 10v1 = reduce_keyed :: < 'static > (stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < i32 , i32 , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | total , count | * total += count })); 11v1 = for_each (stageleft :: runtime_support :: fn1_type_hint :: < (std :: string :: String , i32) , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | (string , count) | println ! ("{}: {}" , string , count) })); diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_1.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_1.snap index 2c79806257e9..4024ed117c8d 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_1.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__map_reduce__tests__map_reduce_ir@surface_graph_1.snap @@ -2,13 +2,13 @@ source: hydroflow_plus_test/src/cluster/map_reduce.rs expression: ir.surface_syntax_string() --- -1v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c2_port = "port_0" ; let env = FAKE ; { env . port (c2_port) . connect_local_blocking :: < ConnectedDirect > () . into_source () } }); +1v1 = source_stream ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c2_port__free = "port_0" ; let env__free = FAKE ; { env__free . port (c2_port__free) . connect_local_blocking :: < ConnectedDirect > () . into_source () } }); 2v1 = map (| res | { hydroflow_plus :: runtime_support :: bincode :: deserialize :: < std :: string :: String > (& res . unwrap ()) . unwrap () }); 3v1 = map (stageleft :: runtime_support :: fn1_type_hint :: < std :: string :: String , (std :: string :: String , ()) > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | string | (string , ()) })); 4v1 = fold_keyed :: < 'tick > (stageleft :: runtime_support :: fn0_type_hint :: < i32 > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | | 0 }) , stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < i32 , () , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | count , _ | * count += 1 })); 5v1 = inspect (stageleft :: runtime_support :: fn1_borrow_type_hint :: < (std :: string :: String , i32) , () > ({ use crate :: __staged :: cluster :: map_reduce :: * ; | (string , count) | println ! ("partition count: {} - {}" , string , count) })); 6v1 = map (| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (std :: string :: String , i32) > (& data) . unwrap () . into () }); -7v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c1_port = "port_1" ; let env = FAKE ; { env . port (c1_port) . connect_local_blocking :: < ConnectedDirect > () . into_sink () } }); +7v1 = dest_sink ({ use hydroflow_plus :: __staged :: deploy :: deploy_runtime :: * ; let c1_port__free = "port_1" ; let env__free = FAKE ; { env__free . port (c1_port__free) . connect_local_blocking :: < ConnectedDirect > () . into_sink () } }); 1v1 -> 2v1; 2v1 -> 3v1; diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap index 18a1550ecc6c..23c5ab44165d 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__paxos_bench__tests__paxos_ir.snap @@ -37,7 +37,7 @@ expression: built.ir() ), input: DeferTick( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: Ballot , u32) , u32 > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (received_max_ballot , ballot_num) | { if received_max_ballot > (Ballot { num : ballot_num , proposer_id : p_id , }) { received_max_ballot . num + 1 } else { ballot_num } } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: Ballot , u32) , u32 > ({ use crate :: __staged :: cluster :: paxos :: * ; let CLUSTER_SELF_ID__free = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | (received_max_ballot , ballot_num) | { if received_max_ballot > (Ballot { num : ballot_num , proposer_id : CLUSTER_SELF_ID__free , }) { received_max_ballot . num + 1 } else { ballot_num } } }), input: CrossSingleton( Tee { inner: : Chain( @@ -47,7 +47,7 @@ expression: built.ir() Chain( Chain( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1a | p1a . max_ballot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1a | p1a . max_ballot }), input: CycleSource { ident: Ident { sym: cycle_1, @@ -58,7 +58,7 @@ expression: built.ir() }, }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | p2b . max_ballot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | p2b . max_ballot }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -83,7 +83,7 @@ expression: built.ir() Persist( Source { source: Iter( - { use hydroflow_plus :: __staged :: location :: * ; let e = { use crate :: __staged :: cluster :: paxos :: * ; Ballot { num : 0 , proposer_id : ClusterId :: from_raw (0) } } ; [e] }, + { use hydroflow_plus :: __staged :: location :: * ; let e__free = { use crate :: __staged :: cluster :: paxos :: * ; Ballot { num : 0 , proposer_id : ClusterId :: from_raw (0) } } ; [e__free] }, ), location_kind: Cluster( 0, @@ -108,7 +108,7 @@ expression: built.ir() Persist( Source { source: Iter( - { use hydroflow_plus :: __staged :: location :: * ; let e = { use crate :: __staged :: cluster :: paxos :: * ; 0 } ; [e] }, + { use hydroflow_plus :: __staged :: location :: * ; let e__free = { use crate :: __staged :: cluster :: paxos :: * ; 0 } ; [e__free] }, ), location_kind: Cluster( 0, @@ -130,7 +130,7 @@ expression: built.ir() ), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -162,7 +162,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > > (__hydroflow_plus_cluster_ids_0) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: Ballot , ()) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: optional :: * ; | (d , _signal) | d }), input: CrossSingleton( @@ -171,7 +171,7 @@ expression: built.ir() input: CrossSingleton( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < u32 , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | num | Ballot { num , proposer_id : p_id } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < u32 , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use crate :: __staged :: cluster :: paxos :: * ; let CLUSTER_SELF_ID__free = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; move | num | Ballot { num , proposer_id : CLUSTER_SELF_ID__free } }), input: Tee { inner: , }, @@ -199,7 +199,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: optional :: * ; | _u | () }), input: Source { source: Stream( - { use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_send_timeout = 1u64 ; Duration :: from_secs (i_am_leader_send_timeout) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }, + { use hydroflow_plus :: __staged :: location :: * ; let interval__free = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_send_timeout__free = 1u64 ; Duration :: from_secs (i_am_leader_send_timeout__free) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval__free)) }, ), location_kind: Cluster( 0, @@ -222,7 +222,7 @@ expression: built.ir() ), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -237,7 +237,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -248,18 +248,18 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus_test :: cluster :: paxos :: P1a , hydroflow_plus_test :: cluster :: paxos :: Ballot) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | ((p1a , max_ballot) , log) | (p1a . ballot . proposer_id , P1b { ballot : p1a . ballot , max_ballot , accepted : log }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus_test :: cluster :: paxos :: P1a , hydroflow_plus_test :: cluster :: paxos :: Ballot) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | ((p1a , max_ballot) , log) | (p1a . ballot . proposer_id , P1b { ballot : p1a . ballot , max_ballot , accepted : log }) }), input: CrossSingleton( CrossSingleton( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1a) , hydroflow_plus_test :: cluster :: paxos :: P1a > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P1a) , hydroflow_plus_test :: cluster :: paxos :: P1a > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -291,7 +291,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Inspect { f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1a , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | _ | println ! ("Proposer leader expired, sending P1a") }), input: Map { @@ -308,7 +308,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < tokio :: time :: Instant > , ()) , core :: option :: Option < tokio :: time :: Instant > > ({ use hydroflow_plus :: __staged :: optional :: * ; | (d , _signal) | d }), input: CrossSingleton( Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < core :: option :: Option < tokio :: time :: Instant > , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_check_timeout = 1u64 ; move | latest_received_i_am_leader | { if let Some (latest_received_i_am_leader) = latest_received_i_am_leader { (Instant :: now () . duration_since (* latest_received_i_am_leader)) > Duration :: from_secs (i_am_leader_check_timeout) } else { true } } }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < core :: option :: Option < tokio :: time :: Instant > , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_check_timeout__free = 1u64 ; move | latest_received_i_am_leader | { if let Some (latest_received_i_am_leader) = latest_received_i_am_leader { (Instant :: now () . duration_since (* latest_received_i_am_leader)) > Duration :: from_secs (i_am_leader_check_timeout__free) } else { true } } }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < tokio :: time :: Instant > , ()) , core :: option :: Option < tokio :: time :: Instant > > ({ use hydroflow_plus :: __staged :: singleton :: * ; | (d , _signal) | d }), input: CrossSingleton( @@ -341,7 +341,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < tokio :: time :: Instant , () > ({ use hydroflow_plus :: __staged :: optional :: * ; | _u | () }), input: Source { source: Stream( - { use hydroflow_plus :: __staged :: location :: * ; let delay = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_check_timeout_delay_multiplier = 1usize ; let p_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; Duration :: from_secs ((p_id . raw_id * i_am_leader_check_timeout_delay_multiplier as u32) . into ()) } ; let interval = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_check_timeout = 1u64 ; Duration :: from_secs (i_am_leader_check_timeout) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval_at (tokio :: time :: Instant :: now () + delay , interval)) }, + { use hydroflow_plus :: __staged :: location :: * ; let delay__free = { use crate :: __staged :: cluster :: paxos :: * ; let CLUSTER_SELF_ID__free = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (__hydroflow_plus_cluster_self_id_0) ; let i_am_leader_check_timeout_delay_multiplier__free = 1usize ; Duration :: from_secs ((CLUSTER_SELF_ID__free . raw_id * i_am_leader_check_timeout_delay_multiplier__free as u32) . into ()) } ; let interval__free = { use crate :: __staged :: cluster :: paxos :: * ; let i_am_leader_check_timeout__free = 1u64 ; Duration :: from_secs (i_am_leader_check_timeout__free) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval_at (tokio :: time :: Instant :: now () + delay__free , interval__free)) }, ), location_kind: Cluster( 0, @@ -378,7 +378,7 @@ expression: built.ir() Persist( Source { source: Iter( - { use hydroflow_plus :: __staged :: location :: * ; let e = { use crate :: __staged :: cluster :: paxos :: * ; Ballot { num : 0 , proposer_id : ClusterId :: from_raw (0) } } ; [e] }, + { use hydroflow_plus :: __staged :: location :: * ; let e__free = { use crate :: __staged :: cluster :: paxos :: * ; Ballot { num : 0 , proposer_id : ClusterId :: from_raw (0) } } ; [e__free] }, ), location_kind: Cluster( 1, @@ -389,7 +389,7 @@ expression: built.ir() }, ), Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_ckpnt , log) | log . clone () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_ckpnt , log) | log . clone () }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -423,19 +423,19 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < (bool , ()) , bool > ({ use hydroflow_plus :: __staged :: optional :: * ; | (d , _signal) | d }), input: CrossSingleton( FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | num_received | if num_received > f { Some (true) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f__free = 1usize ; move | num_received | if num_received > f__free { Some (true) } else { None } }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | t | t . 0 }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | t | t . 0 }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p1b , ballot) | p1b . ballot == * ballot }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , bool > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p1b , ballot) | p1b . ballot == * ballot }), input: CrossSingleton( Persist( Inspect { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | println ! ("Proposer received P1b: {:?}" , p1b) }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | println ! ("Proposer received P1b: {:?}" , p1b) }), input: Tee { inner: , }, @@ -498,13 +498,13 @@ expression: built.ir() inner: : Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , usize , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new > * curr { * curr = new ; } } }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), input: Tee { inner: : FoldKeyed { - init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | curr_entry , new_entry | { if let Some (curr_entry_payload) = & mut curr_entry . 1 { let same_values = new_entry . value == curr_entry_payload . value ; let higher_ballot = new_entry . ballot > curr_entry_payload . ballot ; if same_values { curr_entry . 0 += 1 ; } if higher_ballot { curr_entry_payload . ballot = new_entry . ballot ; if ! same_values { curr_entry . 0 = 1 ; curr_entry_payload . value = new_entry . value ; } } } else { * curr_entry = (1 , Some (new_entry)) ; } } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | curr_entry , new_entry | { if let Some (curr_entry_payload) = & mut curr_entry . 1 { let same_values = new_entry . value == curr_entry_payload . value ; let higher_ballot = new_entry . ballot > curr_entry_payload . ballot ; if same_values { curr_entry . 0 += 1 ; } if higher_ballot { curr_entry_payload . ballot = new_entry . ballot ; if ! same_values { curr_entry . 0 = 1 ; curr_entry_payload . value = new_entry . value ; } } } else { * curr_entry = (1 , Some (new_entry)) ; } } }), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , std :: collections :: hash_map :: IntoIter < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | p1b . accepted . into_iter () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P1b < std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > , std :: collections :: hash_map :: IntoIter < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p1b | p1b . accepted . into_iter () }), input: Tee { inner: , }, @@ -518,7 +518,7 @@ expression: built.ir() Persist( Source { source: Iter( - { use hydroflow_plus :: __staged :: location :: * ; let e = { use crate :: __staged :: cluster :: paxos :: * ; 0 } ; [e] }, + { use hydroflow_plus :: __staged :: location :: * ; let e__free = { use crate :: __staged :: cluster :: paxos :: * ; 0 } ; [e__free] }, ), location_kind: Cluster( 0, @@ -557,16 +557,16 @@ expression: built.ir() Tee { inner: : Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (((usize , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , usize) , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (((index , payload) , next_slot) , ballot) | P2a { ballot , slot : next_slot + index , value : Some (payload) } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (((usize , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , usize) , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (((index , payload) , next_slot) , ballot) | P2a { ballot , slot : next_slot + index , value : Some (payload) } }), input: CrossSingleton( CrossSingleton( Enumerate { is_static: false, input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 2, @@ -581,7 +581,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -592,13 +592,13 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer >) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let client_self_id = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; move | (key , leader_id) | (leader_id , KvPayload { key , value : client_self_id }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer >) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let CLUSTER_SELF_ID__free = hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_bench :: Client > :: from_raw (__hydroflow_plus_cluster_self_id_2) ; move | (key , leader_id) | (leader_id , KvPayload { key , value : CLUSTER_SELF_ID__free }) }), input: CrossSingleton( CycleSource { ident: Ident { @@ -610,7 +610,7 @@ expression: built.ir() }, Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | ballot : Ballot | ballot . proposer_id }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | ballot : Ballot | ballot . proposer_id }), input: Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , hydroflow_plus_test :: cluster :: paxos :: Ballot , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new > * curr { * curr = new ; } } }), input: Persist( @@ -675,23 +675,23 @@ expression: built.ir() input: DeferTick( Difference( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _value) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _value) | slot }), input: Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , value)) | if count > f { Some ((slot , value)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f__free = 1usize ; move | ((slot , _ballot) , (count , value)) | if count > f__free { Some ((slot , value)) } else { None } }), input: Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (k , (count , v)) | (k , (count , v . unwrap ())) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (k , (count , v)) | (k , (count , v . unwrap ())) }), input: FoldKeyed { - init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | accum , value | { accum . 0 += 1 ; accum . 1 = Some (value) ; } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (0 , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (usize , core :: option :: Option < core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | accum , value | { accum . 0 += 1 ; accum . 1 = Some (value) ; } }), input: FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , core :: option :: Option < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | if p2b . ballot == p2b . max_ballot { Some (((p2b . slot , p2b . ballot) , p2b . value)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , core :: option :: Option < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | if p2b . ballot == p2b . max_ballot { Some (((p2b . slot , p2b . ballot) , p2b . value)) } else { None } }), input: Tee { inner: : Chain( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 1, @@ -706,7 +706,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -717,17 +717,17 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Acceptor > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | (p2a . ballot . proposer_id , P2b { ballot : p2a . ballot , max_ballot , slot : p2a . slot , value : p2a . value }) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | (p2a . ballot . proposer_id , P2b { ballot : p2a . ballot , max_ballot , slot : p2a . slot , value : p2a . value }) }), input: CrossSingleton( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -742,7 +742,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -753,23 +753,23 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > (& b) . unwrap ()) }", ], }, ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Chain( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , ()) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Chain( FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , (count , entry)) , ballot) | { let entry = entry . unwrap () ; if count <= f { Some (P2a { ballot , slot , value : entry . value , }) } else { None } } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f__free = 1usize ; move | ((slot , (count , entry)) , ballot) | { let entry = entry . unwrap () ; if count <= f__free { Some (P2a { ballot , slot , value : entry . value , }) } else { None } } }), input: CrossSingleton( Tee { inner: , @@ -780,7 +780,7 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , ballot) | P2a { ballot , slot , value : None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , ballot) | P2a { ballot , slot , value : None } }), input: CrossSingleton( Difference( FlatMap { @@ -790,7 +790,7 @@ expression: built.ir() }, }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >)) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (slot , _) | slot }), input: Tee { inner: , }, @@ -878,7 +878,7 @@ expression: built.ir() }, Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | ((slot , _ballot) , (count , _p2b)) | if count == 2 * f + 1 { Some (slot) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((usize , hydroflow_plus_test :: cluster :: paxos :: Ballot) , (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >)) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f__free = 1usize ; move | ((slot , _ballot) , (count , _p2b)) | if count == 2 * f__free + 1 { Some (slot) } else { None } }), input: Tee { inner: , }, @@ -899,10 +899,10 @@ expression: built.ir() ), input: DeferTick( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_slot , p2b) | p2b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_slot , p2b) | p2b }), input: AntiJoin( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | (p2b . slot , p2b) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , (usize , hydroflow_plus_test :: cluster :: paxos :: P2b < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | p2b | (p2b . slot , p2b) }), input: Tee { inner: , }, @@ -925,12 +925,12 @@ expression: built.ir() ), ), input: Fold { - init: stageleft :: runtime_support :: fn0_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (None , HashMap :: new ()) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | (prev_checkpoint , log) , checkpoint_or_p2a | { match checkpoint_or_p2a { CheckpointOrP2a :: Checkpoint (new_checkpoint) => { for slot in (prev_checkpoint . unwrap_or (0)) .. new_checkpoint { log . remove (& slot) ; } * prev_checkpoint = Some (new_checkpoint) ; } CheckpointOrP2a :: P2a (p2a) => { if prev_checkpoint . map (| prev | p2a . slot > prev) . unwrap_or (true) && log . get (& p2a . slot) . map (| prev_p2a : & LogValue < _ > | p2a . ballot > prev_p2a . ballot) . unwrap_or (true) { log . insert (p2a . slot , LogValue { ballot : p2a . ballot , value : p2a . value , } ,) ; } } } } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) > ({ use crate :: __staged :: cluster :: paxos :: * ; | | (None , HashMap :: new ()) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (core :: option :: Option < usize > , std :: collections :: hash_map :: HashMap < usize , hydroflow_plus_test :: cluster :: paxos :: LogValue < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > >) , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , () > ({ use crate :: __staged :: cluster :: paxos :: * ; | (prev_checkpoint , log) , checkpoint_or_p2a | { match checkpoint_or_p2a { CheckpointOrP2a :: Checkpoint (new_checkpoint) => { for slot in (prev_checkpoint . unwrap_or (0)) .. new_checkpoint { log . remove (& slot) ; } * prev_checkpoint = Some (new_checkpoint) ; } CheckpointOrP2a :: P2a (p2a) => { if prev_checkpoint . map (| prev | p2a . slot > prev) . unwrap_or (true) && log . get (& p2a . slot) . map (| prev_p2a : & LogValue < _ > | p2a . ballot > prev_p2a . ballot) . unwrap_or (true) { log . insert (p2a . slot , LogValue { ballot : p2a . ballot , value : p2a . value , } ,) ; } } } } }), input: Persist( Chain( FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | if p2a . ballot >= max_ballot { Some (CheckpointOrP2a :: P2a (p2a)) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: P2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | (p2a , max_ballot) | if p2a . ballot >= max_ballot { Some (CheckpointOrP2a :: P2a (p2a)) } else { None } }), input: CrossSingleton( Tee { inner: , @@ -941,14 +941,14 @@ expression: built.ir() ), }, Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | min_seq | CheckpointOrP2a :: Checkpoint (min_seq) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , hydroflow_plus_test :: cluster :: paxos :: CheckpointOrP2a < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos :: * ; | min_seq | CheckpointOrP2a :: Checkpoint (min_seq) }), input: Delta( Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , usize , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | { if new < * curr { * curr = new ; } } }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_sender , seq) | seq }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , usize > ({ use crate :: __staged :: cluster :: paxos :: * ; | (_sender , seq) | seq }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , ()) , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), + f: stageleft :: runtime_support :: fn1_type_hint :: < ((hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , ()) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) > ({ use hydroflow_plus :: __staged :: stream :: * ; | (d , _signal) | d }), input: CrossSingleton( Tee { inner: : ReduceKeyed { @@ -985,7 +985,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Acceptor > > > (__hydroflow_plus_cluster_ids_1) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: CycleSource { ident: Ident { sym: cycle_0, @@ -1002,10 +1002,10 @@ expression: built.ir() Map { f: stageleft :: runtime_support :: fn1_type_hint :: < bool , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | _u | () }), input: FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f = 1usize ; move | num_received | if num_received == f + 1 { Some (true) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < usize , core :: option :: Option < bool > > ({ use crate :: __staged :: cluster :: paxos :: * ; let f__free = 1usize ; move | num_received | if num_received == f__free + 1 { Some (true) } else { None } }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use hydroflow_plus :: __staged :: stream :: * ; | | 0usize }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , usize) , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | count , _ | * count += 1 }), input: Tee { inner: , }, @@ -1045,15 +1045,15 @@ expression: built.ir() ), input: DeferTick( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq > * highest_seq }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq > * highest_seq }), input: CrossSingleton( Tee { inner: : Sort( Chain( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -1068,7 +1068,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -1079,15 +1079,15 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos :: Proposer > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > > (__hydroflow_plus_cluster_ids_3) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > > > (__hydroflow_plus_cluster_ids_3) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (slot , kv) | SequencedKv { seq : slot , kv } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (usize , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (slot , kv) | SequencedKv { seq : slot , kv } }), input: AntiJoin( Tee { inner: , @@ -1127,7 +1127,7 @@ expression: built.ir() f: stageleft :: runtime_support :: fn1_type_hint :: < core :: option :: Option < usize > , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | v | v }), input: Fold { init: stageleft :: runtime_support :: fn0_type_hint :: < core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | None }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < core :: option :: Option < usize > , (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | filled_slot , (sorted_payload , highest_seq) | { let expected_next_slot = std :: cmp :: max (filled_slot . map (| v | v + 1) . unwrap_or (0) , highest_seq . map (| v | v + 1) . unwrap_or (0) ,) ; if sorted_payload . seq == expected_next_slot { * filled_slot = Some (sorted_payload . seq) ; } } }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < core :: option :: Option < usize > , (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | filled_slot , (sorted_payload , highest_seq) | { let expected_next_slot = std :: cmp :: max (filled_slot . map (| v | v + 1) . unwrap_or (0) , highest_seq . map (| v | v + 1) . unwrap_or (0) ,) ; if sorted_payload . seq == expected_next_slot { * filled_slot = Some (sorted_payload . seq) ; } } }), input: CrossSingleton( Tee { inner: , @@ -1180,16 +1180,16 @@ expression: built.ir() input: DeferTick( Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (_kv_store , highest_seq) | highest_seq }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (_kv_store , highest_seq) | highest_seq }), input: Fold { - init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | (HashMap :: new () , None) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (kv_store , last_seq) , payload | { if let Some (kv) = payload . kv { kv_store . insert (kv . key , kv . value) ; } debug_assert ! (payload . seq == (last_seq . map (| s | s + 1) . unwrap_or (0)) , "Hole in log between seq {:?} and {}" , * last_seq , payload . seq) ; * last_seq = Some (payload . seq) ; } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | | (HashMap :: new () , None) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: collections :: hash_map :: HashMap < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < usize >) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , () > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (kv_store , last_seq) , payload | { if let Some (kv) = payload . kv { kv_store . insert (kv . key , kv . value) ; } debug_assert ! (payload . seq == (last_seq . map (| s | s + 1) . unwrap_or (0)) , "Hole in log between seq {:?} and {}" , * last_seq , payload . seq) ; * last_seq = Some (payload . seq) ; } }), input: Persist( Tee { inner: : Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , _) | { sorted_payload } }), input: Filter { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq <= * highest_seq }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , usize) , bool > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | (sorted_payload , highest_seq) | sorted_payload . seq <= * highest_seq }), input: CrossSingleton( Tee { inner: , @@ -1220,7 +1220,7 @@ expression: built.ir() input: DeferTick( Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , usize) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; let checkpoint_frequency = 1usize ; move | (max_checkpointed_seq , new_highest_seq) | if max_checkpointed_seq . map (| m | new_highest_seq - m >= checkpoint_frequency) . unwrap_or (true) { Some (new_highest_seq) } else { None } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (core :: option :: Option < usize > , usize) , core :: option :: Option < usize > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; let checkpoint_frequency__free = 1usize ; move | (max_checkpointed_seq , new_highest_seq) | if max_checkpointed_seq . map (| m | new_highest_seq - m >= checkpoint_frequency__free) . unwrap_or (true) { Some (new_highest_seq) } else { None } }), input: CrossSingleton( Chain( Map { @@ -1280,7 +1280,7 @@ expression: built.ir() 2, ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , hydroflow_plus_test :: cluster :: paxos :: Ballot) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 0, @@ -1312,7 +1312,7 @@ expression: built.ir() ), ), input: FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (__hydroflow_plus_cluster_ids_2) } ; | b | ids . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos :: Ballot , std :: iter :: Map < std :: slice :: Iter < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , _ > > ({ use hydroflow_plus :: __staged :: stream :: * ; let ids__free = unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (__hydroflow_plus_cluster_ids_2) } ; | b | ids__free . iter () . map (move | id | (:: std :: clone :: Clone :: clone (id) , :: std :: clone :: Clone :: clone (& b))) }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus_test :: cluster :: paxos :: Ballot , ()) , hydroflow_plus_test :: cluster :: paxos :: Ballot > ({ use hydroflow_plus :: __staged :: singleton :: * ; | (d , _signal) | d }), input: CrossSingleton( @@ -1346,9 +1346,9 @@ expression: built.ir() Tee { inner: : Chain( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (u32 , ()) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | replica_payload | (replica_payload . key , ()) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (u32 , ()) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | replica_payload | (replica_payload . key , ()) }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > ({ use hydroflow_plus :: __staged :: stream :: * ; | (_ , b) | b }), input: Network { from_location: Cluster( 3, @@ -1363,7 +1363,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& data) . unwrap () . into ()) }", ], }, ), @@ -1374,15 +1374,15 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < hydroflow_plus_test :: cluster :: paxos_kv :: Replica > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > (& b) . unwrap ()) }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | payload | (payload . value , payload) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > , hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > >) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | payload | (payload . value , payload) }), input: FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | payload | payload . kv }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus_test :: cluster :: paxos_kv :: SequencedKv < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > , core :: option :: Option < hydroflow_plus_test :: cluster :: paxos_kv :: KvPayload < u32 , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos_bench :: Client > > > > ({ use crate :: __staged :: cluster :: paxos_kv :: * ; | payload | payload . kv }), input: Tee { inner: , }, @@ -1406,7 +1406,7 @@ expression: built.ir() }, Tee { inner: : FilterMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , usize) , core :: option :: Option < u32 > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let f = 1usize ; move | (key , count) | { if count == f + 1 { Some (key) } else { None } } }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (u32 , usize) , core :: option :: Option < u32 > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let f__free = 1usize ; move | (key , count) | { if count == f__free + 1 { Some (key) } else { None } } }), input: FoldKeyed { init: stageleft :: runtime_support :: fn0_type_hint :: < usize > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | | 0 }), acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < usize , () , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | curr_count , _sender | { * curr_count += 1 ; } }), @@ -1428,12 +1428,12 @@ expression: built.ir() ), input: Chain( FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let num_clients_per_node = 1usize ; move | _ | (0 .. num_clients_per_node) . map (move | i | i as u32) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let num_clients_per_node__free = 1usize ; move | _ | (0 .. num_clients_per_node__free) . map (move | i | i as u32) }), input: Tee { inner: : Reduce { f: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < () , () , () > ({ use hydroflow_plus :: __staged :: stream :: * ; | curr , new | * curr = new }), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: cluster :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | _ | () }), + f: stageleft :: runtime_support :: fn1_type_hint :: < hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < hydroflow_plus_test :: cluster :: paxos :: Proposer > , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | _ | () }), input: Delta( Tee { inner: , @@ -1479,7 +1479,7 @@ expression: built.ir() }, }, FlatMap { - f: stageleft :: runtime_support :: fn1_type_hint :: < std :: time :: SystemTime , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let num_clients_per_node = 1usize ; move | now | (0 .. num_clients_per_node) . map (move | virtual_id | (virtual_id , now)) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < std :: time :: SystemTime , std :: iter :: Map < std :: ops :: Range < usize > , _ > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let num_clients_per_node__free = 1usize ; move | now | (0 .. num_clients_per_node__free) . map (move | virtual_id | (virtual_id , now)) }), input: Map { f: stageleft :: runtime_support :: fn1_type_hint :: < () , std :: time :: SystemTime > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | _ | SystemTime :: now () }), input: Tee { @@ -1509,8 +1509,8 @@ expression: built.ir() Map { f: stageleft :: runtime_support :: fn1_type_hint :: < (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize) , std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; | (latencies , _) | latencies }), input: Fold { - init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let median_latency_window_size = 1usize ; move | | (Rc :: new (RefCell :: new (Vec :: < u128 > :: with_capacity (median_latency_window_size))) , 0usize ,) }), - acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize) , u128 , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let median_latency_window_size = 1usize ; move | (latencies , write_index) , latency | { let mut latencies_mut = latencies . borrow_mut () ; if * write_index < latencies_mut . len () { latencies_mut [* write_index] = latency ; } else { latencies_mut . push (latency) ; } * write_index = (* write_index + 1) % median_latency_window_size ; } }), + init: stageleft :: runtime_support :: fn0_type_hint :: < (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize) > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let median_latency_window_size__free = 1usize ; move | | (Rc :: new (RefCell :: new (Vec :: < u128 > :: with_capacity (median_latency_window_size__free))) , 0usize ,) }), + acc: stageleft :: runtime_support :: fn2_borrow_mut_type_hint :: < (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize) , u128 , () > ({ use crate :: __staged :: cluster :: paxos_bench :: * ; let median_latency_window_size__free = 1usize ; move | (latencies , write_index) , latency | { let mut latencies_mut = latencies . borrow_mut () ; if * write_index < latencies_mut . len () { latencies_mut [* write_index] = latency ; } else { latencies_mut . push (latency) ; } * write_index = (* write_index + 1) % median_latency_window_size__free ; } }), input: Persist( FlatMap { f: stageleft :: runtime_support :: fn1_type_hint :: < core :: option :: Option < u128 > , core :: option :: Option < u128 > > ({ use hydroflow_plus :: __staged :: stream :: * ; | d | d }), @@ -1532,7 +1532,7 @@ expression: built.ir() input: Tee { inner: : Source { source: Stream( - { use hydroflow_plus :: __staged :: location :: * ; let interval = { use crate :: __staged :: cluster :: paxos_bench :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval)) }, + { use hydroflow_plus :: __staged :: location :: * ; let interval__free = { use crate :: __staged :: cluster :: paxos_bench :: * ; Duration :: from_secs (1) } ; tokio_stream :: wrappers :: IntervalStream :: new (tokio :: time :: interval (interval__free)) }, ), location_kind: Cluster( 2, diff --git a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap index a011fb746712..e7083d8ccf6d 100644 --- a/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap +++ b/hydroflow_plus_test/src/cluster/snapshots/hydroflow_plus_test__cluster__simple_cluster__tests__simple_cluster.snap @@ -4,7 +4,7 @@ expression: built.ir() --- [ ForEach { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , d) | println ! ("node received: ({}, {:?})" , id , d) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32)) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , d) | println ! ("node received: ({}, {:?})" , id , d) }), input: Network { from_location: Cluster( 1, @@ -19,7 +19,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& data) . unwrap () . into () }", + "| data | { hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) > (& data) . unwrap () . into () }", ], }, ), @@ -30,13 +30,13 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < () > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& b) . unwrap ()) }", + "| res | { let (id , b) = res . unwrap () ; (hydroflow_plus :: ClusterId :: < () > :: from_raw (id) , hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) > (& b) . unwrap ()) }", ], }, ), ), input: Inspect { - f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; let cluster_self_id = hydroflow_plus :: ClusterId :: < () > :: from_raw (__hydroflow_plus_cluster_self_id_1) ; move | n | println ! ("cluster received: {:?} (self cluster id: {})" , n , cluster_self_id) }), + f: stageleft :: runtime_support :: fn1_borrow_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) , () > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; let CLUSTER_SELF_ID__free = hydroflow_plus :: ClusterId :: < () > :: from_raw (__hydroflow_plus_cluster_self_id_1) ; move | n | println ! ("cluster received: {:?} (self cluster id: {})" , n , CLUSTER_SELF_ID__free) }), input: Network { from_location: Process( 0, @@ -51,7 +51,7 @@ expression: built.ir() Operator { path: "map", args: [ - "| (id , data) : (hydroflow_plus :: ClusterId < _ > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& data) . unwrap () . into ()) }", + "| (id , data) : (hydroflow_plus :: ClusterId < _ > , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32)) | { (id . raw_id , hydroflow_plus :: runtime_support :: bincode :: serialize :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) > (& data) . unwrap () . into ()) }", ], }, ), @@ -62,18 +62,18 @@ expression: built.ir() Operator { path: "map", args: [ - "| res | { hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) > (& res . unwrap ()) . unwrap () }", + "| res | { hydroflow_plus :: runtime_support :: bincode :: deserialize :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) > (& res . unwrap ()) . unwrap () }", ], }, ), ), input: Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32) , (hydroflow_plus :: location :: cluster :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: ClusterId < () > , i32)) > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , n) | (id , (id , n)) }), + f: stageleft :: runtime_support :: fn1_type_hint :: < (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32) , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , (hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , i32)) > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | (id , n) | (id , (id , n)) }), input: Delta( CrossProduct( Persist( Map { - f: stageleft :: runtime_support :: fn1_type_hint :: < & hydroflow_plus :: location :: cluster :: ClusterId < () > , hydroflow_plus :: location :: cluster :: ClusterId < () > > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | & id | id }), + f: stageleft :: runtime_support :: fn1_type_hint :: < & hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > , hydroflow_plus :: location :: cluster :: cluster_id :: ClusterId < () > > ({ use crate :: __staged :: cluster :: simple_cluster :: * ; | & id | id }), input: Source { source: Iter( unsafe { :: std :: mem :: transmute :: < _ , & :: std :: vec :: Vec < hydroflow_plus :: ClusterId < () > > > (__hydroflow_plus_cluster_ids_1) }, diff --git a/hydroflow_plus_test_local/src/local/count_elems.rs b/hydroflow_plus_test_local/src/local/count_elems.rs index 8e25dedf0db3..ee670a6bfd02 100644 --- a/hydroflow_plus_test_local/src/local/count_elems.rs +++ b/hydroflow_plus_test_local/src/local/count_elems.rs @@ -7,7 +7,7 @@ pub fn count_elems_generic<'a, T: 'a>( flow: FlowBuilder<'a>, input_stream: RuntimeData>, output: RuntimeData<&'a UnboundedSender>, -) -> impl Quoted<'a, Hydroflow<'a>> { +) -> impl QuotedWithContext<'a, Hydroflow<'a>, ()> { let process = flow.process::<()>(); let tick = process.tick(); diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_dot.snap index 357ce04046f0..aa61b78fad2f 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_dot.snap @@ -9,7 +9,7 @@ digraph { n2v1 [label="(n2v1) source_stream(messages)", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l std::string::String,\l std::string::String,\l >({\l use crate::__staged::local::chat_app::*;\l |s| s.to_uppercase()\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) cross_join_multiset::<'static, 'tick>()", shape=invhouse, fillcolor="#88aaff"] - n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, std::string::String),\l (),\l >({\l use crate::__staged::local::chat_app::*;\l let output = output;\l |t| {\l output.send(t).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, std::string::String),\l (),\l >({\l use crate::__staged::local::chat_app::*;\l let output__free = output;\l |t| {\l output__free.send(t).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n2v1 -> n3v1 n1v1 -> n4v1 [label="0"] n3v1 -> n4v1 [label="1"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_mermaid.snap index 1e4f82827685..d7f3ff6decc9 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_no_replay@graphvis_mermaid.snap @@ -12,7 +12,7 @@ linkStyle default stroke:#aaa 2v1[\"(2v1) source_stream(messages)"/]:::pullClass 3v1[\"

(3v1)
map(
stageleft::runtime_support::fn1_type_hint::<
std::string::String,
std::string::String,
>({
use crate::__staged::local::chat_app::*;
|s| s.to_uppercase()
}),
)
"/]:::pullClass 4v1[\"(4v1) cross_join_multiset::<'static, 'tick>()"/]:::pullClass -5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, std::string::String),
(),
>({
use crate::__staged::local::chat_app::*;
let output = output;
|t| {
output.send(t).unwrap();
}
}),
)
"\]:::pushClass +5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, std::string::String),
(),
>({
use crate::__staged::local::chat_app::*;
let output__free = output;
|t| {
output__free.send(t).unwrap();
}
}),
)
"\]:::pushClass 2v1-->3v1 1v1-->|0|4v1 3v1-->|1|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_dot.snap index 4126022abd7e..3fb6e6d48cf8 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_dot.snap @@ -10,7 +10,7 @@ digraph { n3v1 [label="(n3v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l std::string::String,\l std::string::String,\l >({\l use crate::__staged::local::chat_app::*;\l |s| s.to_uppercase()\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) cross_join_multiset::<'static, 'static>()", shape=invhouse, fillcolor="#88aaff"] n5v1 [label="(n5v1) multiset_delta()", shape=invhouse, fillcolor="#88aaff"] - n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, std::string::String),\l (),\l >({\l use crate::__staged::local::chat_app::*;\l let output = output;\l |t| {\l output.send(t).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, std::string::String),\l (),\l >({\l use crate::__staged::local::chat_app::*;\l let output__free = output;\l |t| {\l output__free.send(t).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n2v1 -> n3v1 n1v1 -> n4v1 [label="0"] n3v1 -> n4v1 [label="1"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_mermaid.snap index 893b860d09ba..9c3d82a4e5e8 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__chat_app__tests__chat_app_replay@graphvis_mermaid.snap @@ -13,7 +13,7 @@ linkStyle default stroke:#aaa 3v1[\"
(3v1)
map(
stageleft::runtime_support::fn1_type_hint::<
std::string::String,
std::string::String,
>({
use crate::__staged::local::chat_app::*;
|s| s.to_uppercase()
}),
)
"/]:::pullClass 4v1[\"(4v1) cross_join_multiset::<'static, 'static>()"/]:::pullClass 5v1[\"(5v1) multiset_delta()"/]:::pullClass -6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, std::string::String),
(),
>({
use crate::__staged::local::chat_app::*;
let output = output;
|t| {
output.send(t).unwrap();
}
}),
)
"\]:::pushClass +6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, std::string::String),
(),
>({
use crate::__staged::local::chat_app::*;
let output__free = output;
|t| {
output__free.send(t).unwrap();
}
}),
)
"\]:::pushClass 2v1-->3v1 1v1-->|0|4v1 3v1-->|1|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_dot.snap index 177414b8d207..374f7193775e 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_dot.snap @@ -8,7 +8,7 @@ digraph { n1v1 [label="(n1v1) source_stream(input_stream)", shape=invhouse, fillcolor="#88aaff"] n2v1 [label="(n2v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l usize,\l u32,\l >({\l use crate::__staged::local::count_elems::*;\l |_| 1\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) fold::<\l 'tick,\l>(\l stageleft::runtime_support::fn0_type_hint::<\l u32,\l >({\l use crate::__staged::local::count_elems::*;\l || 0\l }),\l stageleft::runtime_support::fn2_borrow_mut_type_hint::<\l u32,\l u32,\l (),\l >({\l use crate::__staged::local::count_elems::*;\l |a, b| *a += b\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] - n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::count_elems::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::count_elems::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n5v1 [label="(n5v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_mermaid.snap index f0e71c8608e7..47423697fb14 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__count_elems__tests__count@graphvis_mermaid.snap @@ -11,7 +11,7 @@ linkStyle default stroke:#aaa 1v1[\"(1v1) source_stream(input_stream)"/]:::pullClass 2v1[\"
(2v1)
map(
stageleft::runtime_support::fn1_type_hint::<
usize,
u32,
>({
use crate::__staged::local::count_elems::*;
|_| 1
}),
)
"/]:::pullClass 3v1[\"
(3v1)
fold::<
'tick,
>(
stageleft::runtime_support::fn0_type_hint::<
u32,
>({
use crate::__staged::local::count_elems::*;
|| 0
}),
stageleft::runtime_support::fn2_borrow_mut_type_hint::<
u32,
u32,
(),
>({
use crate::__staged::local::count_elems::*;
|a, b| *a += b
}),
)
"/]:::pullClass -4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::count_elems::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::count_elems::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 5v1["(5v1) handoff"]:::otherClass 1v1-->2v1 2v1-->5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_dot.snap index 7e84019f8a9c..a29934f0eb58 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_dot.snap @@ -17,7 +17,7 @@ digraph { n10v1 [label="(n10v1) persist::<'static>()", shape=house, fillcolor="#ffff88"] n11v1 [label="(n11v1) unique::<'tick>()", shape=house, fillcolor="#ffff88"] n12v1 [label="(n12v1) multiset_delta()", shape=house, fillcolor="#ffff88"] - n13v1 [label="(n13v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::graph_reachability::*;\l let reached_out = reached_out;\l |v| {\l reached_out.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n13v1 [label="(n13v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::graph_reachability::*;\l let reached_out__free = reached_out;\l |v| {\l reached_out__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n14v1 [label="(n14v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n15v1 [label="(n15v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n16v1 [label="(n16v1) handoff", shape=parallelogram, fillcolor="#ddddff"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_mermaid.snap index 3ddd47390ae3..bdd9a1910fc6 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__graph_reachability__tests__reachability@graphvis_mermaid.snap @@ -20,7 +20,7 @@ linkStyle default stroke:#aaa 10v1[/"(10v1) persist::<'static>()"\]:::pushClass 11v1[/"(11v1) unique::<'tick>()"\]:::pushClass 12v1[/"(12v1) multiset_delta()"\]:::pushClass -13v1[/"
(13v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::graph_reachability::*;
let reached_out = reached_out;
|v| {
reached_out.send(v).unwrap();
}
}),
)
"\]:::pushClass +13v1[/"
(13v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::graph_reachability::*;
let reached_out__free = reached_out;
|v| {
reached_out__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 14v1["(14v1) handoff"]:::otherClass 15v1["(15v1) handoff"]:::otherClass 16v1["(16v1) handoff"]:::otherClass diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_dot.snap index a42f15c8200d..c1d64fab31b3 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_dot.snap @@ -10,7 +10,7 @@ digraph { n3v1 [label="(n3v1) persist::<'static>()", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n5v1 [label="(n5v1) anti_join_multiset::<'tick, 'static>()", shape=invhouse, fillcolor="#88aaff"] - n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n7v1 [label="(n7v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_mermaid.snap index a551e93b7771..e461c8275ec8 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_static@graphvis_mermaid.snap @@ -13,7 +13,7 @@ linkStyle default stroke:#aaa 3v1[\"(3v1) persist::<'static>()"/]:::pullClass 4v1[\"
(4v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 5v1[\"(5v1) anti_join_multiset::<'tick, 'static>()"/]:::pullClass -6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v.0).unwrap();
}
}),
)
"\]:::pushClass +6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v.0).unwrap();
}
}),
)
"\]:::pushClass 7v1["(7v1) handoff"]:::otherClass 1v1-->2v1 2v1-->3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_dot.snap index 064e8c2ad217..125415caa1f9 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_dot.snap @@ -10,7 +10,7 @@ digraph { n3v1 [label="(n3v1) persist::<'static>()", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n5v1 [label="(n5v1) anti_join_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] - n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n6v1 [label="(n6v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n7v1 [label="(n7v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_mermaid.snap index 72e7e8e12cc0..daa59bcd9c60 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_static_tick@graphvis_mermaid.snap @@ -13,7 +13,7 @@ linkStyle default stroke:#aaa 3v1[\"(3v1) persist::<'static>()"/]:::pullClass 4v1[\"
(4v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 5v1[\"(5v1) anti_join_multiset::<'tick, 'tick>()"/]:::pullClass -6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v.0).unwrap();
}
}),
)
"\]:::pushClass +6v1[/"
(6v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v.0).unwrap();
}
}),
)
"\]:::pushClass 7v1["(7v1) handoff"]:::otherClass 1v1-->2v1 2v1-->3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_dot.snap index e08580edcfca..79936132989d 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_dot.snap @@ -9,7 +9,7 @@ digraph { n2v1 [label="(n2v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (u32, u32),\l >({\l use crate::__staged::local::negation::*;\l |v| (v, v)\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) anti_join_multiset::<'tick, 'static>()", shape=invhouse, fillcolor="#88aaff"] - n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n6v1 [label="(n6v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n4v1 [label="pos"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_mermaid.snap index bd3ed201ed8b..6d60700e2d83 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_static@graphvis_mermaid.snap @@ -12,7 +12,7 @@ linkStyle default stroke:#aaa 2v1[\"
(2v1)
map(
stageleft::runtime_support::fn1_type_hint::<
u32,
(u32, u32),
>({
use crate::__staged::local::negation::*;
|v| (v, v)
}),
)
"/]:::pullClass 3v1[\"
(3v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 4v1[\"(4v1) anti_join_multiset::<'tick, 'static>()"/]:::pullClass -5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v.0).unwrap();
}
}),
)
"\]:::pushClass +5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v.0).unwrap();
}
}),
)
"\]:::pushClass 6v1["(6v1) handoff"]:::otherClass 1v1-->2v1 2v1-->|pos|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_dot.snap index 19c6f15739b8..8a4b988f4ce0 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_dot.snap @@ -9,7 +9,7 @@ digraph { n2v1 [label="(n2v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (u32, u32),\l >({\l use crate::__staged::local::negation::*;\l |v| (v, v)\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) anti_join_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] - n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, u32),\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v.0).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n6v1 [label="(n6v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n4v1 [label="pos"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_mermaid.snap index f43ea369d190..16fd2abddc27 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__anti_join_tick_tick@graphvis_mermaid.snap @@ -12,7 +12,7 @@ linkStyle default stroke:#aaa 2v1[\"
(2v1)
map(
stageleft::runtime_support::fn1_type_hint::<
u32,
(u32, u32),
>({
use crate::__staged::local::negation::*;
|v| (v, v)
}),
)
"/]:::pullClass 3v1[\"
(3v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 4v1[\"(4v1) anti_join_multiset::<'tick, 'tick>()"/]:::pullClass -5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v.0).unwrap();
}
}),
)
"\]:::pushClass +5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
(u32, u32),
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v.0).unwrap();
}
}),
)
"\]:::pushClass 6v1["(6v1) handoff"]:::otherClass 1v1-->2v1 2v1-->|pos|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_dot.snap index 0089af5b6d8f..b9112226c9de 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_dot.snap @@ -9,7 +9,7 @@ digraph { n2v1 [label="(n2v1) persist::<'static>()", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) difference_multiset::<'tick, 'static>()", shape=invhouse, fillcolor="#88aaff"] - n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n6v1 [label="(n6v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n4v1 [label="pos"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_mermaid.snap index 78b507ade59d..c28b6b0d4d5d 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_static@graphvis_mermaid.snap @@ -12,7 +12,7 @@ linkStyle default stroke:#aaa 2v1[\"(2v1) persist::<'static>()"/]:::pullClass 3v1[\"
(3v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 4v1[\"(4v1) difference_multiset::<'tick, 'static>()"/]:::pullClass -5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 6v1["(6v1) handoff"]:::otherClass 1v1-->2v1 2v1-->|pos|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_dot.snap index 319db4ff376f..1e9a8e2cf4e5 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_dot.snap @@ -9,7 +9,7 @@ digraph { n2v1 [label="(n2v1) persist::<'static>()", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n4v1 [label="(n4v1) difference_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] - n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n5v1 [label="(n5v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n6v1 [label="(n6v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n4v1 [label="pos"] diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_mermaid.snap index b2582dbf4bbd..e7d673d11e08 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_static_tick@graphvis_mermaid.snap @@ -12,7 +12,7 @@ linkStyle default stroke:#aaa 2v1[\"(2v1) persist::<'static>()"/]:::pullClass 3v1[\"
(3v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 4v1[\"(4v1) difference_multiset::<'tick, 'tick>()"/]:::pullClass -5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +5v1[/"
(5v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 6v1["(6v1) handoff"]:::otherClass 1v1-->2v1 2v1-->|pos|4v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_dot.snap index 3686d5a6bff6..1eea0f181a5a 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_dot.snap @@ -8,7 +8,7 @@ digraph { n1v1 [label="(n1v1) source_iter({\l use crate::__staged::local::negation::*;\l 0..5\l})\l", shape=invhouse, fillcolor="#88aaff"] n2v1 [label="(n2v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) difference_multiset::<'tick, 'static>()", shape=invhouse, fillcolor="#88aaff"] - n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n5v1 [label="(n5v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n3v1 [label="pos"] n2v1 -> n5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_mermaid.snap index 4de7f82c02b4..ad3cf51c3a1c 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_static@graphvis_mermaid.snap @@ -11,7 +11,7 @@ linkStyle default stroke:#aaa 1v1[\"
(1v1)
source_iter({
use crate::__staged::local::negation::*;
0..5
})
"/]:::pullClass 2v1[\"
(2v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 3v1[\"(3v1) difference_multiset::<'tick, 'static>()"/]:::pullClass -4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 5v1["(5v1) handoff"]:::otherClass 1v1-->|pos|3v1 2v1-->5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_dot.snap index 2ef95dfc528c..67dc43c1e7fe 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_dot.snap @@ -8,7 +8,7 @@ digraph { n1v1 [label="(n1v1) source_iter({\l use crate::__staged::local::negation::*;\l 0..5\l})\l", shape=invhouse, fillcolor="#88aaff"] n2v1 [label="(n2v1) source_iter({\l use crate::__staged::local::negation::*;\l 3..6\l})\l", shape=invhouse, fillcolor="#88aaff"] n3v1 [label="(n3v1) difference_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] - n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n4v1 [label="(n4v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::negation::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n5v1 [label="(n5v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n3v1 [label="pos"] n2v1 -> n5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_mermaid.snap index 7b67d52f7b82..af952d07e1d6 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__negation__tests__difference_tick_tick@graphvis_mermaid.snap @@ -11,7 +11,7 @@ linkStyle default stroke:#aaa 1v1[\"
(1v1)
source_iter({
use crate::__staged::local::negation::*;
0..5
})
"/]:::pullClass 2v1[\"
(2v1)
source_iter({
use crate::__staged::local::negation::*;
3..6
})
"/]:::pullClass 3v1[\"(3v1) difference_multiset::<'tick, 'tick>()"/]:::pullClass -4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +4v1[/"
(4v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::negation::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 5v1["(5v1) handoff"]:::otherClass 1v1-->|pos|3v1 2v1-->5v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_dot.snap index 600618e9b6b1..ac9a190ad283 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_dot.snap @@ -12,7 +12,7 @@ digraph { n5v1 [label="(n5v1) join_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] n6v1 [label="(n6v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, ((), ())),\l u32,\l >({\l use crate::__staged::local::teed_join::*;\l |t| t.0\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n7v3 [label="(n7v3) handoff", shape=parallelogram, fillcolor="#ddddff"] - n8v1 [label="(n8v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n8v1 [label="(n8v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n9v1 [label="(n9v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 n2v1 -> n3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_mermaid.snap index 78c612ffe837..4da0aa56994c 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join@graphvis_mermaid.snap @@ -15,7 +15,7 @@ linkStyle default stroke:#aaa 5v1[\"(5v1) join_multiset::<'tick, 'tick>()"/]:::pullClass 6v1[\"
(6v1)
map(
stageleft::runtime_support::fn1_type_hint::<
(u32, ((), ())),
u32,
>({
use crate::__staged::local::teed_join::*;
|t| t.0
}),
)
"/]:::pullClass 7v3["(7v3) handoff"]:::otherClass -8v1[/"
(8v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +8v1[/"
(8v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 9v1["(9v1) handoff"]:::otherClass 1v1-->2v1 2v1-->3v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_dot.snap index 82416ab8855c..c557ed3d7ad5 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_dot.snap @@ -6,7 +6,7 @@ digraph { node [fontname="Monaco,Menlo,Consolas,"Droid Sans Mono",Inconsolata,"Courier New",monospace", style=filled]; edge [fontname="Monaco,Menlo,Consolas,"Droid Sans Mono",Inconsolata,"Courier New",monospace"]; n1v1 [label="(n1v1) source_iter({\l use crate::__staged::local::teed_join::*;\l 0..5\l})\l", shape=invhouse, fillcolor="#88aaff"] - n2v1 [label="(n2v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n2v1 [label="(n2v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n1v1 -> n2v1 subgraph "cluster n1v1" { fillcolor="#dddddd" diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_mermaid.snap index 9cbaddadeb1a..72cdbf388e0e 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_multi_node@graphvis_mermaid.snap @@ -9,7 +9,7 @@ classDef pushClass fill:#ff8,stroke:#000,text-align:left,white-space:pre classDef otherClass fill:#fdc,stroke:#000,text-align:left,white-space:pre linkStyle default stroke:#aaa 1v1[\"
(1v1)
source_iter({
use crate::__staged::local::teed_join::*;
0..5
})
"/]:::pullClass -2v1[/"
(2v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +2v1[/"
(2v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 1v1-->2v1 subgraph sg_1v1 ["sg_1v1 stratum 0"] 1v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_dot.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_dot.snap index 267d3d849447..d35e86f614ec 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_dot.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_dot.snap @@ -12,8 +12,8 @@ digraph { n5v1 [label="(n5v1) join_multiset::<'tick, 'tick>()", shape=invhouse, fillcolor="#88aaff"] n6v1 [label="(n6v1) map(\l stageleft::runtime_support::fn1_type_hint::<\l (u32, ((), ())),\l u32,\l >({\l use crate::__staged::local::teed_join::*;\l |t| t.0\l }),\l)\l", shape=invhouse, fillcolor="#88aaff"] n7v1 [label="(n7v1) tee()", shape=house, fillcolor="#ffff88"] - n8v1 [label="(n8v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] - n9v1 [label="(n9v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output = output;\l |v| {\l output.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n8v1 [label="(n8v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] + n9v1 [label="(n9v1) for_each(\l stageleft::runtime_support::fn1_type_hint::<\l u32,\l (),\l >({\l use crate::__staged::local::teed_join::*;\l let output__free = output;\l |v| {\l output__free.send(v).unwrap();\l }\l }),\l)\l", shape=house, fillcolor="#ffff88"] n10v1 [label="(n10v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n11v1 [label="(n11v1) handoff", shape=parallelogram, fillcolor="#ddddff"] n1v1 -> n2v1 diff --git a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_mermaid.snap b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_mermaid.snap index e8ddfbbd0b98..5efe825e367d 100644 --- a/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_mermaid.snap +++ b/hydroflow_plus_test_local/src/local/snapshots/hydroflow_plus_test_local__local__teed_join__tests__teed_join_twice@graphvis_mermaid.snap @@ -15,8 +15,8 @@ linkStyle default stroke:#aaa 5v1[\"(5v1) join_multiset::<'tick, 'tick>()"/]:::pullClass 6v1[\"
(6v1)
map(
stageleft::runtime_support::fn1_type_hint::<
(u32, ((), ())),
u32,
>({
use crate::__staged::local::teed_join::*;
|t| t.0
}),
)
"/]:::pullClass 7v1[/"(7v1) tee()"\]:::pushClass -8v1[/"
(8v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass -9v1[/"
(9v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output = output;
|v| {
output.send(v).unwrap();
}
}),
)
"\]:::pushClass +8v1[/"
(8v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass +9v1[/"
(9v1)
for_each(
stageleft::runtime_support::fn1_type_hint::<
u32,
(),
>({
use crate::__staged::local::teed_join::*;
let output__free = output;
|v| {
output__free.send(v).unwrap();
}
}),
)
"\]:::pushClass 10v1["(10v1) handoff"]:::otherClass 11v1["(11v1) handoff"]:::otherClass 1v1-->2v1 diff --git a/stageleft/src/lib.rs b/stageleft/src/lib.rs index 6113fd5979d6..d38026335275 100644 --- a/stageleft/src/lib.rs +++ b/stageleft/src/lib.rs @@ -17,7 +17,7 @@ pub mod internal { pub use stageleft_macro::{entry, q, quse_fn, runtime, top_level_mod}; pub mod runtime_support; -use runtime_support::FreeVariable; +use runtime_support::FreeVariableWithContext; use crate::runtime_support::get_final_crate_name; @@ -110,12 +110,12 @@ impl QuotedContext for BorrowBounds<'_> { } } -pub trait Quoted<'a, T>: FreeVariable { - fn splice_untyped(self) -> syn::Expr +pub trait QuotedWithContext<'a, T, Ctx>: FreeVariableWithContext { + fn splice_untyped_ctx(self, ctx: &Ctx) -> syn::Expr where Self: Sized, { - let (prelude, value) = self.to_tokens(); + let (prelude, value) = self.to_tokens(ctx); if prelude.is_some() { panic!("Quoted value should not have prelude"); } @@ -123,9 +123,96 @@ pub trait Quoted<'a, T>: FreeVariable { syn::parse2(value.unwrap()).unwrap() } + fn splice_typed_ctx(self, ctx: &Ctx) -> syn::Expr + where + Self: Sized, + { + let inner_expr = self.splice_untyped_ctx(ctx); + let stageleft_root = stageleft_root(); + + let out_type = quote_type::(); + + syn::parse_quote! { + #stageleft_root::runtime_support::type_hint::<#out_type>(#inner_expr) + } + } + + fn splice_fn0_ctx(self, ctx: &Ctx) -> syn::Expr + where + Self: Sized, + T: Fn() -> O, + { + let inner_expr = self.splice_untyped_ctx(ctx); + let stageleft_root = stageleft_root(); + + let out_type = quote_type::(); + + syn::parse_quote! { + #stageleft_root::runtime_support::fn0_type_hint::<#out_type>(#inner_expr) + } + } + + fn splice_fn1_ctx(self, ctx: &Ctx) -> syn::Expr + where + Self: Sized, + T: Fn(I) -> O, + { + let inner_expr = self.splice_untyped_ctx(ctx); + let stageleft_root = stageleft_root(); + + let in_type = quote_type::(); + let out_type = quote_type::(); + + syn::parse_quote! { + #stageleft_root::runtime_support::fn1_type_hint::<#in_type, #out_type>(#inner_expr) + } + } + + fn splice_fn1_borrow_ctx(self, ctx: &Ctx) -> syn::Expr + where + Self: Sized, + T: Fn(&I) -> O, + { + let inner_expr = self.splice_untyped_ctx(ctx); + let stageleft_root = stageleft_root(); + + let in_type = quote_type::(); + let out_type = quote_type::(); + + syn::parse_quote! { + #stageleft_root::runtime_support::fn1_borrow_type_hint::<#in_type, #out_type>(#inner_expr) + } + } + + fn splice_fn2_borrow_mut_ctx(self, ctx: &Ctx) -> syn::Expr + where + Self: Sized, + T: Fn(&mut I1, I2) -> O, + { + let inner_expr = self.splice_untyped_ctx(ctx); + let stageleft_root = stageleft_root(); + + let in1_type = quote_type::(); + let in2_type = quote_type::(); + let out_type = quote_type::(); + + syn::parse_quote! { + #stageleft_root::runtime_support::fn2_borrow_mut_type_hint::<#in1_type, #in2_type, #out_type>(#inner_expr) + } + } + + fn splice_untyped(self) -> syn::Expr + where + Self: Sized, + Ctx: Default, + { + self.splice_untyped_ctx(&Default::default()) + } + fn splice_typed(self) -> syn::Expr where Self: Sized, + Ctx: Default, { let inner_expr = self.splice_untyped(); let stageleft_root = stageleft_root(); @@ -140,6 +227,7 @@ pub trait Quoted<'a, T>: FreeVariable { fn splice_fn0(self) -> syn::Expr where Self: Sized, + Ctx: Default, T: Fn() -> O, { let inner_expr = self.splice_untyped(); @@ -155,6 +243,7 @@ pub trait Quoted<'a, T>: FreeVariable { fn splice_fn1(self) -> syn::Expr where Self: Sized, + Ctx: Default, T: Fn(I) -> O, { let inner_expr = self.splice_untyped(); @@ -171,6 +260,7 @@ pub trait Quoted<'a, T>: FreeVariable { fn splice_fn1_borrow(self) -> syn::Expr where Self: Sized, + Ctx: Default, T: Fn(&I) -> O, { let inner_expr = self.splice_untyped(); @@ -187,6 +277,7 @@ pub trait Quoted<'a, T>: FreeVariable { fn splice_fn2_borrow_mut(self) -> syn::Expr where Self: Sized, + Ctx: Default, T: Fn(&mut I1, I2) -> O, { let inner_expr = self.splice_untyped(); @@ -202,6 +293,9 @@ pub trait Quoted<'a, T>: FreeVariable { } } +pub trait Quoted<'a, T>: QuotedWithContext<'a, T, ()> {} +impl<'a, T, F: QuotedWithContext<'a, T, ()>> Quoted<'a, T> for F {} + fn stageleft_root() -> syn::Ident { let stageleft_crate = proc_macro_crate::crate_name("stageleft") .unwrap_or_else(|_| panic!("stageleft should be present in `Cargo.toml`")); @@ -212,12 +306,19 @@ fn stageleft_root() -> syn::Ident { } } -pub trait IntoQuotedOnce<'a, T>: - FnOnce(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T +pub trait IntoQuotedOnce<'a, T, Ctx>: + for<'b> FnOnce( + &'b Ctx, + &mut String, + &mut &'static str, + &mut TokenStream, + &mut CaptureVec, + bool, + ) -> T + 'a - + Quoted<'a, T> + + QuotedWithContext<'a, T, Ctx> { - fn boxed(self) -> Box> + fn boxed(self) -> Box> where Self: Sized, { @@ -228,31 +329,60 @@ pub trait IntoQuotedOnce<'a, T>: impl< 'a, T, - F: FnOnce(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T + 'a, - > Quoted<'a, T> for F + Ctx, + F: for<'b> FnOnce( + &'b Ctx, + &mut String, + &mut &'static str, + &mut TokenStream, + &mut CaptureVec, + bool, + ) -> T + + 'a, + > QuotedWithContext<'a, T, Ctx> for F { } impl< 'a, T, - F: FnOnce(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T + 'a, - > IntoQuotedOnce<'a, T> for F + Ctx, + F: for<'b> FnOnce( + &'b Ctx, + &mut String, + &mut &'static str, + &mut TokenStream, + &mut CaptureVec, + bool, + ) -> T + + 'a, + > IntoQuotedOnce<'a, T, Ctx> for F { } impl< T, - F: FnOnce(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T, - > FreeVariable for F + Ctx, + F: for<'b> FnOnce( + &'b Ctx, + &mut String, + &mut &'static str, + &mut TokenStream, + &mut CaptureVec, + bool, + ) -> T, + > FreeVariableWithContext for F { - fn to_tokens(self) -> (Option, Option) { + type O = T; + + fn to_tokens(self, ctx: &Ctx) -> (Option, Option) { let mut module_path = String::new(); let mut crate_name = ""; let mut expr_tokens = TokenStream::new(); let mut free_variables = Vec::new(); // this is an uninit value so we can't drop it std::mem::forget(self( + ctx, &mut module_path, &mut crate_name, &mut expr_tokens, @@ -307,16 +437,25 @@ impl< } } -pub trait IntoQuotedMut<'a, T>: - FnMut(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T + 'a +pub trait IntoQuotedMut<'a, T, Ctx>: + FnMut(&Ctx, &mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T + 'a { } impl< 'a, T, - F: FnMut(&mut String, &mut &'static str, &mut TokenStream, &mut CaptureVec, bool) -> T + 'a, - > IntoQuotedMut<'a, T> for F + Ctx, + F: FnMut( + &Ctx, + &mut String, + &mut &'static str, + &mut TokenStream, + &mut CaptureVec, + bool, + ) -> T + + 'a, + > IntoQuotedMut<'a, T, Ctx> for F { } @@ -326,7 +465,7 @@ pub struct RuntimeData { _phantom: PhantomData, } -impl<'a, T: 'a> Quoted<'a, T> for RuntimeData {} +impl<'a, T: 'a, Ctx> QuotedWithContext<'a, T, Ctx> for RuntimeData {} impl Copy for RuntimeData {} @@ -346,8 +485,10 @@ impl RuntimeData { } } -impl FreeVariable for RuntimeData { - fn to_tokens(self) -> (Option, Option) { +impl FreeVariableWithContext for RuntimeData { + type O = T; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { let ident = syn::Ident::new(self.ident, Span::call_site()); (None, Some(quote!(#ident))) } diff --git a/stageleft/src/runtime_support.rs b/stageleft/src/runtime_support.rs index cdca23ec078e..2f825152b74d 100644 --- a/stageleft/src/runtime_support.rs +++ b/stageleft/src/runtime_support.rs @@ -5,7 +5,7 @@ use std::mem::MaybeUninit; use proc_macro2::{Span, TokenStream}; use quote::quote; -use crate::Quoted; +use crate::QuotedWithContext; pub fn get_final_crate_name(crate_name: &str) -> TokenStream { let final_crate = proc_macro_crate::crate_name(crate_name) @@ -75,11 +75,29 @@ impl ParseFromLiteral for bool { impl_parse_from_literal_numeric!(i8, i16, i32, i64, i128, isize); impl_parse_from_literal_numeric!(u8, u16, u32, u64, u128, usize); -pub trait FreeVariable { - fn to_tokens(self) -> (Option, Option) +pub trait FreeVariableWithContext { + type O; + + fn to_tokens(self, ctx: &Ctx) -> (Option, Option) where Self: Sized; + fn uninitialized(&self, _ctx: &Ctx) -> Self::O { + #[expect(clippy::uninit_assumed_init, reason = "this code should never run")] + unsafe { + MaybeUninit::uninit().assume_init() + } + } +} + +pub trait FreeVariable: FreeVariableWithContext<(), O = O> { + fn to_tokens(self) -> (Option, Option) + where + Self: Sized, + { + FreeVariableWithContext::to_tokens(self, &()) + } + fn uninitialized(&self) -> O { #[expect(clippy::uninit_assumed_init, reason = "this code should never run")] unsafe { @@ -88,16 +106,20 @@ pub trait FreeVariable { } } +impl> FreeVariable for T {} + macro_rules! impl_free_variable_from_literal_numeric { ($($ty:ty),*) => { $( - impl FreeVariable<$ty> for $ty { - fn to_tokens(self) -> (Option, Option) { + impl FreeVariableWithContext for $ty { + type O = $ty; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { (None, Some(quote!(#self))) } } - impl<'a> Quoted<'a, $ty> for $ty {} + impl<'a, Ctx> QuotedWithContext<'a, $ty, Ctx> for $ty {} )* }; } @@ -105,8 +127,10 @@ macro_rules! impl_free_variable_from_literal_numeric { impl_free_variable_from_literal_numeric!(i8, i16, i32, i64, i128, isize); impl_free_variable_from_literal_numeric!(u8, u16, u32, u64, u128, usize); -impl FreeVariable<&str> for &str { - fn to_tokens(self) -> (Option, Option) { +impl FreeVariableWithContext for &str { + type O = &'static str; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { (None, Some(quote!(#self))) } } @@ -142,8 +166,10 @@ pub fn create_import( } } -impl FreeVariable for Import { - fn to_tokens(self) -> (Option, Option) { +impl FreeVariableWithContext for Import { + type O = T; + + fn to_tokens(self, _ctx: &Ctx) -> (Option, Option) { let final_crate_root = get_final_crate_name(self.crate_name); let module_path = syn::parse_str::(self.module_path).unwrap(); diff --git a/stageleft_macro/src/lib.rs b/stageleft_macro/src/lib.rs index c6972c694c23..279a53a88c71 100644 --- a/stageleft_macro/src/lib.rs +++ b/stageleft_macro/src/lib.rs @@ -370,7 +370,7 @@ pub fn entry( #root::runtime_support::set_macro_to_crate(macro_crate_name, final_crate_name); let output_core = { - #root::Quoted::splice_untyped(#input_name #passed_generics(#root::QuotedContext::create(), #(#params_to_pass),*)) + #root::QuotedWithContext::splice_untyped_ctx(#input_name #passed_generics(#root::QuotedContext::create(), #(#params_to_pass),*), &()) }; let final_crate_root = #root::runtime_support::get_final_crate_name(final_crate_name); diff --git a/stageleft_macro/src/quote_impl/free_variable/mod.rs b/stageleft_macro/src/quote_impl/free_variable/mod.rs index d323b26ea141..23c6ba85f19c 100644 --- a/stageleft_macro/src/quote_impl/free_variable/mod.rs +++ b/stageleft_macro/src/quote_impl/free_variable/mod.rs @@ -2,6 +2,7 @@ use std::collections::{BTreeSet, HashSet}; mod prelude; use prelude::is_prelude; +use quote::ToTokens; #[derive(Debug)] pub struct ScopeStack { @@ -64,25 +65,25 @@ pub struct FreeVariableVisitor { pub current_scope: ScopeStack, } -impl<'ast> syn::visit::Visit<'ast> for FreeVariableVisitor { - fn visit_expr_closure(&mut self, i: &'ast syn::ExprClosure) { +impl syn::visit_mut::VisitMut for FreeVariableVisitor { + fn visit_expr_closure_mut(&mut self, i: &mut syn::ExprClosure) { self.current_scope.push(); - i.inputs.iter().for_each(|input| { - self.visit_pat(input); + i.inputs.iter_mut().for_each(|input| { + self.visit_pat_mut(input); }); - syn::visit::visit_expr_closure(self, i); + syn::visit_mut::visit_expr_closure_mut(self, i); self.current_scope.pop(); } - fn visit_item_fn(&mut self, i: &'ast syn::ItemFn) { + fn visit_item_fn_mut(&mut self, i: &mut syn::ItemFn) { self.current_scope.push(); - syn::visit::visit_item_fn(self, i); + syn::visit_mut::visit_item_fn_mut(self, i); self.current_scope.pop(); } - fn visit_generic_param(&mut self, i: &'ast syn::GenericParam) { + fn visit_generic_param_mut(&mut self, i: &mut syn::GenericParam) { match i { syn::GenericParam::Type(type_param) => { self.current_scope.insert_type(type_param.ident.clone()); @@ -97,140 +98,157 @@ impl<'ast> syn::visit::Visit<'ast> for FreeVariableVisitor { } } - fn visit_block(&mut self, i: &'ast syn::Block) { + fn visit_block_mut(&mut self, i: &mut syn::Block) { self.current_scope.push(); - syn::visit::visit_block(self, i); + syn::visit_mut::visit_block_mut(self, i); self.current_scope.pop(); } - fn visit_local(&mut self, i: &'ast syn::Local) { - i.init.iter().for_each(|init| { - syn::visit::visit_local_init(self, init); + fn visit_local_mut(&mut self, i: &mut syn::Local) { + i.init.iter_mut().for_each(|init| { + syn::visit_mut::visit_local_init_mut(self, init); }); - match &i.pat { + match &mut i.pat { syn::Pat::Ident(pat_ident) => { self.current_scope.insert_term(pat_ident.ident.clone()); } syn::Pat::Type(pat_type) => { - self.visit_pat(&pat_type.pat); + self.visit_pat_mut(&mut pat_type.pat); } syn::Pat::Wild(_) => { // Do nothing } syn::Pat::Tuple(pat_tuple) => { - for el in &pat_tuple.elems { - self.visit_pat(el); + for el in &mut pat_tuple.elems { + self.visit_pat_mut(el); } } _ => panic!("Local variables must be identifiers, got {:?}", i.pat), } } - fn visit_ident(&mut self, i: &'ast proc_macro2::Ident) { + fn visit_ident_mut(&mut self, i: &mut proc_macro2::Ident) { if !self.current_scope.contains_term(i) { self.free_variables.insert(i.clone()); + *i = syn::Ident::new(&format!("{}__free", i), i.span()); } } - fn visit_lifetime(&mut self, i: &'ast syn::Lifetime) { + fn visit_lifetime_mut(&mut self, i: &mut syn::Lifetime) { if !self.current_scope.contains_type(&i.ident) { self.free_variables.insert(i.ident.clone()); + i.ident = syn::Ident::new(&format!("{}__free", i.ident), i.ident.span()); } } - fn visit_path(&mut self, i: &'ast syn::Path) { + fn visit_path_mut(&mut self, i: &mut syn::Path) { if i.leading_colon.is_none() && !is_prelude(&i.segments.first().unwrap().ident) { - let node = i.segments.first().unwrap(); - if i.segments.len() == 1 && !self.current_scope.contains_term(&node.ident) { + let one_segment = i.segments.len() == 1; + let node = i.segments.first_mut().unwrap(); + if one_segment && !self.current_scope.contains_term(&node.ident) { self.free_variables.insert(node.ident.clone()); + node.ident = syn::Ident::new(&format!("{}__free", node.ident), node.ident.span()); } } - for node in i.segments.iter() { - self.visit_path_arguments(&node.arguments); + for node in i.segments.iter_mut() { + self.visit_path_arguments_mut(&mut node.arguments); } } - fn visit_arm(&mut self, i: &'ast syn::Arm) { + fn visit_arm_mut(&mut self, i: &mut syn::Arm) { self.current_scope.push(); - syn::visit::visit_arm(self, i); + syn::visit_mut::visit_arm_mut(self, i); self.current_scope.pop(); } - fn visit_field_pat(&mut self, i: &'ast syn::FieldPat) { - for it in &i.attrs { - self.visit_attribute(it); + fn visit_field_pat_mut(&mut self, i: &mut syn::FieldPat) { + for it in &mut i.attrs { + self.visit_attribute_mut(it); } - self.visit_pat(&i.pat); + self.visit_pat_mut(&mut i.pat); } - fn visit_pat_ident(&mut self, i: &'ast syn::PatIdent) { + fn visit_pat_ident_mut(&mut self, i: &mut syn::PatIdent) { self.current_scope.insert_term(i.ident.clone()); } - fn visit_expr_method_call(&mut self, i: &'ast syn::ExprMethodCall) { - syn::visit::visit_expr(self, &i.receiver); - for arg in &i.args { - self.visit_expr(arg); + fn visit_expr_method_call_mut(&mut self, i: &mut syn::ExprMethodCall) { + syn::visit_mut::visit_expr_mut(self, &mut i.receiver); + for arg in &mut i.args { + self.visit_expr_mut(arg); } } - fn visit_type(&mut self, _: &'ast syn::Type) {} + fn visit_type_mut(&mut self, _: &mut syn::Type) {} - fn visit_expr_struct(&mut self, node: &'ast syn::ExprStruct) { - for it in &node.attrs { - self.visit_attribute(it); + fn visit_expr_struct_mut(&mut self, node: &mut syn::ExprStruct) { + for it in &mut node.attrs { + self.visit_attribute_mut(it); } - if let Some(it) = &node.qself { - self.visit_qself(it); + if let Some(it) = &mut node.qself { + self.visit_qself_mut(it); } // No need to capture the struct path // self.visit_path(&node.path); - for el in syn::punctuated::Punctuated::pairs(&node.fields) { - let it = el.value(); - self.visit_expr(&it.expr); + for el in syn::punctuated::Punctuated::pairs_mut(&mut node.fields) { + let it = el.into_value(); + self.visit_expr_mut(&mut it.expr); } - if let Some(it) = &node.rest { - self.visit_expr(it); + if let Some(it) = &mut node.rest { + self.visit_expr_mut(it); } } - fn visit_expr_field(&mut self, i: &'ast syn::ExprField) { - self.visit_expr(&i.base); + fn visit_expr_field_mut(&mut self, i: &mut syn::ExprField) { + self.visit_expr_mut(&mut i.base); } - fn visit_macro(&mut self, i: &'ast syn::Macro) { + fn visit_macro_mut(&mut self, i: &mut syn::Macro) { // TODO(shadaj): emit a warning if our guess at parsing fails match i.delimiter { - syn::MacroDelimiter::Paren(_binding_0) => i - .parse_body_with( - syn::punctuated::Punctuated::::parse_terminated, - ) - .ok() - .iter() - .flatten() - .for_each(|expr| { - self.visit_expr(expr); - }), - syn::MacroDelimiter::Brace(_binding_0) => i - .parse_body_with(syn::Block::parse_within) - .ok() - .iter() - .flatten() - .for_each(|stmt| { - self.visit_stmt(stmt); - }), - syn::MacroDelimiter::Bracket(_binding_0) => i - .parse_body_with( - syn::punctuated::Punctuated::::parse_terminated, - ) - .ok() - .iter() - .flatten() - .for_each(|expr| { - self.visit_expr(expr); - }), + syn::MacroDelimiter::Paren(_binding_0) => { + i.tokens = i + .parse_body_with( + syn::punctuated::Punctuated::::parse_terminated, + ) + .ok() + .map(|mut exprs| { + for arg in &mut exprs { + self.visit_expr_mut(arg); + } + exprs.to_token_stream() + }) + .unwrap_or(i.tokens.clone()); + } + syn::MacroDelimiter::Brace(_binding_0) => { + i.tokens = i + .parse_body_with(syn::Block::parse_within) + .ok() + .map(|mut stmts| { + for stmt in &mut stmts { + self.visit_stmt_mut(stmt); + } + syn::punctuated::Punctuated::::from_iter(stmts) + .to_token_stream() + }) + .unwrap_or(i.tokens.clone()); + } + syn::MacroDelimiter::Bracket(_binding_0) => { + i.tokens = i + .parse_body_with( + syn::punctuated::Punctuated::::parse_terminated, + ) + .ok() + .map(|mut exprs| { + for arg in &mut exprs { + self.visit_expr_mut(arg); + } + exprs.to_token_stream() + }) + .unwrap_or(i.tokens.clone()); + } } } } diff --git a/stageleft_macro/src/quote_impl/mod.rs b/stageleft_macro/src/quote_impl/mod.rs index f26b533be7d3..475999680ee1 100644 --- a/stageleft_macro/src/quote_impl/mod.rs +++ b/stageleft_macro/src/quote_impl/mod.rs @@ -1,32 +1,34 @@ use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens}; -use syn::visit::Visit; +use syn::visit_mut::VisitMut; use self::free_variable::FreeVariableVisitor; mod free_variable; -pub fn q_impl(root: TokenStream, expr: syn::Expr) -> TokenStream { +pub fn q_impl(root: TokenStream, mut expr: syn::Expr) -> TokenStream { let mut visitor = FreeVariableVisitor::default(); - visitor.visit_expr(&expr); + visitor.visit_expr_mut(&mut expr); let unitialized_free_variables = visitor.free_variables.iter().map(|i| { - let mut i_without_span = i.clone(); - i_without_span.set_span(Span::call_site()); - let ident_str = i.to_string(); + let ident_str = format!("{}__free", i); + + let i_renamed = syn::Ident::new(&ident_str, i.span()); + let mut i_outer = i.clone(); + i_outer.set_span(Span::call_site()); + quote!( #[allow(unused, non_upper_case_globals, non_snake_case)] - let #i = { - let _out = ::#root::runtime_support::FreeVariable::uninitialized(&#i_without_span); - _vec_to_set.push((#ident_str.to_string(), ::#root::runtime_support::FreeVariable::to_tokens(#i_without_span))); + let #i_renamed = { + let _out = ::#root::runtime_support::FreeVariableWithContext::uninitialized(&#i_outer, __stageleft_ctx); + _vec_to_set.push((#ident_str.to_string(), ::#root::runtime_support::FreeVariableWithContext::to_tokens(#i_outer, __stageleft_ctx))); _out }; ) }); let uninit_forgets = visitor.free_variables.iter().map(|i| { - let mut i_without_span = i.clone(); - i_without_span.set_span(Span::call_site()); + let i_without_span = syn::Ident::new(&format!("{}__free", i), Span::call_site()); quote!( #[allow(unused, non_upper_case_globals, non_snake_case)] ::std::mem::forget(#i_without_span); @@ -38,7 +40,7 @@ pub fn q_impl(root: TokenStream, expr: syn::Expr) -> TokenStream { syn::parse_str(&expr.clone().into_token_stream().to_string()).unwrap(); quote!({ - move |set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut #root::internal::TokenStream, _vec_to_set: &mut #root::internal::CaptureVec, run: bool| { + move |__stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut #root::internal::TokenStream, _vec_to_set: &mut #root::internal::CaptureVec, run: bool| { #(#unitialized_free_variables;)* *set_mod = module_path!().to_string(); diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local@macro_tokens.snap index 7a48e3cdfdef..07671ec33863 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,16 +32,17 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - (x + 2) + (x + 2) + (x__free + 2) + (x__free + 2) }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } } - #[allow(unreachable_code, unused_qualifications)] { (x + 2) + (x + 2) } + #[allow(unreachable_code, unused_qualifications)] + { (x__free + 2) + (x__free + 2) } } } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block@macro_tokens.snap index b5f826004f69..3446a20152f0 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,11 +32,11 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - { let _ = x + 2; let _ = x + 2; } + { let _ = x__free + 2; let _ = x__free + 2; } }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } @@ -37,8 +44,8 @@ fn main() { #[allow(unreachable_code, unused_qualifications)] { { - let _ = x + 2; - let _ = x + 2; + let _ = x__free + 2; + let _ = x__free + 2; } } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block_let@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block_let@macro_tokens.snap index 84a8c67dea1d..cecf987e32d9 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block_let@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_copy_local_block_let@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,11 +32,11 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - { let x = x + 2; let _ = x + 2; } + { let x = x__free + 2; let _ = x + 2; } }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } @@ -37,7 +44,7 @@ fn main() { #[allow(unreachable_code, unused_qualifications)] { { - let x = x + 2; + let x = x__free + 2; let _ = x + 2; } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_in_macro@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_in_macro@macro_tokens.snap index 13d47903d640..bca5e0f6058b 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_in_macro@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_in_macro@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,16 +32,16 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - dbg!(x) + dbg!(x__free) }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } } - #[allow(unreachable_code, unused_qualifications)] { dbg!(x) } + #[allow(unreachable_code, unused_qualifications)] { dbg!(x__free) } } } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local@macro_tokens.snap index 1ba7491cf55f..9ac5fe90be4e 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,16 +32,16 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - x + 2 + x__free + 2 }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } } - #[allow(unreachable_code, unused_qualifications)] { x + 2 } + #[allow(unreachable_code, unused_qualifications)] { x__free + 2 } } } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local_mut@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local_mut@macro_tokens.snap index 70bb2d59ba99..90141a59dd71 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local_mut@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__capture_local_mut@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, @@ -12,12 +13,18 @@ fn main() { run: bool| { #[allow(unused, non_upper_case_globals, non_snake_case)] - let x = { - let _out = ::stageleft::runtime_support::FreeVariable::uninitialized(&x); + let x__free = { + let _out = ::stageleft::runtime_support::FreeVariableWithContext::uninitialized( + &x, + __stageleft_ctx, + ); _vec_to_set .push(( - "x".to_string(), - ::stageleft::runtime_support::FreeVariable::to_tokens(x), + "x__free".to_string(), + ::stageleft::runtime_support::FreeVariableWithContext::to_tokens( + x, + __stageleft_ctx, + ), )); _out }; @@ -25,16 +32,16 @@ fn main() { *set_crate_name = option_env!("STAGELEFT_FINAL_CRATE_NAME") .unwrap_or(env!("CARGO_PKG_NAME")); *set_tokens = stageleft::internal::quote! { - x += 2 + x__free += 2 }; if !run { #[allow(unused, non_upper_case_globals, non_snake_case)] - ::std::mem::forget(x); + ::std::mem::forget(x__free); unsafe { return ::std::mem::MaybeUninit::uninit().assume_init(); } } - #[allow(unreachable_code, unused_qualifications)] { x += 2 } + #[allow(unreachable_code, unused_qualifications)] { x__free += 2 } } } } diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_enum_creation@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_enum_creation@macro_tokens.snap index 819cbbd28c3c..1cae8b08b7d5 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_enum_creation@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_enum_creation@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_local@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_local@macro_tokens.snap index 7169ceb62557..3130580842c0 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_local@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_local@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_struct_creation@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_struct_creation@macro_tokens.snap index e72911de50bc..298d31b1ed83 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_struct_creation@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__non_capture_struct_creation@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-2.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-2.snap index 236653f1143e..a2cc7a1d4240 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-2.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-2.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-3.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-3.snap index a7c8bf5a87af..041b3a8a8ddd 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-3.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-3.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-4.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-4.snap index 3a7639ba687a..cca0039f9bfd 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-4.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens-4.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens.snap index 06b3866d73bd..5f02ee3b0f6d 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__prelude_enum_variants@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__simple@macro_tokens.snap b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__simple@macro_tokens.snap index d9143ddb3d98..c80aa9720ce9 100644 --- a/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__simple@macro_tokens.snap +++ b/stageleft_macro/src/quote_impl/snapshots/stageleft_macro__quote_impl__tests__simple@macro_tokens.snap @@ -5,6 +5,7 @@ expression: "prettyplease :: unparse(& wrapped)" fn main() { { move | + __stageleft_ctx: &_, set_mod: &mut String, set_crate_name: &mut &'static str, set_tokens: &mut stageleft::internal::TokenStream, diff --git a/stageleft_tool/src/lib.rs b/stageleft_tool/src/lib.rs index ea239830bfb3..6cc232eeb6b5 100644 --- a/stageleft_tool/src/lib.rs +++ b/stageleft_tool/src/lib.rs @@ -244,6 +244,18 @@ impl VisitMut for GenFinalPubVistor { #[cfg(stageleft_macro)] #e ); + } else if let syn::Item::Static(e) = i { + if matches!(e.vis, syn::Visibility::Public(_)) { + let e_name = &e.ident; + *i = parse_quote!(pub use #cur_path::#e_name;); + return; + } + } else if let syn::Item::Const(e) = i { + if matches!(e.vis, syn::Visibility::Public(_)) { + let e_name = &e.ident; + *i = parse_quote!(pub use #cur_path::#e_name;); + return; + } } }