groovysh and long input

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

groovysh and long input

Stephen Mallette
Hello, 

I happened to be testing some issues related to this pull request I submitted the other day:


In testing between groovy 2.5.x and 3.x I've noticed a considerable performance difference when pasting long multi-lined scripts. 2.5.x is quite quick to accept the input whereas 3.x seems to slow more and more as additional lines are consumed. While I did more complex tests trying to get to the bottom of the problem, it's fairly easy to recreate with a simple addition script:

1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +  
1 + 10 +  
... repeated a bunch of times and then ended with
1

copy that out of your text editor and just paste it into both versions of groovsh and see the difference. I've found 500 lines demonstrates it well but you could probably get away with less and still see the difference of evaluation at play. 

I tried to do some profiling to try to isolate the problem myself, but things got a little too deep into antlr4 for me and I got lost. Does anyone have any ideas as to what might be different for 3.x?


Reply | Threaded
Open this post in threaded view
|

RE: groovysh and long input

Winnebeck, Jason

I’d be curious to know the conclusion on this, it sounds like a scalability issue in the parser. I’ve seen similar behavior in our application, but I’ve not had time to isolate it further. We’re still stuck on Groovy 2 because we’re unable to compile on Groovy 3 because I haven’t been able to give the parser enough RAM or CPU time. A few hundred MB is OK to compile in Groovy 2 but even with multi-GB heap sizes result in out of memory exception in Groovy 3 and minutes long compile times.

 

Jason Winnebeck

 

 

Sensitivity: Internal

From: Stephen Mallette <[hidden email]>
Sent: Friday, October 16, 2020 2:58 PM
To: [hidden email]
Subject: groovysh and long input

 

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

Hello, 

 

I happened to be testing some issues related to this pull request I submitted the other day:

 

 

In testing between groovy 2.5.x and 3.x I've noticed a considerable performance difference when pasting long multi-lined scripts. 2.5.x is quite quick to accept the input whereas 3.x seems to slow more and more as additional lines are consumed. While I did more complex tests trying to get to the bottom of the problem, it's fairly easy to recreate with a simple addition script:

 

1 + 10 +

1 + 10 + 

1 + 10 + 

1 + 10 +  

1 + 10 +  

... repeated a bunch of times and then ended with

1

 

copy that out of your text editor and just paste it into both versions of groovsh and see the difference. I've found 500 lines demonstrates it well but you could probably get away with less and still see the difference of evaluation at play. 

 

I tried to do some profiling to try to isolate the problem myself, but things got a little too deep into antlr4 for me and I got lost. Does anyone have any ideas as to what might be different for 3.x?

 

 

Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

Daniel.Sun
In reply to this post by Stephen Mallette

Please try 3.0.6+, we have tuned the performance a lot.

Cheers,
Daniel Sun
On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:

> Hello,
>
> I happened to be testing some issues related to this pull request I
> submitted the other day:
>
> https://github.com/apache/groovy/pull/1405
>
> In testing between groovy 2.5.x and 3.x I've noticed a considerable
> performance difference when pasting long multi-lined scripts. 2.5.x is
> quite quick to accept the input whereas 3.x seems to slow more and more as
> additional lines are consumed. While I did more complex tests trying to get
> to the bottom of the problem, it's fairly easy to recreate with a simple
> addition script:
>
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> ... repeated a bunch of times and then ended with
> 1
>
> copy that out of your text editor and just paste it into both versions of
> groovsh and see the difference. I've found 500 lines demonstrates it well
> but you could probably get away with less and still see the difference of
> evaluation at play.
>
> I tried to do some profiling to try to isolate the problem myself, but
> things got a little too deep into antlr4 for me and I got lost. Does anyone
> have any ideas as to what might be different for 3.x?
>
Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

Stephen Mallette
I was using 3.0.6 actually (I'd downloaded it to make sure that it wasn't our extension of groovysh that was causing some difference). But to be sure, I just retested it on 3.0.6 and 2.5.13. I built a 500 line script of "addition". For 2.5.13 I got:

groovy:000> start = System.currentTimeMillis()
===> 1603105239050
groovy:000> 1 + 10 +
groovy:001> 1 + 10 +
groovy:002> 1 + 10 +
groovy:003> 1 + 10 +
groovy:004> 1 + 10 +
groovy:005> 1 + 10 +
groovy:006> 1 + 10 +
...
groovy:495> 1 + 10 +
groovy:496> 1 + 10 +
groovy:497> 1 + 10
===> 5478
groovy:000> System.currentTimeMillis() - start
===> 1193

and on 3.0.6 I got:

groovy:000> start = System.currentTimeMillis()
===> 1603105244825
groovy:000> 1 + 10 +
groovy:001> 1 + 10 +
groovy:002> 1 + 10 +
groovy:003> 1 + 10 +
groovy:004> 1 + 10 +
groovy:005> 1 + 10 +
groovy:006> 1 + 10 +
...
groovy:495> 1 + 10 +
groovy:496> 1 + 10 +
groovy:497> 1 + 10
===> 5478
groovy:000> System.currentTimeMillis() - start
===> 31876







On Mon, Oct 19, 2020 at 6:40 AM Daniel Sun <[hidden email]> wrote:

Please try 3.0.6+, we have tuned the performance a lot.

Cheers,
Daniel Sun
On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:
> Hello,
>
> I happened to be testing some issues related to this pull request I
> submitted the other day:
>
> https://github.com/apache/groovy/pull/1405
>
> In testing between groovy 2.5.x and 3.x I've noticed a considerable
> performance difference when pasting long multi-lined scripts. 2.5.x is
> quite quick to accept the input whereas 3.x seems to slow more and more as
> additional lines are consumed. While I did more complex tests trying to get
> to the bottom of the problem, it's fairly easy to recreate with a simple
> addition script:
>
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> 1 + 10 +
> ... repeated a bunch of times and then ended with
> 1
>
> copy that out of your text editor and just paste it into both versions of
> groovsh and see the difference. I've found 500 lines demonstrates it well
> but you could probably get away with less and still see the difference of
> evaluation at play.
>
> I tried to do some profiling to try to isolate the problem myself, but
> things got a little too deep into antlr4 for me and I got lost. Does anyone
> have any ideas as to what might be different for 3.x?
>
Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

Daniel.Sun

I think the performance issue could be related to groovysh but not the new parser.
Here the result of running my script[1], as you could see, it works well:
```
D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 261ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 240ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 275ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 249ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 259ms

D:\_TEMP\yyy>groovy -v
Groovy Version: 3.0.6 JVM: 15 Vendor: Azul Systems, Inc. OS: Windows 10
```

Cheers,
Daniel Sun

[1] my script:
```
def begin = System.currentTimeMillis()

// 500 lines of "1 + 10 +"
def result = new GroovyShell().evaluate '''
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10 +  
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 +  
1 + 10
'''

def end = System.currentTimeMillis()

println "result: $result; elapsed time: ${end - begin}ms"

```


On 2020/10/19 11:06:25, Stephen Mallette <[hidden email]> wrote:

> I was using 3.0.6 actually (I'd downloaded it to make sure that it wasn't
> our extension of groovysh that was causing some difference). But to be
> sure, I just retested it on 3.0.6 and 2.5.13. I built a 500 line script of
> "addition". For 2.5.13 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105239050
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 1193
>
> and on 3.0.6 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105244825
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 31876
>
>
>
>
>
>
>
> On Mon, Oct 19, 2020 at 6:40 AM Daniel Sun <[hidden email]> wrote:
>
> >
> > Please try 3.0.6+, we have tuned the performance a lot.
> >
> > Cheers,
> > Daniel Sun
> > On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:
> > > Hello,
> > >
> > > I happened to be testing some issues related to this pull request I
> > > submitted the other day:
> > >
> > > https://github.com/apache/groovy/pull/1405
> > >
> > > In testing between groovy 2.5.x and 3.x I've noticed a considerable
> > > performance difference when pasting long multi-lined scripts. 2.5.x is
> > > quite quick to accept the input whereas 3.x seems to slow more and more
> > as
> > > additional lines are consumed. While I did more complex tests trying to
> > get
> > > to the bottom of the problem, it's fairly easy to recreate with a simple
> > > addition script:
> > >
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > ... repeated a bunch of times and then ended with
> > > 1
> > >
> > > copy that out of your text editor and just paste it into both versions of
> > > groovsh and see the difference. I've found 500 lines demonstrates it well
> > > but you could probably get away with less and still see the difference of
> > > evaluation at play.
> > >
> > > I tried to do some profiling to try to isolate the problem myself, but
> > > things got a little too deep into antlr4 for me and I got lost. Does
> > anyone
> > > have any ideas as to what might be different for 3.x?
> > >
> >
>
Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

Stephen Mallette
Would it help if I created a ticket in JIRA and uploaded the JFRs I had? Perhaps someone could take a look and either see an easy fix or point me in the right direction toward one?

On Mon, Oct 19, 2020 at 7:43 PM Daniel Sun <[hidden email]> wrote:

I think the performance issue could be related to groovysh but not the new parser.
Here the result of running my script[1], as you could see, it works well:
```
D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 261ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 240ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 275ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 249ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 259ms

D:\_TEMP\yyy>groovy -v
Groovy Version: 3.0.6 JVM: 15 Vendor: Azul Systems, Inc. OS: Windows 10
```

Cheers,
Daniel Sun

[1] my script:
```
def begin = System.currentTimeMillis()

// 500 lines of "1 + 10 +"
def result = new GroovyShell().evaluate '''
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10
'''

def end = System.currentTimeMillis()

println "result: $result; elapsed time: ${end - begin}ms"

```


On 2020/10/19 11:06:25, Stephen Mallette <[hidden email]> wrote:
> I was using 3.0.6 actually (I'd downloaded it to make sure that it wasn't
> our extension of groovysh that was causing some difference). But to be
> sure, I just retested it on 3.0.6 and 2.5.13. I built a 500 line script of
> "addition". For 2.5.13 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105239050
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 1193
>
> and on 3.0.6 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105244825
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 31876
>
>
>
>
>
>
>
> On Mon, Oct 19, 2020 at 6:40 AM Daniel Sun <[hidden email]> wrote:
>
> >
> > Please try 3.0.6+, we have tuned the performance a lot.
> >
> > Cheers,
> > Daniel Sun
> > On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:
> > > Hello,
> > >
> > > I happened to be testing some issues related to this pull request I
> > > submitted the other day:
> > >
> > > https://github.com/apache/groovy/pull/1405
> > >
> > > In testing between groovy 2.5.x and 3.x I've noticed a considerable
> > > performance difference when pasting long multi-lined scripts. 2.5.x is
> > > quite quick to accept the input whereas 3.x seems to slow more and more
> > as
> > > additional lines are consumed. While I did more complex tests trying to
> > get
> > > to the bottom of the problem, it's fairly easy to recreate with a simple
> > > addition script:
> > >
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > ... repeated a bunch of times and then ended with
> > > 1
> > >
> > > copy that out of your text editor and just paste it into both versions of
> > > groovsh and see the difference. I've found 500 lines demonstrates it well
> > > but you could probably get away with less and still see the difference of
> > > evaluation at play.
> > >
> > > I tried to do some profiling to try to isolate the problem myself, but
> > > things got a little too deep into antlr4 for me and I got lost. Does
> > anyone
> > > have any ideas as to what might be different for 3.x?
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

paulk_asert
Administrator
Hi Stephen, sounds like it can't hurt.

Cheers, Paul.


On Tue, Oct 20, 2020 at 8:23 PM Stephen Mallette <[hidden email]> wrote:
Would it help if I created a ticket in JIRA and uploaded the JFRs I had? Perhaps someone could take a look and either see an easy fix or point me in the right direction toward one?

On Mon, Oct 19, 2020 at 7:43 PM Daniel Sun <[hidden email]> wrote:

I think the performance issue could be related to groovysh but not the new parser.
Here the result of running my script[1], as you could see, it works well:
```
D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 261ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 240ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 275ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 249ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 259ms

D:\_TEMP\yyy>groovy -v
Groovy Version: 3.0.6 JVM: 15 Vendor: Azul Systems, Inc. OS: Windows 10
```

Cheers,
Daniel Sun

[1] my script:
```
def begin = System.currentTimeMillis()

// 500 lines of "1 + 10 +"
def result = new GroovyShell().evaluate '''
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10
'''

def end = System.currentTimeMillis()

println "result: $result; elapsed time: ${end - begin}ms"

```


On 2020/10/19 11:06:25, Stephen Mallette <[hidden email]> wrote:
> I was using 3.0.6 actually (I'd downloaded it to make sure that it wasn't
> our extension of groovysh that was causing some difference). But to be
> sure, I just retested it on 3.0.6 and 2.5.13. I built a 500 line script of
> "addition". For 2.5.13 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105239050
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 1193
>
> and on 3.0.6 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105244825
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 31876
>
>
>
>
>
>
>
> On Mon, Oct 19, 2020 at 6:40 AM Daniel Sun <[hidden email]> wrote:
>
> >
> > Please try 3.0.6+, we have tuned the performance a lot.
> >
> > Cheers,
> > Daniel Sun
> > On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:
> > > Hello,
> > >
> > > I happened to be testing some issues related to this pull request I
> > > submitted the other day:
> > >
> > > https://github.com/apache/groovy/pull/1405
> > >
> > > In testing between groovy 2.5.x and 3.x I've noticed a considerable
> > > performance difference when pasting long multi-lined scripts. 2.5.x is
> > > quite quick to accept the input whereas 3.x seems to slow more and more
> > as
> > > additional lines are consumed. While I did more complex tests trying to
> > get
> > > to the bottom of the problem, it's fairly easy to recreate with a simple
> > > addition script:
> > >
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > ... repeated a bunch of times and then ended with
> > > 1
> > >
> > > copy that out of your text editor and just paste it into both versions of
> > > groovsh and see the difference. I've found 500 lines demonstrates it well
> > > but you could probably get away with less and still see the difference of
> > > evaluation at play.
> > >
> > > I tried to do some profiling to try to isolate the problem myself, but
> > > things got a little too deep into antlr4 for me and I got lost. Does
> > anyone
> > > have any ideas as to what might be different for 3.x?
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: groovysh and long input

Stephen Mallette

On Tue, Oct 20, 2020 at 6:40 AM Paul King <[hidden email]> wrote:
Hi Stephen, sounds like it can't hurt.

Cheers, Paul.


On Tue, Oct 20, 2020 at 8:23 PM Stephen Mallette <[hidden email]> wrote:
Would it help if I created a ticket in JIRA and uploaded the JFRs I had? Perhaps someone could take a look and either see an easy fix or point me in the right direction toward one?

On Mon, Oct 19, 2020 at 7:43 PM Daniel Sun <[hidden email]> wrote:

I think the performance issue could be related to groovysh but not the new parser.
Here the result of running my script[1], as you could see, it works well:
```
D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 261ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 240ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 275ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 249ms

D:\_TEMP\yyy>groovy Test.groovy
result: 5500; elapsed time: 259ms

D:\_TEMP\yyy>groovy -v
Groovy Version: 3.0.6 JVM: 15 Vendor: Azul Systems, Inc. OS: Windows 10
```

Cheers,
Daniel Sun

[1] my script:
```
def begin = System.currentTimeMillis()

// 500 lines of "1 + 10 +"
def result = new GroovyShell().evaluate '''
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10 + 
1 + 10 +
1 + 10 +
1 + 10 +
1 + 10 + 
1 + 10
'''

def end = System.currentTimeMillis()

println "result: $result; elapsed time: ${end - begin}ms"

```


On 2020/10/19 11:06:25, Stephen Mallette <[hidden email]> wrote:
> I was using 3.0.6 actually (I'd downloaded it to make sure that it wasn't
> our extension of groovysh that was causing some difference). But to be
> sure, I just retested it on 3.0.6 and 2.5.13. I built a 500 line script of
> "addition". For 2.5.13 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105239050
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 1193
>
> and on 3.0.6 I got:
>
> groovy:000> start = System.currentTimeMillis()
> ===> 1603105244825
> groovy:000> 1 + 10 +
> groovy:001> 1 + 10 +
> groovy:002> 1 + 10 +
> groovy:003> 1 + 10 +
> groovy:004> 1 + 10 +
> groovy:005> 1 + 10 +
> groovy:006> 1 + 10 +
> ...
> groovy:495> 1 + 10 +
> groovy:496> 1 + 10 +
> groovy:497> 1 + 10
> ===> 5478
> groovy:000> System.currentTimeMillis() - start
> ===> 31876
>
>
>
>
>
>
>
> On Mon, Oct 19, 2020 at 6:40 AM Daniel Sun <[hidden email]> wrote:
>
> >
> > Please try 3.0.6+, we have tuned the performance a lot.
> >
> > Cheers,
> > Daniel Sun
> > On 2020/10/16 18:58:28, Stephen Mallette <[hidden email]> wrote:
> > > Hello,
> > >
> > > I happened to be testing some issues related to this pull request I
> > > submitted the other day:
> > >
> > > https://github.com/apache/groovy/pull/1405
> > >
> > > In testing between groovy 2.5.x and 3.x I've noticed a considerable
> > > performance difference when pasting long multi-lined scripts. 2.5.x is
> > > quite quick to accept the input whereas 3.x seems to slow more and more
> > as
> > > additional lines are consumed. While I did more complex tests trying to
> > get
> > > to the bottom of the problem, it's fairly easy to recreate with a simple
> > > addition script:
> > >
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > 1 + 10 +
> > > ... repeated a bunch of times and then ended with
> > > 1
> > >
> > > copy that out of your text editor and just paste it into both versions of
> > > groovsh and see the difference. I've found 500 lines demonstrates it well
> > > but you could probably get away with less and still see the difference of
> > > evaluation at play.
> > >
> > > I tried to do some profiling to try to isolate the problem myself, but
> > > things got a little too deep into antlr4 for me and I got lost. Does
> > anyone
> > > have any ideas as to what might be different for 3.x?
> > >
> >
>