[
https://issues.apache.org/jira/browse/TINKERPOP-3311?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Yuxuan Qing updated TINKERPOP-3311:
-----------------------------------
Description:
h1. A constant-false child filter still expands every neighbor
h2. Describe the situation
Hi, Apache TinkerPop developers,
Please consider these two queries:
{code:java}
// q1
g.V(root.id()).out('HIGH').filter(__.constant(2).is(P.lt(1))
).constant(1)
{code}
{code:java}
// q2
g.V(root.id()).out('LOW').filter(__.constant(2).is(P.lt(1))
).constant(1)
{code}
Each query expands one edge label and then applies the same constant
comparison, `2 < 1`. That comparison always rejects the input. Both queries
return no rows.
h2. Which Apache TinkerPop versions are affected?
I reproduced this with TinkerGraph 3.8.2 (OpenJDK 11.0.32.1) and TinkerGraph
3.5.1 (OpenJDK 11.0.30), using Gremlin-Groovy and the default traversal
strategies. The TinkerGraph measurements below ran in a fresh in-memory graph
in a Gremlin Server JVM in Docker on macOS ARM64.
I also ran the same query pair with 300,000 HIGH neighbors and one LOW neighbor
on JanusGraph 1.2.0 (TinkerPop 3.8.2, BerkeleyJE) and HugeGraph 1.7.0
(TinkerPop 3.5.1, RocksDB). The median JVM runtimes for q1 and q2 were *363.223
ms / 0.357 ms* on JanusGraph and *252.663 ms / 0.148 ms* on HugeGraph. Both
providers emitted 300,000 and one neighbors into the constant-false filter in
q1 and q2, respectively.
h2. How to reproduce
Run this setup, then run q1 and q2 with the same traversal source. Consume the
results using `toList()`.
{code:java}
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
def tg = TinkerGraph.open()
def g = tg.traversal()
def root = g.addV('Root').property('anchor', 1).next()
300000.times {
root.addEdge('HIGH', g.addV('Leaf').property('mark', true).next())
}
root.addEdge('LOW', g.addV('Leaf').property('mark', true).next())
{code}
The root has 300,000 neighbors under `HIGH` and one neighbor under `LOW`.
For q1, I get no rows. Median runtime on 3.8.2 is {*}125.833 ms{*}{*}.{*} On
3.5.1 it is {*}120.922 ms{*}.
For q2, I get no rows. Median runtime on 3.8.2 is {*}0.094 ms{*}{*}.{*} On
3.5.1 it is {*}0.090 ms{*}.
TinkerGraph 3.8.2 `PROFILE` excerpt. Rows with blank counts are shown as
recorded.
{code:java}
Step Count Traversers Time (ms) % Dur
q1
VertexStep(OUT,[HIGH],vertex) 300000 300000 26.867 10.95
TraversalFilterStep([ConstantStep(2), IsStep(lt... 218.394 89.02
q2
VertexStep(OUT,[LOW],vertex) 1 1 0.010 13.24
TraversalFilterStep([ConstantStep(2), IsStep(lt... 0.013 16.76
{code}
The final plans retain the constant comparison after the vertex expansion. The
expansion supplies 300,000 inputs to the filter in q1 and one in q2.
h2. Expected performance
Please fold a pure constant-false child filter so the traversal can skip the
preceding read-only expansion.
was:
h1. A constant-false child filter still expands every neighbor
h2. Describe the situation
Hi, Apache TinkerPop developers,
Please consider these two queries:
{code:java}
// q1
g.V(root.id()).out('HIGH').filter(__.constant(2).is(P.lt(1))
).constant(1)
{code}
{code:java}
// q2
g.V(root.id()).out('LOW').filter( __.constant(2).is(P.lt(1))
).constant(1)
{code}
Each query expands one edge label and then applies the same constant
comparison, `2 < 1`. That comparison always rejects the input. Both queries
return no rows.
h2. Which Apache TinkerPop versions are affected?
I reproduced this with TinkerGraph 3.8.2 (OpenJDK 11.0.32.1) and TinkerGraph
3.5.1 (OpenJDK 11.0.30), using Gremlin-Groovy and the default traversal
strategies. The TinkerGraph measurements below ran in a fresh in-memory graph
in a Gremlin Server JVM in Docker on macOS ARM64.
I also ran the same query pair with 300,000 HIGH neighbors and one LOW neighbor
on JanusGraph 1.2.0 (TinkerPop 3.8.2, BerkeleyJE) and HugeGraph 1.7.0
(TinkerPop 3.5.1, RocksDB). The median JVM runtimes for q1 and q2 were *363.223
ms / 0.357 ms* on JanusGraph and *252.663 ms / 0.148 ms* on HugeGraph. Both
providers emitted 300,000 and one neighbors into the constant-false filter in
q1 and q2, respectively.
h2. How to reproduce
Run this setup, then run q1 and q2 with the same traversal source. Consume the
results using `toList()`.
{code:java}
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
def tg = TinkerGraph.open()
def g = tg.traversal()
def root = g.addV('Root').property('anchor', 1).next()
300000.times {
root.addEdge('HIGH', g.addV('Leaf').property('mark', true).next())
}
root.addEdge('LOW', g.addV('Leaf').property('mark', true).next())
{code}
The root has 300,000 neighbors under `HIGH` and one neighbor under `LOW`.
For q1, I get no rows. Median runtime on 3.8.2 is {*}125.833 ms{*}{*}.{*} On
3.5.1 it is \{*}120.922 ms{*}.
For q2, I get no rows. Median runtime on 3.8.2 is {*}0.094 ms{*}{*}.{*} On
3.5.1 it is \{*}0.090 ms{*}.
TinkerGraph 3.8.2 `PROFILE` excerpt. Rows with blank counts are shown as
recorded.
{code:java}
Step Count Traversers Time (ms) % Dur
q1
VertexStep(OUT,[HIGH],vertex) 300000 300000 26.867 10.95
TraversalFilterStep([ConstantStep(2), IsStep(lt... 218.394 89.02
q2
VertexStep(OUT,[LOW],vertex) 1 1 0.010 13.24
TraversalFilterStep([ConstantStep(2), IsStep(lt... 0.013 16.76
{code}
The final plans retain the constant comparison after the vertex expansion. The
expansion supplies 300,000 inputs to the filter in q1 and one in q2.
h2. Expected performance
Please fold a pure constant-false child filter so the traversal can skip the
preceding read-only expansion.
> A constant-false child filter still expands every neighbor
> ----------------------------------------------------------
>
> Key: TINKERPOP-3311
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3311
> Project: TinkerPop
> Issue Type: Bug
> Components: process, tinkergraph
> Affects Versions: 3.5.1, 3.8.2
> Reporter: Yuxuan Qing
> Priority: Major
> Labels: performance
>
> h1. A constant-false child filter still expands every neighbor
> h2. Describe the situation
> Hi, Apache TinkerPop developers,
> Please consider these two queries:
> {code:java}
> // q1
> g.V(root.id()).out('HIGH').filter(__.constant(2).is(P.lt(1))
> ).constant(1)
> {code}
> {code:java}
> // q2
> g.V(root.id()).out('LOW').filter(__.constant(2).is(P.lt(1))
> ).constant(1)
> {code}
> Each query expands one edge label and then applies the same constant
> comparison, `2 < 1`. That comparison always rejects the input. Both queries
> return no rows.
> h2. Which Apache TinkerPop versions are affected?
> I reproduced this with TinkerGraph 3.8.2 (OpenJDK 11.0.32.1) and TinkerGraph
> 3.5.1 (OpenJDK 11.0.30), using Gremlin-Groovy and the default traversal
> strategies. The TinkerGraph measurements below ran in a fresh in-memory graph
> in a Gremlin Server JVM in Docker on macOS ARM64.
> I also ran the same query pair with 300,000 HIGH neighbors and one LOW
> neighbor on JanusGraph 1.2.0 (TinkerPop 3.8.2, BerkeleyJE) and HugeGraph
> 1.7.0 (TinkerPop 3.5.1, RocksDB). The median JVM runtimes for q1 and q2 were
> *363.223 ms / 0.357 ms* on JanusGraph and *252.663 ms / 0.148 ms* on
> HugeGraph. Both providers emitted 300,000 and one neighbors into the
> constant-false filter in q1 and q2, respectively.
> h2. How to reproduce
> Run this setup, then run q1 and q2 with the same traversal source. Consume
> the results using `toList()`.
> {code:java}
> import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
> def tg = TinkerGraph.open()
> def g = tg.traversal()
> def root = g.addV('Root').property('anchor', 1).next()
> 300000.times {
> root.addEdge('HIGH', g.addV('Leaf').property('mark', true).next())
> }
> root.addEdge('LOW', g.addV('Leaf').property('mark', true).next())
> {code}
> The root has 300,000 neighbors under `HIGH` and one neighbor under `LOW`.
> For q1, I get no rows. Median runtime on 3.8.2 is {*}125.833 ms{*}{*}.{*} On
> 3.5.1 it is {*}120.922 ms{*}.
> For q2, I get no rows. Median runtime on 3.8.2 is {*}0.094 ms{*}{*}.{*} On
> 3.5.1 it is {*}0.090 ms{*}.
>
> TinkerGraph 3.8.2 `PROFILE` excerpt. Rows with blank counts are shown as
> recorded.
> {code:java}
> Step Count Traversers Time (ms) % Dur
> q1
> VertexStep(OUT,[HIGH],vertex) 300000 300000 26.867 10.95
> TraversalFilterStep([ConstantStep(2), IsStep(lt... 218.394 89.02
> q2
> VertexStep(OUT,[LOW],vertex) 1 1 0.010 13.24
> TraversalFilterStep([ConstantStep(2), IsStep(lt... 0.013 16.76
> {code}
> The final plans retain the constant comparison after the vertex expansion.
> The expansion supplies 300,000 inputs to the filter in q1 and one in q2.
> h2. Expected performance
> Please fold a pure constant-false child filter so the traversal can skip the
> preceding read-only expansion.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)