Skip to content

Commit 66274f5

Browse files
committed
Filtersets V2
Simplifies filtersets. The primary filter type is now a RelDnf (the ids of spans matching a Disjunctive Normal Form over a source). This makes rewrite rules simpler (many -> one (intersection of DNFS)), and also results in better performance, since we can merge many kinds of nodes into one DNF, which corresponds to only a single scan on the data.
1 parent ff2f9e3 commit 66274f5

File tree

9 files changed

+436
-330
lines changed

9 files changed

+436
-330
lines changed

Cargo.lock

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

docs/filtersets.md

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
THE FILTERSET CALCULUS
1+
THE FILTERSET CALCULUS (v2)
22
---
33

44
### TYPES
55

66
```rust
77
type FiltersetId = usize;
8+
type PreidcateId = usize;
89
struct Predicate {
910
attr: String,
1011
rel: Ordering,
@@ -14,9 +15,8 @@ struct Predicate {
1415
enum Filterset {
1516
Dead,
1617
Primitive(Roaring),
17-
Rel(Predicate, FiltersetId),
18-
RelIntersect(Vec<Predicate>, FiltersetId),
19-
RelUnion(Vec<Predicate>, FiltersetId),
18+
BlackBox(FiltersetId),
19+
RelDnf(Vec<Vec<PredicateId>>, FiltersetId),
2020
And(Vec<FiltersetId>),
2121
Or(Vec<FiltersetId>),
2222
Not(FiltersetId),
@@ -30,25 +30,12 @@ enum Filterset {
3030
And([... And(children) ...]) -> And(flattened)
3131
Or([... Or(children) ...]) -> Or(flattened)
3232
Not(Not(X)) -> X
33-
34-
**Eliminating trivial ops (unimplemeneted)**
3533
And([A]) -> A
3634
Or([A]) -> A
3735

38-
**REL composition**
39-
40-
I. Rel(p1, Rel(p2, A)) -> RelIntersect([p1, p2], A)
41-
II. Rel(p, RelIntersect(ps, A)) -> RelIntersect([p] + ps, A)
42-
III. RelIntersect(ps1, RelIntersect(ps2, A)) -> RelIntersect(ps1 + ps2, A)
43-
IV. RelIntersect(ps, Rel(p, A)) -> RelIntersect(ps + [p], A)
44-
V. RelUnion(ps1, RelUnion(ps2, A)) -> RelUnion(ps1 + ps2, A)
45-
36+
**One Rule To Rule Them All**
37+
1. RelDnf(clauses, RelDnf(clauses2, A)) -> new clauses: c_1 \times c_2 (if the result won't be too big)
4638

47-
**Flattening on the same level (unimplemeneted)**
48-
And([RelIntersect(ps, A), RelIntersect(ps2, A), RelIntersect(_, B) ...])
49-
-> And([RelIntersect(ps1+ps2, A), RelIntersect(_, B)])
50-
- This could be hard to detect, instead there could be just:
51-
And([RelIntersect(ps_1, A), .. RelIntersect(ps_n, A)]) -> RelIntersect(ps_1+..+ps_n, A)
52-
Or([RelUnion(ps, A), RelUnion(ps2, A), RelUnion(_, B) ...])
53-
-> Or([RelUnion(ps1+ps2, A), RelIntersect(_, B)])
54-
- same applies here.
39+
**RelDnf in Or/And**
40+
1. Or([RelDnf(c, A), RelDnf(c2, A), RelDnf(c3, B), RelDnf(c4, B)]) -> Or([RelDnf(c+c2, A), RelDnf(c3+c4, B)])
41+
2. And([RelDnf(c, A), RelDnf(c2, A), RelDnf(c3, B), RelDnf(c4, B)]) -> And([RelDnf(c x c2, A), RelDnf(c3 x c4, B)]) (if not too big)

entrace_core/src/log_provider.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub trait LogProvider {
3535
/// This MUST be cheap as the frontend might call this every frame.
3636
fn len(&self) -> usize;
3737

38-
/// The frontent SHOULD call this at the beginning of each painted frame.
38+
/// The frontent SHOULD call this at the beginning of each painted frame,
39+
/// but there is no guarantee to whether or when it will.
3940
/// This runs on the main thread.
4041
/// The [LogProvider] implementation MUST ensure that this terminates quickly,
4142
/// as it directly affects FPS.

entrace_query/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ anyhow = "1.0.100"
1010
memchr = "2.7.6"
1111
thiserror = "2.0.17"
1212
roaring = "0.11.2"
13+
itertools = "0.14.0"
1314

1415
[[bin]]
1516
name="entrace-query-test"

0 commit comments

Comments
 (0)