[ 
https://issues.apache.org/jira/browse/TINKERPOP-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15302859#comment-15302859
 ] 

Daniel Kuppitz commented on TINKERPOP-1312:
-------------------------------------------

h1. Benchmark

h2. Query

{code}
graph = TinkerGraph.open()
graph.io(graphml()).readGraph('data/grateful-dead.xml')
g = graph.traversal()

g.V().filter(outE("sungBy").count().is(0)).explain()

(1..10).each { def iteration ->
  println "Iteration ${iteration}:\t" + (clock (1000) 
{g.V().filter(outE("sungBy").count().is(0)).iterate()})
}; []
{code}

h2. Results for *TINKERPOP-1312*

{noformat}
==>Traversal Explanation
===============================================================================================================================================
Original Traversal                 [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]

ConnectiveStrategy           [D]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]
IdentityRemovalStrategy      [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]
FilterRankingStrategy        [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]
RangeByIsCountStrategy       [O]   [GraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
IncidentToAdjacentStrategy   [O]   [GraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
MatchPredicateStrategy       [O]   [GraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
AdjacentToIncidentStrategy   [O]   [GraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
TinkerGraphStepStrategy      [P]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
EngineDependentStrategy      [F]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
ProfileStrategy              [F]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
StandardVerificationStrategy [V]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
ComputerVerificationStrategy [V]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]

Final Traversal                    [TinkerGraphStep([],vertex), 
TraversalFilterStep([NotStep(![VertexStep(OUT,[sungBy],edge)])])]
{noformat}

{noformat}
Iteration 1:    1.075229388
Iteration 2:    1.0842609749999998
Iteration 3:    1.137469162
Iteration 4:    1.160591912
Iteration 5:    1.0985851619999998
Iteration 6:    1.086706259
Iteration 7:    1.0837818689999998
Iteration 8:    1.0516196969999998
Iteration 9:    1.0611784519999998
Iteration 10:   1.0489953269999999
{noformat}

h2. Results for *tp31*

{noformat}
==>Traversal Explanation
===========================================================================================================================================================================
Original Traversal                 [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]

ConnectiveStrategy           [D]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), CountGlobalStep, 
IsStep(eq(0))])]
RangeByIsCountStrategy       [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
IdentityRemovalStrategy      [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
IncidentToAdjacentStrategy   [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
AdjacentToIncidentStrategy   [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
FilterRankingStrategy        [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
MatchPredicateStrategy       [O]   [GraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
TinkerGraphStepStrategy      [P]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
EngineDependentStrategy      [F]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
ProfileStrategy              [F]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
ComputerVerificationStrategy [V]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
StandardVerificationStrategy [V]   [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]

Final Traversal                    [TinkerGraphStep([],vertex), 
TraversalFilterStep([VertexStep(OUT,[sungBy],edge), RangeGlobalStep(0,1), 
CountGlobalStep, IsStep(eq(0))])]
{noformat}

{noformat}
Iteration 1:    2.6951165539999997
Iteration 2:    2.653600113
Iteration 3:    2.5956586319999997
Iteration 4:    2.5645630959999997
Iteration 5:    2.577944411
Iteration 6:    2.761260979
Iteration 7:    2.5828950479999997
Iteration 8:    2.615809266
Iteration 9:    2.707625998
Iteration 10:   2.6328726119999994
{noformat}


> .count().is(0) is not properly optimized
> ----------------------------------------
>
>                 Key: TINKERPOP-1312
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1312
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.2.0-incubating, 3.1.2-incubating
>            Reporter: Daniel Kuppitz
>            Assignee: Daniel Kuppitz
>             Fix For: 3.1.3, 3.2.1
>
>
> {{bla.count().is(0)}} gets optimized by {{RangeByIsCountStrategy}}, which 
> replaces it with {{bla.limit(1).count().is(0)}}. That's good, but we can do 
> even better by replacing it with {{__.not(bla)}}, which is a simple 
> {{.hasNext()}} instead of a {{RangeStep}} followed by a 
> {{ReducingBarrierStep}} ({{count()}}).
> Question is: should we do the replacement in {{RangeByIsCountStrategy}}? The 
> strategy will recognize the pattern, no matter if we use it for the 
> replacement or not; it's just that the strategy name is then no longer in 
> line with the the actual replacement (for this particular {{.count().is(0)}} 
> case) as it won't inject a {{RangeStep}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to