[
https://issues.apache.org/jira/browse/TINKERPOP-3314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146179#comment-18146179
]
Stephen Mallette commented on TINKERPOP-3314:
---------------------------------------------
Thanks for offering this issue, but we likely won't make any changes to match()
at this point. It is being completely reworked to support GQL in TinkerPop 4.0
and the form you're referring to is essentially deprecated:
https://tinkerpop.apache.org/docs/4.0.0-beta.3/upgrade/#_declarative_pattern_matching
> Bounded reachability in match() expands from the high-degree endpoint
> ---------------------------------------------------------------------
>
> Key: TINKERPOP-3314
> URL: https://issues.apache.org/jira/browse/TINKERPOP-3314
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.5.1, 3.8.2
> Reporter: Yuxuan Qing
> Priority: Major
> Labels: performance
>
> h1. Bounded reachability in match() expands from the high-degree endpoint
> h2. Describe the situation
> Hi, Apache TinkerPop developers,
> Please consider these two queries:
> {code:java}
> // q1
> g.V(u.id()).match(
> __.as('u').out('Bind').as('t'),
> __.as('u').where(__.repeat(__.both('Walk')).emit().times(2).as('t'))
> ).select('u').constant(1){code}
> {code:java}
> // q2
> g.V(u.id()).match(
> __.as('u').out('Bind').as('t'),
> __.as('t').where(__.repeat(__.both('Walk')).emit().times(2).as('u'))
> ).select('u').constant(1)
> {code}
> The first pattern binds the same two vertices in both queries. The second
> checks whether a walk of one or two `Walk` edges connects them. Each hop uses
> `both()`, so the existence condition holds in either direction. Both queries
> return one row.
> 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 leaves at the high-degree
> endpoint 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
> *0.807 ms / 2,042.578 ms* on JanusGraph and *0.670 ms / 1,193.371 ms* on
> HugeGraph. Both providers returned one row in either direction. Inside
> `repeat()`, the JanusGraph vertex expansion produced 3 and 600,003
> traversers, and the HugeGraph expansion produced 2 and 600,003.
> 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 u = g.addV('U').next()
> def m = g.addV('Middle').next()
> def t = g.addV('T').next()
> u.addEdge('Bind', t)
> u.addEdge('Walk', m)
> m.addEdge('Walk', t)
> 300000.times
> { t.addEdge('Walk', g.addV('Leaf').next()) }
> {code}
> Two `Walk` edges connect the endpoints through `m`. Another 300,000 leaves
> are attached to `t`. A walk that takes the first hop from `t` to one of those
> leaves cannot reach `u` in its remaining hop.
> For q1, I get one row, `1`. Median runtime on 3.8.2 is {*}0.328 ms{*}{*}.{*}
> On 3.5.1 it is {*}0.329 ms{*}.
> For q2, I get one row, `1`. Median runtime on 3.8.2 is {*}371.455
> ms{*}{*}.{*} On 3.5.1 it is {*}296.923 ms{*}.
>
> TinkerGraph 3.8.2 `PROFILE` excerpt. Rows with blank counts are shown as
> recorded.
> {code:java}
> Step Count Traversers Time (ms) % Dur
> q1
> RepeatStep([VertexStep(BOTH,[Walk],vertex),... 2 2 0.051
> VertexStep(BOTH,[Walk],vertex) 2 2 0.002
> q2
> RepeatStep([VertexStep(BOTH,[Walk],vertex),... 600003 600003 513.606
> VertexStep(BOTH,[Walk],vertex) 600003 600003 172.708
> {code}
> Starting at `u`, the walk reaches `t` after two expansions. Starting at `t`,
> the repeat also visits the leaves and walks back from them. The endpoint
> comparison sees the traversers after they leave `repeat()`.
> h2. Expected performance
> Please consider choosing the lower-expansion endpoint for a read-only bounded
> `both()` existence check between already bound vertices.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)