From 1b9714a2460a38dd6da08b85552eb9a978ced19a Mon Sep 17 00:00:00 2001 From: J Pratt Date: Thu, 3 Mar 2022 17:03:05 +1100 Subject: [PATCH 1/3] Use edge iteration to marginally improve performance --- ibis/Cargo.lock | 4 ++-- ibis/Cargo.toml | 2 +- ibis/src/recipes.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ibis/Cargo.lock b/ibis/Cargo.lock index fd124220e..fddc377a1 100644 --- a/ibis/Cargo.lock +++ b/ibis/Cargo.lock @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "crepe" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a143ee68e4ec17aa70d0b95a1a5ef2c4e510b79cc3d956ea51bd2fe56d1856bd" +checksum = "6d0c81f0055a7c877a9a69ec9d667a0b14c2b38394c712f54b9a400d035f49a9" dependencies = [ "petgraph", "proc-macro-error", diff --git a/ibis/Cargo.toml b/ibis/Cargo.toml index a43086a6b..d111ccc28 100644 --- a/ibis/Cargo.toml +++ b/ibis/Cargo.toml @@ -22,7 +22,7 @@ wasm = [ "wasm-bindgen", "console_error_panic_hook" ] # Support wasm-bindgen API [dependencies] nom = "7.1.0" paste = "1.0.6" -crepe = "0.1.5" +crepe = "0.1.6" lazy_static = "1.4.0" ibis_macros = { package = "arcsjs_ibis_macros", path = "./ibis_macros" } serde = { version = "1.0", features = ["derive"] } diff --git a/ibis/src/recipes.rs b/ibis/src/recipes.rs index 45fd59e4c..14a2d2ee3 100644 --- a/ibis/src/recipes.rs +++ b/ibis/src/recipes.rs @@ -105,10 +105,10 @@ ibis! { HasTag(s, n, n, tag) <- Solution(s), Claim(n, tag); HasTag(s, source, down, tag) <- // Propagate tags 'downstream' - HasTag(s, source, curr, tag), Node(_down_particle, down, _, _), - (s.has_edge(curr, down)), - !TrustedToRemoveTag(down, tag); + HasTag(s, source, curr, tag), + !TrustedToRemoveTag(down, tag), + (s.has_edge(curr, down)); HasTag(s, source, down, tag) <- // Propagate tags 'across stream' (i.e. inside a particle) HasTag(s, source, curr, tag), From 4a53fdb8f474a48446439cc22fa7fa69564fa786 Mon Sep 17 00:00:00 2001 From: J Pratt Date: Fri, 4 Mar 2022 13:55:14 +1100 Subject: [PATCH 2/3] Propagate tags for edges, not all nodes that have an edge Change-Id: I42288adf9332ba17f7a43bf94541fa88eebdfac9 --- ibis/src/recipes.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibis/src/recipes.rs b/ibis/src/recipes.rs index 14a2d2ee3..04dba6976 100644 --- a/ibis/src/recipes.rs +++ b/ibis/src/recipes.rs @@ -104,11 +104,11 @@ ibis! { KnownType(apply!(y_generic, y_arg)); HasTag(s, n, n, tag) <- Solution(s), Claim(n, tag); - HasTag(s, source, down, tag) <- // Propagate tags 'downstream' - Node(_down_particle, down, _, _), + HasTag(s, source, *down, tag) <- // Propagate tags 'downstream' HasTag(s, source, curr, tag), - !TrustedToRemoveTag(down, tag), - (s.has_edge(curr, down)); + for (up, down) in &s.solution().edges, + (*up == curr), + !TrustedToRemoveTag(*down, tag); HasTag(s, source, down, tag) <- // Propagate tags 'across stream' (i.e. inside a particle) HasTag(s, source, curr, tag), From 59bcf1d9f916f0bb139a87e886e7365e4f952952 Mon Sep 17 00:00:00 2001 From: J Pratt Date: Fri, 4 Mar 2022 16:14:50 +1100 Subject: [PATCH 3/3] Check Type and Capability errors on each edge, not each node --- ibis/src/recipes.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ibis/src/recipes.rs b/ibis/src/recipes.rs index 04dba6976..4b1a6dd08 100644 --- a/ibis/src/recipes.rs +++ b/ibis/src/recipes.rs @@ -121,18 +121,18 @@ ibis! { LessPrivateThan(t1, t2), HasTag(s, source, n, t2); // Check failed, node has a 'more private' tag i.e. is leaking. - TypeError(s, from, from_ty, to, to_ty) <- - Node(_from_p, from, _, from_ty), - Node(_to_p, to, _, to_ty), + TypeError(s, *from, from_ty, *to, to_ty) <- Solution(s), - (s.has_edge(from, to)), + for (from, to) in &s.solution().edges, + Node(_from_p, *from, _, from_ty), + Node(_to_p, *to, _, to_ty), !Subtype(from_ty, to_ty); // Check failed, from writes an incompatible type into to - CapabilityError(s, from, from_capability, to, to_capability) <- - Node(_from_p, from, from_capability, _), - Node(_to_p, to, to_capability, _), + CapabilityError(s, *from, from_capability, *to, to_capability) <- Solution(s), - (s.has_edge(from, to)), + for (from, to) in &s.solution().edges, + Node(_from_p, *from, from_capability, _), + Node(_to_p, *to, to_capability, _), !Capability(from_capability, to_capability); // Check failed, from writes an incompatible type into to KnownType(x) <- Node(_par, _node, _cap, x); // Infer types that are used in the recipes.