Skip to content

Fix and reenable profiling CI action #2632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/comment-profiling-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,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: |
Expand All @@ -57,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<<EOF" >> $GITHUB_OUTPUT
echo "$BENCH_OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
Expand Down
3 changes: 2 additions & 1 deletion node-graph/graph-craft/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<NodeNetwork>(document["network_interface"]["network"].clone()).expect("Failed to parse document")
let document = (document["network_interface"]["network"].clone()).to_string();
serde_json::from_str::<NodeNetwork>(&document).expect("Failed to parse document")
}

pub fn compile(network: NodeNetwork) -> ProtoNetwork {
Expand Down
10 changes: 5 additions & 5 deletions node-graph/interpreted-executor/benches/run_cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 3 additions & 4 deletions node-graph/interpreted-executor/benches/run_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
});
Expand Down
11 changes: 9 additions & 2 deletions node-graph/interpreted-executor/src/dynamic_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn ...>`.
Expand Down Expand Up @@ -101,6 +100,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<Type> {
self.typing_context.type_of(self.output).map(|node_io| node_io.return_value.clone())
}
Expand Down Expand Up @@ -239,7 +246,7 @@ impl BorrowTree {
/// This ensures that no borrowed data can escape the node graph.
pub async fn eval_tagged_value<I>(&self, id: NodeId, input: I) -> Result<TaggedValue, String>
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));
Expand Down
Loading