Fix and reenable profiling CI action (#2632)

* Reenable profiling ci action

* Remove deprecated iai feature flag

* Remove unused import

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert 2025-05-18 22:31:15 +02:00 committed by GitHub
parent ebf351277d
commit 7a2144e31e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 16 deletions

View file

@ -9,8 +9,6 @@ env:
jobs: jobs:
profile: profile:
# TODO(TrueDoctor): Fix and reenable this action
if: false
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -48,7 +46,7 @@ jobs:
- name: Run baseline benchmarks - name: Run baseline benchmarks
run: | 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 - name: Checkout PR branch
run: | run: |
@ -57,7 +55,7 @@ jobs:
- name: Run PR benchmarks - name: Run PR benchmarks
id: benchmark id: benchmark
run: | 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 "BENCHMARK_OUTPUT<<EOF" >> $GITHUB_OUTPUT
echo "$BENCH_OUTPUT" >> $GITHUB_OUTPUT echo "$BENCH_OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT

View file

@ -4,7 +4,8 @@ use crate::proto::ProtoNetwork;
pub fn load_network(document_string: &str) -> NodeNetwork { pub fn load_network(document_string: &str) -> NodeNetwork {
let document: serde_json::Value = serde_json::from_str(document_string).expect("Failed to parse document"); 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 { pub fn compile(network: NodeNetwork) -> ProtoNetwork {

View file

@ -2,16 +2,16 @@ mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network}; use benchmark_util::{bench_for_each_demo, setup_network};
use criterion::{Criterion, criterion_group, criterion_main}; use criterion::{Criterion, criterion_group, criterion_main};
use graph_craft::graphene_compiler::Executor; use graphene_std::Context;
use graphene_std::transform::Footprint;
fn subsequent_evaluations(c: &mut Criterion) { fn subsequent_evaluations(c: &mut Criterion) {
let mut group = c.benchmark_group("Subsequent Evaluations"); let mut group = c.benchmark_group("Subsequent Evaluations");
let footprint = Footprint::default(); let context: Context = None;
bench_for_each_demo(&mut group, |name, g| { bench_for_each_demo(&mut group, |name, g| {
let (executor, _) = setup_network(name); let (executor, _) = setup_network(name);
futures::executor::block_on((&executor).execute(criterion::black_box(footprint))).unwrap(); g.bench_function(name, |b| {
g.bench_function(name, |b| b.iter(|| futures::executor::block_on((&executor).execute(criterion::black_box(footprint))))); b.iter(|| futures::executor::block_on(executor.tree().eval_tagged_value(executor.output(), criterion::black_box(context.clone()))).unwrap())
});
}); });
group.finish(); group.finish();
} }

View file

@ -2,17 +2,16 @@ mod benchmark_util;
use benchmark_util::{bench_for_each_demo, setup_network}; use benchmark_util::{bench_for_each_demo, setup_network};
use criterion::{Criterion, criterion_group, criterion_main}; use criterion::{Criterion, criterion_group, criterion_main};
use graph_craft::graphene_compiler::Executor; use graphene_std::Context;
use graphene_std::transform::Footprint;
fn run_once(c: &mut Criterion) { fn run_once(c: &mut Criterion) {
let mut group = c.benchmark_group("Run Once"); let mut group = c.benchmark_group("Run Once");
let footprint = Footprint::default(); let context: Context = None;
bench_for_each_demo(&mut group, |name, g| { bench_for_each_demo(&mut group, |name, g| {
g.bench_function(name, |b| { g.bench_function(name, |b| {
b.iter_batched( b.iter_batched(
|| setup_network(name), || 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, criterion::BatchSize::SmallInput,
) )
}); });

View file

@ -8,7 +8,6 @@ use graph_craft::proto::{ConstructionArgs, GraphError, LocalFuture, NodeContaine
use graph_craft::proto::{GraphErrorType, GraphErrors}; use graph_craft::proto::{GraphErrorType, GraphErrors};
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::error::Error; use std::error::Error;
use std::panic::UnwindSafe;
use std::sync::Arc; use std::sync::Arc;
/// An executor of a node graph that does not require an online compilation server, and instead uses `Box<dyn ...>`. /// An executor of a node graph that does not require an online compilation server, and instead uses `Box<dyn ...>`.
@ -101,6 +100,14 @@ impl DynamicExecutor {
self.typing_context.type_of(self.output).map(|node_io| node_io.call_argument.clone()) 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> { pub fn output_type(&self) -> Option<Type> {
self.typing_context.type_of(self.output).map(|node_io| node_io.return_value.clone()) self.typing_context.type_of(self.output).map(|node_io| node_io.return_value.clone())
} }
@ -239,7 +246,7 @@ impl BorrowTree {
/// This ensures that no borrowed data can escape the node graph. /// 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> pub async fn eval_tagged_value<I>(&self, id: NodeId, input: I) -> Result<TaggedValue, String>
where 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 (node, _path) = self.nodes.get(&id).cloned().ok_or("Output node not found in executor")?;
let output = node.eval(Box::new(input)); let output = node.eval(Box::new(input));