Skip to content

Commit c1d8d81

Browse files
Merge pull request #311 from egraphs-good/speedup-new-backend
Speedup new backend
2 parents 528b3e9 + 4a43cd8 commit c1d8d81

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

Cargo.lock

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ crate-type = ["cdylib"]
1212
[dependencies]
1313
pyo3 = { version = "0.24.2", features = ["extension-module"] }
1414

15-
# include this bugfix https://github.com/egraphs-good/egglog/pull/629
16-
egglog = { git = "https://github.com/saulshanabrook/egg-smol.git", rev = "1e638e6" }
15+
egglog = { git = "https://github.com/egraphs-good/egglog.git", rev = "5542549" }
1716
# egglog = { path = "../egg-smol" }
18-
egglog-bridge = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "1a1f913" }
19-
core-relations = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "1a1f913" }
20-
egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "202078f" }
17+
egglog-bridge = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "cd51d04" }
18+
core-relations = { git = "https://github.com/egraphs-good/egglog-backend.git", rev = "cd51d04" }
19+
egglog-experimental = { git = "https://github.com/egraphs-good/egglog-experimental", rev = "255b67a" }
2120
egraph-serialize = { version = "0.2.0", features = ["serde", "graphviz"] }
2221
serde_json = "1.0.140"
2322
pyo3-log = "0.12.4"
2423
log = "0.4.27"
2524
lalrpop-util = { version = "0.22", features = ["lexer"] }
2625
ordered-float = "3.7.0"
2726
uuid = { version = "1.17.0", features = ["v4"] }
27+
rayon = "1.10.0"
2828

2929
# Use patched version of egglog in experimental
3030
[patch.'https://github.com/egraphs-good/egglog']
3131
# egglog = { git = "https://github.com/egraphs-good//egglog.git", rev = "d2fa5b733de0796fb187dc5a27e570d5644aa75a" }
3232
# egglog = { path = "../egg-smol" }
33-
egglog = { git = "https://github.com/saulshanabrook/egg-smol.git", rev = "1e638e6" }
33+
# egglog = { git = "https://github.com/egraphs-good//egglog.git", rev = "5542549" }
3434

3535
# enable debug symbols for easier profiling
3636
[profile.release]

src/conversions.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Create wrappers around input types so that convert from pyobjects to them
22
// and then from them to the egg_smol types
33
use crate::utils::*;
4+
use egglog::extract::DefaultCost;
45
use ordered_float::OrderedFloat;
56
use pyo3::prelude::*;
67
use pyo3::types::{PyDelta, PyDeltaAccess};
@@ -258,7 +259,7 @@ convert_enums!(
258259
Include(span: Span, path: String)
259260
i -> egglog::ast::Command::Include(i.span.clone().into(), (&i.path).into()),
260261
egglog::ast::Command::Include(span, p) => Include { span: span.into(), path: p.to_string() };
261-
Constructor(span: Span, name: String, schema: Schema, cost: Option<usize>, unextractable: bool)
262+
Constructor(span: Span, name: String, schema: Schema, cost: Option<DefaultCost>, unextractable: bool)
262263
c -> egglog::ast::Command::Constructor {
263264
span: c.span.clone().into(),
264265
name: (&c.name).into(),
@@ -325,7 +326,7 @@ convert_enums!(
325326
egglog::ast::Subdatatypes::NewSort(name, args) => NewSort { name: name.to_string(), args: args.iter().map(|e| e.into()).collect() }
326327
};
327328
egglog::ExtractReport: "{:?}" => ExtractReport {
328-
Best(termdag: TermDag, cost: usize, term: Term)
329+
Best(termdag: TermDag, cost: DefaultCost, term: Term)
329330
b -> egglog::ExtractReport::Best {
330331
termdag: (&b.termdag).into(),
331332
cost: b.cost,
@@ -384,7 +385,7 @@ convert_struct!(
384385
span: Span,
385386
name: String,
386387
types: Vec<String>,
387-
cost: Option<usize> = None
388+
cost: Option<DefaultCost> = None
388389
)
389390
v -> egglog::ast::Variant {span: v.span.clone().into(), name: (&v.name).into(), types: v.types.iter().map(|v| v.into()).collect(), cost: v.cost},
390391
v -> Variant {span: v.span.clone().into(), name: v.name.to_string(), types: v.types.iter().map(|v| v.to_string()).collect(), cost: v.cost};

src/egraph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::error::{EggResult, WrappedError};
55
use crate::py_object_sort::PyObjectSort;
66
use crate::serialize::SerializedEGraph;
77

8-
use egglog::prelude::add_leaf_sort;
9-
use egglog::{span, SerializeConfig};
8+
use egglog::prelude::add_base_sort;
9+
use egglog::{SerializeConfig, span};
1010
use log::info;
1111
use pyo3::prelude::*;
1212
use std::path::PathBuf;
@@ -38,7 +38,7 @@ impl EGraph {
3838
egraph.fact_directory = fact_directory;
3939
egraph.seminaive = seminaive;
4040
if let Some(py_object_sort) = py_object_sort {
41-
add_leaf_sort(&mut egraph, py_object_sort, span!()).unwrap();
41+
add_base_sort(&mut egraph, py_object_sort, span!()).unwrap();
4242
}
4343
Self {
4444
egraph,

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ use pyo3::prelude::*;
1111
/// Bindings for egglog rust library
1212
#[pymodule]
1313
fn bindings(m: &Bound<'_, PyModule>) -> PyResult<()> {
14+
rayon::ThreadPoolBuilder::new()
15+
.num_threads(1)
16+
.build_global()
17+
.unwrap();
18+
1419
pyo3_log::init();
1520

1621
m.add_class::<crate::py_object_sort::PyObjectSort>()?;

0 commit comments

Comments
 (0)