Bug 541387 - Slow compilation in project with many parameterized type arguments
Summary: Slow compilation in project with many parameterized type arguments
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.11 M1   Edit
Assignee: Motonori IWAMURO CLA
QA Contact: Till Brychcy CLA
URL:
Whiteboard:
Keywords: helpwanted, performance
Depends on:
Blocks:
 
Reported: 2018-11-21 01:45 EST by Motonori IWAMURO CLA
Modified: 2019-01-08 03:56 EST (History)
4 users (show)

See Also:


Attachments
patch for master branch of eclipse.jdt.core (1.11 KB, application/octet-stream)
2018-11-21 01:45 EST, Motonori IWAMURO CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Motonori IWAMURO CLA 2018-11-21 01:45:54 EST
Created attachment 276638 [details]
patch for master branch of eclipse.jdt.core

Compilation is too slow in a project with many parameterized type arguments.
I fixed it.

"ParameterizedTypeBinding" has many instance variables, but "hashCode()" uses  "ReferenceBinding#hashCode()".

This is because "hashCode()" is not reimplemented in "ParameterizedTypeBinding".

Therefore, there may be many different "ParameterizedTypeBinding" instances that return the same hash code.

As a result, in "TypeSystem", a significant performance degradation occurs due to collision of hash codes in "hashedParameterizedTypes" using "PTBKey" as key.

"PTBKey" performs comparison of each element of "TypeBinding[] arguments" with "==" in equals, so if different "ParameterizedTypeBinding" instances exist, different hash codes should be returned.
Comment 1 Andrey Loskutov CLA 2018-11-21 02:11:00 EST
(In reply to iwa from comment #0)
> Created attachment 276638 [details]
> patch for master branch of eclipse.jdt.core
> 
> Compilation is too slow in a project with many parameterized type arguments.
> I fixed it.

Cool. Could you please push the change as a Gerrit patch? https://wiki.eclipse.org/JDT_Core_Committer_FAQ
Comment 2 Eclipse Genie CLA 2018-11-21 04:52:49 EST
New Gerrit change created: https://git.eclipse.org/r/132817
Comment 3 Andrey Loskutov CLA 2018-11-21 05:09:10 EST
Till, the patch looks good, so RC1 as target. WDYT? Can we merge it in M3 already?
Comment 4 Till Brychcy CLA 2018-11-21 06:47:49 EST
See gerrit.
Comment 5 Stephan Herrmann CLA 2018-11-27 13:08:19 EST
@Till, is RC1 still a realistic target? Would already need +1 from a project lead...

I see an updated change in gerrit, but unfortunately no test case. Hence my question: how to gain confidence that the change is improving anything?
Comment 6 Till Brychcy CLA 2018-11-27 14:46:01 EST
(In reply to Stephan Herrmann from comment #5)
> @Till, is RC1 still a realistic target? Would already need +1 from a project
> lead...
> 
> I see an updated change in gerrit, but unfortunately no test case. Hence my
> question: how to gain confidence that the change is improving anything?

I currently don't have capacity to recheck this with appropriate diligence, so lets move it to 4.11.

As this is only a performance improvement, I wouldn't expect a new test case, but it would be nice if somebody knows an open source project where it makes a noticeable difference.
Comment 7 Andrey Loskutov CLA 2018-11-28 05:13:11 EST
Motonori, can you please provide some performance data, or better an example of open source code which would show some difference in the compilation performance?
Comment 8 Motonori IWAMURO CLA 2018-12-01 21:09:57 EST
I do not know the OSS project where this problem occurs.

Below is the information on our project.

- Environment
  - Eclipse: Spring Tool Suite 4.0.0.RELEASE (JDT: 3.15.0.v20180905-0317)
    - Plug-ins: Lombok 1.18.0, Checkstyle 8.12.0.201808161509
    - Annotation processor: doma 2.19.2
  - OS: 16.04.5 LTS (x86_64) / gtk 3.18.9
  - Java version: 1.8.0_191
  - CPU: 2 cores of the following spec (cloud VM)
    - model name      : Intel Xeon E312xx (Sandy Bridge)
    - cpu MHz         : 1995.394
    - cache size      : 4096 KB
  - Memory: 15GB

- Project size
  - Java files: 14,106
  - Other resource files: 21,003

- Performance information (duration from start of "Clean all project"
  until "No operations to display at this time." is displayed)
  - Original: about 50 min.
  - Patched (change/132817/2): about 22 min.
Comment 9 Motonori IWAMURO CLA 2018-12-01 21:22:19 EST
OS: 16.04.5 LTS => Ubuntu 16.04.5 LTS
Comment 11 Till Brychcy CLA 2018-12-23 14:36:46 EST
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/132817 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=41ed24e39f591a7b5807470ed92379a45d609f3a

Released for 4.11M1

Thanks, Motonori!
Comment 12 Manoj N Palat CLA 2019-01-08 03:56:50 EST
Verified for 4.11 M1  with Build id: I20190107-0600
(Verified as mentioned in comment 8)