diff --git a/Cargo.lock b/Cargo.lock index 293b85ff30..15d146694b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2887,6 +2887,7 @@ dependencies = [ "iai-callgrind", "log", "once_cell", + "preprocessor", "serde", "wgpu-executor", ] diff --git a/node-graph/interpreted-executor/Cargo.toml b/node-graph/interpreted-executor/Cargo.toml index 1a6185c88a..b8fe6eba1e 100644 --- a/node-graph/interpreted-executor/Cargo.toml +++ b/node-graph/interpreted-executor/Cargo.toml @@ -29,6 +29,7 @@ serde = { workspace = true } graph-craft = { workspace = true, features = ["loading"] } criterion = { workspace = true } iai-callgrind = { workspace = true } +preprocessor = { workspace = true } # Benchmarks [[bench]] diff --git a/node-graph/interpreted-executor/benches/benchmark_util.rs b/node-graph/interpreted-executor/benches/benchmark_util.rs index b2c686c222..71ab004f09 100644 --- a/node-graph/interpreted-executor/benches/benchmark_util.rs +++ b/node-graph/interpreted-executor/benches/benchmark_util.rs @@ -8,8 +8,12 @@ use interpreted_executor::dynamic_executor::DynamicExecutor; use interpreted_executor::util::wrap_network_in_scope; pub fn setup_network(name: &str) -> (DynamicExecutor, ProtoNetwork) { - let network = load_from_name(name); + let mut network = load_from_name(name); let editor_api = std::sync::Arc::new(EditorApi::default()); + println!("generating substitutions"); + let substitutions = preprocessor::generate_node_substitutions(); + println!("expanding network"); + preprocessor::expand_network(&mut network, &substitutions); let network = wrap_network_in_scope(network, editor_api); let proto_network = compile(network); let executor = block_on(DynamicExecutor::new(proto_network.clone())).unwrap(); diff --git a/node-graph/interpreted-executor/benches/run_cached.rs b/node-graph/interpreted-executor/benches/run_cached.rs index 0d645bfc69..e62533bd32 100644 --- a/node-graph/interpreted-executor/benches/run_cached.rs +++ b/node-graph/interpreted-executor/benches/run_cached.rs @@ -10,7 +10,7 @@ fn subsequent_evaluations(c: &mut Criterion) { bench_for_each_demo(&mut group, |name, g| { let (executor, _) = setup_network(name); g.bench_function(name, |b| { - b.iter(|| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), criterion::black_box(context))).unwrap()) + b.iter(|| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), std::hint::black_box(context))).unwrap()) }); }); group.finish(); diff --git a/node-graph/interpreted-executor/benches/run_demo_art_criterion.rs b/node-graph/interpreted-executor/benches/run_demo_art_criterion.rs index fb0cf34094..7f58565665 100644 --- a/node-graph/interpreted-executor/benches/run_demo_art_criterion.rs +++ b/node-graph/interpreted-executor/benches/run_demo_art_criterion.rs @@ -1,5 +1,5 @@ use criterion::measurement::Measurement; -use criterion::{BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main}; +use criterion::{BenchmarkGroup, Criterion, criterion_group, criterion_main}; use graph_craft::graphene_compiler::Executor; use graph_craft::proto::ProtoNetwork; use graph_craft::util::{DEMO_ART, compile, load_from_name}; @@ -16,7 +16,7 @@ fn update_executor(name: &str, c: &mut BenchmarkGroup) { c.bench_function(name, |b| { b.iter_batched( || (executor.clone(), proto_network.clone()), - |(mut executor, network)| futures::executor::block_on(executor.update(black_box(network))), + |(mut executor, network)| futures::executor::block_on(executor.update(std::hint::black_box(network))), criterion::BatchSize::SmallInput, ) }); diff --git a/node-graph/interpreted-executor/benches/run_once.rs b/node-graph/interpreted-executor/benches/run_once.rs index b8c6645412..a7bd7ac714 100644 --- a/node-graph/interpreted-executor/benches/run_once.rs +++ b/node-graph/interpreted-executor/benches/run_once.rs @@ -11,7 +11,7 @@ fn run_once(c: &mut Criterion) { g.bench_function(name, |b| { b.iter_batched( || setup_network(name), - |(executor, _)| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), criterion::black_box(context))).unwrap(), + |(executor, _)| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), std::hint::black_box(context))).unwrap(), criterion::BatchSize::SmallInput, ) }); diff --git a/node-graph/interpreted-executor/benches/update_executor.rs b/node-graph/interpreted-executor/benches/update_executor.rs index 102dcdd026..ca5f4c0a4a 100644 --- a/node-graph/interpreted-executor/benches/update_executor.rs +++ b/node-graph/interpreted-executor/benches/update_executor.rs @@ -16,7 +16,7 @@ fn update_executor(c: &mut Criterion) { let executor = futures::executor::block_on(DynamicExecutor::new(empty)).unwrap(); (executor, proto_network) }, - |(mut executor, network)| futures::executor::block_on(executor.update(criterion::black_box(network))), + |(mut executor, network)| futures::executor::block_on(executor.update(std::hint::black_box(network))), criterion::BatchSize::SmallInput, ) }); diff --git a/node-graph/preprocessor/src/lib.rs b/node-graph/preprocessor/src/lib.rs index b0479344a3..f80c203675 100644 --- a/node-graph/preprocessor/src/lib.rs +++ b/node-graph/preprocessor/src/lib.rs @@ -29,6 +29,8 @@ pub fn expand_network(network: &mut NodeNetwork, substitutions: &HashMap HashMap { let mut custom = HashMap::new(); + // We pre initialize the node registry here to avoid a deadlock + let into_node_registry = &*interpreted_executor::node_registry::NODE_REGISTRY; let node_registry = graphene_core::registry::NODE_REGISTRY.lock().unwrap(); for (id, metadata) in graphene_core::registry::NODE_METADATA.lock().unwrap().iter() { let id = id.clone(); @@ -54,8 +56,6 @@ pub fn generate_node_substitutions() -> HashMap = node_io_types .iter()