From c74f5203b0db1cd33e39b0c8a98e05cbe2bb346f Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 6 May 2025 17:20:27 +0200 Subject: [PATCH 1/3] Reenable profiling ci action --- .github/workflows/comment-profiling-changes.yaml | 2 -- node-graph/graph-craft/src/util.rs | 3 ++- node-graph/interpreted-executor/benches/run_cached.rs | 10 +++++----- node-graph/interpreted-executor/benches/run_once.rs | 7 +++---- .../interpreted-executor/src/dynamic_executor.rs | 10 +++++++++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/comment-profiling-changes.yaml b/.github/workflows/comment-profiling-changes.yaml index 6f7fc17dba..8ff65294af 100644 --- a/.github/workflows/comment-profiling-changes.yaml +++ b/.github/workflows/comment-profiling-changes.yaml @@ -9,8 +9,6 @@ env: jobs: profile: - # TODO(TrueDoctor): Fix and reenable this action - if: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/node-graph/graph-craft/src/util.rs b/node-graph/graph-craft/src/util.rs index 6a54268360..eddeec842c 100644 --- a/node-graph/graph-craft/src/util.rs +++ b/node-graph/graph-craft/src/util.rs @@ -4,7 +4,8 @@ use crate::proto::ProtoNetwork; pub fn load_network(document_string: &str) -> NodeNetwork { let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document"); - serde_json::from_value::(document["network_interface"]["network"].clone()).expect("Failed to parse document") + let document = (document["network_interface"]["network"].clone()).to_string(); + serde_json::from_str::(&document).expect("Failed to parse document") } pub fn compile(network: NodeNetwork) -> ProtoNetwork { diff --git a/node-graph/interpreted-executor/benches/run_cached.rs b/node-graph/interpreted-executor/benches/run_cached.rs index 9ee5758214..e6b132668e 100644 --- a/node-graph/interpreted-executor/benches/run_cached.rs +++ b/node-graph/interpreted-executor/benches/run_cached.rs @@ -2,16 +2,16 @@ mod benchmark_util; use benchmark_util::{bench_for_each_demo, setup_network}; use criterion::{Criterion, criterion_group, criterion_main}; -use graph_craft::graphene_compiler::Executor; -use graphene_std::transform::Footprint; +use graphene_std::Context; fn subsequent_evaluations(c: &mut Criterion) { let mut group = c.benchmark_group("Subsequent Evaluations"); - let footprint = Footprint::default(); + let context: Context = None; bench_for_each_demo(&mut group, |name, g| { let (executor, _) = setup_network(name); - futures::executor::block_on((&executor).execute(criterion::black_box(footprint))).unwrap(); - g.bench_function(name, |b| b.iter(|| futures::executor::block_on((&executor).execute(criterion::black_box(footprint))))); + g.bench_function(name, |b| { + b.iter(|| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), criterion::black_box(context.clone()))).unwrap()) + }); }); group.finish(); } diff --git a/node-graph/interpreted-executor/benches/run_once.rs b/node-graph/interpreted-executor/benches/run_once.rs index 33d9ba31b2..a55b6843ec 100644 --- a/node-graph/interpreted-executor/benches/run_once.rs +++ b/node-graph/interpreted-executor/benches/run_once.rs @@ -2,17 +2,16 @@ mod benchmark_util; use benchmark_util::{bench_for_each_demo, setup_network}; use criterion::{Criterion, criterion_group, criterion_main}; -use graph_craft::graphene_compiler::Executor; -use graphene_std::transform::Footprint; +use graphene_std::Context; fn run_once(c: &mut Criterion) { let mut group = c.benchmark_group("Run Once"); - let footprint = Footprint::default(); + let context: Context = None; bench_for_each_demo(&mut group, |name, g| { g.bench_function(name, |b| { b.iter_batched( || setup_network(name), - |(executor, _)| futures::executor::block_on((&executor).execute(criterion::black_box(footprint))), + |(executor, _)| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), criterion::black_box(context.clone()))).unwrap(), criterion::BatchSize::SmallInput, ) }); diff --git a/node-graph/interpreted-executor/src/dynamic_executor.rs b/node-graph/interpreted-executor/src/dynamic_executor.rs index b3e521bf59..137f6958fe 100644 --- a/node-graph/interpreted-executor/src/dynamic_executor.rs +++ b/node-graph/interpreted-executor/src/dynamic_executor.rs @@ -101,6 +101,14 @@ impl DynamicExecutor { self.typing_context.type_of(self.output).map(|node_io| node_io.call_argument.clone()) } + pub fn tree(&self) -> &BorrowTree { + &self.tree + } + + pub fn output(&self) -> NodeId { + self.output + } + pub fn output_type(&self) -> Option { self.typing_context.type_of(self.output).map(|node_io| node_io.return_value.clone()) } @@ -239,7 +247,7 @@ impl BorrowTree { /// This ensures that no borrowed data can escape the node graph. pub async fn eval_tagged_value(&self, id: NodeId, input: I) -> Result where - I: StaticType + 'static + Send + Sync + UnwindSafe, + I: StaticType + 'static + Send + Sync, { let (node, _path) = self.nodes.get(&id).cloned().ok_or("Output node not found in executor")?; let output = node.eval(Box::new(input)); From 4225112018774348db0643e5d991b4fc87137e69 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 6 May 2025 20:03:14 +0200 Subject: [PATCH 2/3] Remove deprecated iai feature flag --- .github/workflows/comment-profiling-changes.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment-profiling-changes.yaml b/.github/workflows/comment-profiling-changes.yaml index 8ff65294af..d130fdc557 100644 --- a/.github/workflows/comment-profiling-changes.yaml +++ b/.github/workflows/comment-profiling-changes.yaml @@ -46,7 +46,7 @@ jobs: - name: Run baseline benchmarks run: | - cargo bench --bench compile_demo_art --features=iai -- --save-baseline=master + cargo bench --bench compile_demo_art_iai -- --save-baseline=master - name: Checkout PR branch run: | @@ -55,7 +55,7 @@ jobs: - name: Run PR benchmarks id: benchmark run: | - BENCH_OUTPUT=$(cargo bench --bench compile_demo_art --features=iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g') + BENCH_OUTPUT=$(cargo bench --bench compile_demo_art_iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g') echo "BENCHMARK_OUTPUT<> $GITHUB_OUTPUT echo "$BENCH_OUTPUT" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT From 32c3709a4c8adb1f3a7240f5669f8df6aa85c08e Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 6 May 2025 20:29:13 +0200 Subject: [PATCH 3/3] Remove unused import --- node-graph/interpreted-executor/src/dynamic_executor.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node-graph/interpreted-executor/src/dynamic_executor.rs b/node-graph/interpreted-executor/src/dynamic_executor.rs index 137f6958fe..089b936074 100644 --- a/node-graph/interpreted-executor/src/dynamic_executor.rs +++ b/node-graph/interpreted-executor/src/dynamic_executor.rs @@ -8,7 +8,6 @@ use graph_craft::proto::{ConstructionArgs, GraphError, LocalFuture, NodeContaine use graph_craft::proto::{GraphErrorType, GraphErrors}; use std::collections::{HashMap, HashSet}; use std::error::Error; -use std::panic::UnwindSafe; use std::sync::Arc; /// An executor of a node graph that does not require an online compilation server, and instead uses `Box`.