mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 16:38:13 +08:00
Replace hashing algorithm and disable debug logging for improved performance
This commit is contained in:
committed by
Keavon Chambers
parent
7ce9d6db05
commit
1c50f0030c
Generated
+8
@@ -1663,6 +1663,7 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
"serde",
|
"serde",
|
||||||
"specta",
|
"specta",
|
||||||
|
"xxhash-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1713,6 +1714,7 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
"vulkan-executor",
|
"vulkan-executor",
|
||||||
"wgpu-executor",
|
"wgpu-executor",
|
||||||
|
"xxhash-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5944,6 +5946,12 @@ version = "0.8.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xxhash-rust"
|
||||||
|
version = "0.8.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "735a71d46c4d68d71d4b24d03fdc2b98e38cea81730595801db779c04fe80d70"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zune-inflate"
|
name = "zune-inflate"
|
||||||
version = "0.2.50"
|
version = "0.2.50"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ exclude = [
|
|||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
specta = { git = "https://github.com/oscartbeaumont/rspc", rev = "9725ddbfe40183debc055b88c37910eb6f818eae", features = ["glam"] }
|
specta = { git = "https://github.com/oscartbeaumont/rspc", rev = "9725ddbfe40183debc055b88c37910eb6f818eae", features = ["glam"] }
|
||||||
|
xxhash-rust = { version = "0.8.4", features = ["xxh3"] }
|
||||||
|
|
||||||
[profile.release.package.graphite-wasm]
|
[profile.release.package.graphite-wasm]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
@@ -47,5 +48,11 @@ opt-level = 3
|
|||||||
[profile.dev.package.autoquant]
|
[profile.dev.package.autoquant]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.dev.package.image]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.dev.package.xxhash-rust]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
#[profile.dev]
|
#[profile.dev]
|
||||||
#opt-level = 3
|
#opt-level = 3
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ accepted = [
|
|||||||
"MPL-2.0",
|
"MPL-2.0",
|
||||||
"CC0-1.0",
|
"CC0-1.0",
|
||||||
"OpenSSL",
|
"OpenSSL",
|
||||||
|
"BSL-1.0",
|
||||||
]
|
]
|
||||||
ignore-build-dependencies = true
|
ignore-build-dependencies = true
|
||||||
ignore-dev-dependencies = true
|
ignore-dev-dependencies = true
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ allow = [
|
|||||||
"MPL-2.0",
|
"MPL-2.0",
|
||||||
"CC0-1.0",
|
"CC0-1.0",
|
||||||
"OpenSSL",
|
"OpenSSL",
|
||||||
|
"BSL-1.0",
|
||||||
#"Apache-2.0 WITH LLVM-exception",
|
#"Apache-2.0 WITH LLVM-exception",
|
||||||
]
|
]
|
||||||
# List of explicitly disallowed licenses
|
# List of explicitly disallowed licenses
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ impl NodeGraphExecutor {
|
|||||||
scoped_network.duplicate_outputs(&mut generate_uuid);
|
scoped_network.duplicate_outputs(&mut generate_uuid);
|
||||||
scoped_network.remove_dead_nodes();
|
scoped_network.remove_dead_nodes();
|
||||||
|
|
||||||
debug!("Execute document network:\n{scoped_network:#?}");
|
//debug!("Execute document network:\n{scoped_network:#?}");
|
||||||
|
|
||||||
// We assume only one output
|
// We assume only one output
|
||||||
assert_eq!(scoped_network.outputs.len(), 1, "Graph with multiple outputs not yet handled");
|
assert_eq!(scoped_network.outputs.len(), 1, "Graph with multiple outputs not yet handled");
|
||||||
let c = Compiler {};
|
let c = Compiler {};
|
||||||
let proto_network = c.compile_single(scoped_network, true)?;
|
let proto_network = c.compile_single(scoped_network, true)?;
|
||||||
debug!("Execute proto network:\n{proto_network}");
|
//debug!("Execute proto network:\n{proto_network}");
|
||||||
assert_ne!(proto_network.nodes.len(), 0, "No protonodes exist?");
|
assert_ne!(proto_network.nodes.len(), 0, "No protonodes exist?");
|
||||||
if let Err(e) = self.executor.update(proto_network) {
|
if let Err(e) = self.executor.update(proto_network) {
|
||||||
error!("Failed to update executor:\n{}", e);
|
error!("Failed to update executor:\n{}", e);
|
||||||
|
|||||||
@@ -24,3 +24,4 @@ specta.workspace = true
|
|||||||
|
|
||||||
bytemuck = {version = "1.8" }
|
bytemuck = {version = "1.8" }
|
||||||
anyhow = "1.0.66"
|
anyhow = "1.0.66"
|
||||||
|
xxhash-rust = {workspace = true}
|
||||||
|
|||||||
@@ -379,14 +379,7 @@ impl NodeNetwork {
|
|||||||
}
|
}
|
||||||
NodeInput::Value { tagged_value, exposed } => {
|
NodeInput::Value { tagged_value, exposed } => {
|
||||||
// Skip formatting very large values for seconds in performance speedup
|
// Skip formatting very large values for seconds in performance speedup
|
||||||
let name = if matches!(
|
let name = "Value".to_string();
|
||||||
tagged_value,
|
|
||||||
TaggedValue::Image(_) | TaggedValue::RcImage(_) | TaggedValue::Color(_) | TaggedValue::Subpath(_) | TaggedValue::RcSubpath(_)
|
|
||||||
) {
|
|
||||||
"Value".to_string()
|
|
||||||
} else {
|
|
||||||
format!("Value: {:?}", tagged_value)
|
|
||||||
};
|
|
||||||
let new_id = map_ids(id, gen_id());
|
let new_id = map_ids(id, gen_id());
|
||||||
let value_node = DocumentNode {
|
let value_node = DocumentNode {
|
||||||
name,
|
name,
|
||||||
@@ -654,8 +647,6 @@ mod test {
|
|||||||
network.flatten_with_fns(1, |self_id, inner_id| self_id * 10 + inner_id, gen_node_id);
|
network.flatten_with_fns(1, |self_id, inner_id| self_id * 10 + inner_id, gen_node_id);
|
||||||
let flat_network = flat_network();
|
let flat_network = flat_network();
|
||||||
|
|
||||||
println!("{:#?}", network);
|
|
||||||
println!("{:#?}", flat_network);
|
|
||||||
assert_eq!(flat_network, network);
|
assert_eq!(flat_network, network);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +737,7 @@ mod test {
|
|||||||
(
|
(
|
||||||
14,
|
14,
|
||||||
DocumentNode {
|
DocumentNode {
|
||||||
name: "Value: U32(2)".into(),
|
name: "Value".into(),
|
||||||
inputs: vec![NodeInput::Value {
|
inputs: vec![NodeInput::Value {
|
||||||
tagged_value: value::TaggedValue::U32(2),
|
tagged_value: value::TaggedValue::U32(2),
|
||||||
exposed: false,
|
exposed: false,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
use xxhash_rust::xxh3::Xxh3;
|
||||||
|
|
||||||
use crate::document::value;
|
use crate::document::value;
|
||||||
use crate::document::NodeId;
|
use crate::document::NodeId;
|
||||||
@@ -135,7 +136,8 @@ impl ProtoNodeInput {
|
|||||||
impl ProtoNode {
|
impl ProtoNode {
|
||||||
pub fn stable_node_id(&self) -> Option<NodeId> {
|
pub fn stable_node_id(&self) -> Option<NodeId> {
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher = Xxh3::new();
|
||||||
|
|
||||||
self.identifier.name.hash(&mut hasher);
|
self.identifier.name.hash(&mut hasher);
|
||||||
self.construction_args.hash(&mut hasher);
|
self.construction_args.hash(&mut hasher);
|
||||||
match self.input {
|
match self.input {
|
||||||
@@ -593,12 +595,12 @@ mod test {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
ids,
|
ids,
|
||||||
vec![
|
vec![
|
||||||
15907139529964845467,
|
7332206428857154453,
|
||||||
1552706903207877482,
|
946497269036214321,
|
||||||
15211082859148708110,
|
3038115864048241698,
|
||||||
3361684226823984981,
|
1932610308557160863,
|
||||||
16609475913638361514,
|
2105748431407297710,
|
||||||
5640155373642511298
|
8596220090685862327
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ kurbo = { git = "https://github.com/linebender/kurbo.git", features = [
|
|||||||
glam = { version = "0.22", features = ["serde"] }
|
glam = { version = "0.22", features = ["serde"] }
|
||||||
node-macro = { path="../node-macro" }
|
node-macro = { path="../node-macro" }
|
||||||
boxcar = "0.1.0"
|
boxcar = "0.1.0"
|
||||||
|
xxhash-rust = {workspace = true}
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::collections::hash_map::DefaultHasher;
|
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
use xxhash_rust::xxh3::Xxh3;
|
||||||
|
|
||||||
use graphene_core::Node;
|
use graphene_core::Node;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ pub struct CacheNode<T> {
|
|||||||
impl<'i, T: 'i + Hash> Node<'i, T> for CacheNode<T> {
|
impl<'i, T: 'i + Hash> Node<'i, T> for CacheNode<T> {
|
||||||
type Output = &'i T;
|
type Output = &'i T;
|
||||||
fn eval<'s: 'i>(&'s self, input: T) -> Self::Output {
|
fn eval<'s: 'i>(&'s self, input: T) -> Self::Output {
|
||||||
let mut hasher = DefaultHasher::new();
|
let mut hasher = Xxh3::new();
|
||||||
input.hash(&mut hasher);
|
input.hash(&mut hasher);
|
||||||
let hash = hasher.finish();
|
let hash = hasher.finish();
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ impl<'i, T: 'i + Hash> Node<'i, Option<T>> for LetNode<T> {
|
|||||||
fn eval<'s: 'i>(&'s self, input: Option<T>) -> Self::Output {
|
fn eval<'s: 'i>(&'s self, input: Option<T>) -> Self::Output {
|
||||||
match input {
|
match input {
|
||||||
Some(input) => {
|
Some(input) => {
|
||||||
let mut hasher = DefaultHasher::new();
|
let mut hasher = Xxh3::new();
|
||||||
input.hash(&mut hasher);
|
input.hash(&mut hasher);
|
||||||
let hash = hasher.finish();
|
let hash = hasher.finish();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user