Run preprocessing on benchmarks and fix deadlock (#3230)
This commit is contained in:
parent
ffc74273cc
commit
84e44810d2
|
|
@ -2887,6 +2887,7 @@ dependencies = [
|
|||
"iai-callgrind",
|
||||
"log",
|
||||
"once_cell",
|
||||
"preprocessor",
|
||||
"serde",
|
||||
"wgpu-executor",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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]]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<M: Measurement>(name: &str, c: &mut BenchmarkGroup<M>) {
|
|||
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,
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ pub fn expand_network(network: &mut NodeNetwork, substitutions: &HashMap<ProtoNo
|
|||
|
||||
pub fn generate_node_substitutions() -> HashMap<ProtoNodeIdentifier, DocumentNode> {
|
||||
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<ProtoNodeIdentifier, DocumentNod
|
|||
|
||||
let identity_node = ops::identity::IDENTIFIER;
|
||||
|
||||
let into_node_registry = &interpreted_executor::node_registry::NODE_REGISTRY;
|
||||
|
||||
let mut generated_nodes = 0;
|
||||
let mut nodes: HashMap<_, _, _> = node_io_types
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Reference in New Issue