You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Paolo Di Tommaso <pa...@gmail.com> on 2020/02/01 14:22:59 UTC
Re: RE: Groovy 3 very slow stub generation
What is the maximum number of lines of code that a source file should
contain to prevent perf degradation?
On Fri, Jan 31, 2020 at 8:16 PM Daniel.Sun <su...@apache.org> wrote:
> I find antlr4 parser parses *big* files much slower than antlr2 parser,
> unfortunately nextflow project contains quite a few big files...
>
> One of reasons is antlr2 uses LL(k) and antlr4 uses ALL. As we know, LL(k)
> will look ahead *limited* count of tokens, but ALL will look ahead
> *unlimited* count of tokens...
>
> I am trying to tweak rules to reduce looking ahead, but we have to admit
> that Groovy's grammar contains ambiguities, one of main reasons is
> parenthesis-less... As a user, I like it, but as a developer, I hate it...
>
> Cheers,
> Daniel.Sun
>
>
>
> -----
> Apache Groovy committer & PMC member
> Blog: http://blog.sunlan.me
> Twitter: @daniel_sun
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
>
Re: RE: Groovy 3 very slow stub generation
Posted by "Daniel.Sun" <su...@apache.org>.
I tried to remove the following error alternative of `rparen`, parsing all
groovy source files under nextflow module[1] with 4.0.0-SNAPSHOT takes only
"14s".
https://github.com/apache/groovy/blob/GROOVY_3_0_0_RC_3/src/antlr/GroovyParser.g4#L1232-L1234
*4.0.0-SNAPSHOT antlr4 parser: 14s*
result-4.log <http://groovy.329449.n5.nabble.com/file/t340716/result-4.log>
profile-4.zip
<http://groovy.329449.n5.nabble.com/file/t340716/profile-4.zip>
*4.0.0-SNAPSHOT antlr2 parser: 6s*
result-2.log <http://groovy.329449.n5.nabble.com/file/t340716/result-2.log>
profile-2.svg
<http://groovy.329449.n5.nabble.com/file/t340716/profile-2.svg>
Cheers,
Daniel.Sun
[1] https://github.com/nextflow-io/nextflow/tree/master/modules/nextflow
-----
Apache Groovy committer & PMC member
Blog: http://blog.sunlan.me
Twitter: @daniel_sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Re: RE: Groovy 3 very slow stub generation
Posted by "Daniel.Sun" <su...@apache.org>.
The current result of parsing all groovy source files under nextflow
module[1] with 3.0.0-rc-3 and the distribution built from master.
After some rules tweaked, about 39.8% time is saved util now(Formula: (103s
- 62s) / 103s = 39.8%).
*3.0.0-rc-3 costs 103s*
result-3.log <http://groovy.329449.n5.nabble.com/file/t340716/result-3.log>
profile-3.svg
<http://groovy.329449.n5.nabble.com/file/t340716/profile-3.svg>
*4.0.0-SNAPSHOT costs 62s*
result-4.log <http://groovy.329449.n5.nabble.com/file/t340716/result-4.log>
profile-4.svg
<http://groovy.329449.n5.nabble.com/file/t340716/profile-4.svg>
Sam and I are still trying to tune the performance of the antlr4 parser.
Thanks a lot for your help, Sam :-)
Cheers,
Daniel.Sun
[1] https://github.com/nextflow-io/nextflow/tree/master/modules/nextflow
-----
Apache Groovy committer & PMC member
Blog: http://blog.sunlan.me
Twitter: @daniel_sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Re: RE: Groovy 3 very slow stub generation
Posted by "Daniel.Sun" <su...@apache.org>.
Hi Paolo,
As you can see, Sam and I have been trying to improve the performance
of the antlr4 parser recently. I believe the performance could be improved a
lot, but antlr4 parser will be slower than antlr2 parser as a whole finally
due to the following reasons(including but not limited to):
1) Groovy 3's grammar is more complicated than Groovy 2's
2) Different algorithms used by antlr2 and antlr4, as I said in the previous
email
> What is the maximum number of lines of code that a source file should
> contain to prevent perf degradation?
It needs some tests. Let's wait for the tuning result ;-)
Cheers,
Daniel.Sun
-----
Apache Groovy committer & PMC member
Blog: http://blog.sunlan.me
Twitter: @daniel_sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html