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

Marko A. Rodriguez commented on TINKERPOP-1349:
-----------------------------------------------

{code}
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> graph.io(gryo()).readGraph('data/grateful-dead.kryo')
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:808 edges:8049], standard]
gremlin> g.getStrategies().removeStrategies(RepeatUnrollStrategy)
==>strategies[ConnectiveStrategy, RangeByIsCountStrategy, 
IdentityRemovalStrategy, IncidentToAdjacentStrategy, 
AdjacentToIncidentStrategy, FilterRankingStrategy, MatchPredicateStrategy, 
TinkerGraphStepStrategy, ProfileStrategy, StandardVerificationStrategy]
gremlin> //
==>true
gremlin> clock(5){g.V().repeat(out()).times(3).count().next()}
==>262.0667158
gremlin> clock(5){g.V().out().out().out().count().next()}
==>909.0318090000001
gremlin> 
clock(5){g.V().out().barrier().out().barrier().out().barrier().count().next()}
==>6.0667501999999995
gremlin>
{code}

{{RepeatStep}} is a lazy barrier in that it will only barrier up to the full 
child traversal being drained as it can't "back drain" a traversal. 

Finally, with {{RepeatUnrollStrategy}} added back:

{code}
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> graph.io(gryo()).readGraph('data/grateful-dead.kryo')
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:808 edges:8049], standard]
gremlin> //
==>true
gremlin> clockWithResult(5){g.V().repeat(out()).times(3).count().next()}
==>5.263927799999999
==>14465066
gremlin>
gremlin> g.V().repeat(out()).times(3).count().explain()
==>Traversal Explanation
================================================================================================================================
Original Traversal                 [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]

ConnectiveStrategy           [D]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
RangeByIsCountStrategy       [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
IdentityRemovalStrategy      [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
IncidentToAdjacentStrategy   [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
AdjacentToIncidentStrategy   [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
FilterRankingStrategy        [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
MatchPredicateStrategy       [O]   [GraphStep(vertex,[]), 
RepeatStep([VertexStep(OUT,vertex), RepeatEndStep],until(loops(3)),emi
                                      t(false)), CountGlobalStep]
RepeatUnrollStrategy         [O]   [GraphStep(vertex,[]), 
VertexStep(OUT,vertex), NoOpBarrierStep, VertexStep(OUT,vertex), NoOpB
                                      arrierStep, VertexStep(OUT,vertex), 
NoOpBarrierStep, CountGlobalStep]
TinkerGraphStepStrategy      [P]   [TinkerGraphStep(vertex,[]), 
VertexStep(OUT,vertex), NoOpBarrierStep, VertexStep(OUT,vertex),
                                       NoOpBarrierStep, VertexStep(OUT,vertex), 
NoOpBarrierStep, CountGlobalStep]
ProfileStrategy              [F]   [TinkerGraphStep(vertex,[]), 
VertexStep(OUT,vertex), NoOpBarrierStep, VertexStep(OUT,vertex),
                                       NoOpBarrierStep, VertexStep(OUT,vertex), 
NoOpBarrierStep, CountGlobalStep]
StandardVerificationStrategy [V]   [TinkerGraphStep(vertex,[]), 
VertexStep(OUT,vertex), NoOpBarrierStep, VertexStep(OUT,vertex),
                                       NoOpBarrierStep, VertexStep(OUT,vertex), 
NoOpBarrierStep, CountGlobalStep]

Final Traversal                    [TinkerGraphStep(vertex,[]), 
VertexStep(OUT,vertex), NoOpBarrierStep, VertexStep(OUT,vertex),
                                       NoOpBarrierStep, VertexStep(OUT,vertex), 
NoOpBarrierStep, CountGlobalStep]
gremlin>
{code}

Huh, just realized a nice optimization, if the step after last step of the 
unroll is a {{BarrierStep}}, then the last {{NoOpBarrierStep}} is not needed.

> RepeatUnrollStrategy should unroll loops while maintaining equivalent 
> semantics.
> --------------------------------------------------------------------------------
>
>                 Key: TINKERPOP-1349
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1349
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.2.0-incubating
>            Reporter: Marko A. Rodriguez
>            Assignee: Marko A. Rodriguez
>             Fix For: 3.2.0-incubating
>
>
> Create {{RepeatUnrollStrategy}} that will unroll patterns such as:
> {code}
> repeat(out()).times(3)
> // ->
> out().barrier().out().barrier().out().barrier()
> {code}



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

Reply via email to