Type inference exponential compilation performance

Vicente-Arturo Romero-Zaldivar vicente.romero at oracle.com
Thu Sep 25 18:02:17 UTC 2014


Hi Ella,

Thanks for your mail. We are aware of the issue and we are actively 
working on it.

Thanks,
Vicente

On 09/25/2014 07:56 AM, ella nekipelova wrote:
> Hello, dear team,
>
> I have a question concerning the javac performance in resolving type 
> inference. I found that if there are more than three nested 
> invocations with type inference, compilation might take several minutes.
> Consider this example:
>
> class Test<T> {
>
>     Test obj;
>
>     Test(Test<T> other) { this.obj = other.obj; }
>
>     static <U> Test<U> m(Test<U> src) { return new Test<U>(src); }
>
>     public static void main(String argv[]) {
>
>         Test<String> c14 = m(new Test<>(m(new Test<>(m(new 
> Test<>(m(new Test<>(m(new Test<>(m(new Test<>(m(new Test<>(m(new 
> Test<>(m(new Test<>(m(new Test<>(m(new Test<>(m(new Test<>(m(new 
> Test<>(m(new Test<>())))))))))))))))))))))))))));
>
>     }
>
> }
>
>  I noticed that there is exponential growth, because for for 8 
> invocations it takes 20 sec, for 9 - 50 sec, for 10 invocations 
> compilation succeeds in about 3 minutes, but for 14 invocations, as in 
> the example, javac just hangs.
>
> It's unlikely that any human developer will ever write such code, but 
> there are different kinds of code generators, and we can't be sure 
> about their implementation.
>
> My question is if this behavior is admissible? Are you going to do 
> anything to improve this situation?
>
> Thank you,
> Ella
>
>



More information about the compiler-dev mailing list