Bug 541054 - Delay when saving Java files
Summary: Delay when saving Java files
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-12 15:49 EST by David Christensen CLA
Modified: 2022-12-31 12:52 EST (History)
9 users (show)

See Also:


Attachments
Snapshot Neon (23.39 KB, application/octet-stream)
2018-11-12 15:49 EST, David Christensen CLA
no flags Details
Snapshot Juno (11.22 KB, application/octet-stream)
2018-11-12 15:52 EST, David Christensen CLA
no flags Details
Save Actions Screen (190.01 KB, image/png)
2018-12-03 12:46 EST, David Christensen CLA
no flags Details
example of imports (1.45 KB, text/plain)
2018-12-26 18:12 EST, David Christensen CLA
no flags Details
MainTestCase.java (440 bytes, application/octet-stream)
2018-12-26 18:12 EST, David Christensen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Christensen CLA 2018-11-12 15:49:52 EST
Created attachment 276554 [details]
Snapshot Neon

Migrating from Juno (4.2.2) to Neon (4.6.3), a delay saving Java files is experienced. 

Sampling was made using VisualVM where it was noted a different behavior in the Save procedure. Here the highlights observed at this moment:


   -The behavior deviation observed starts in org.eclipse.ltk.core.refactoring.TextChange.perform() where, for Neon, most time was consumed in org.eclipse.jdt.core.refactoring.CompilationUnitChange.releaseDocument()	method, while in Juno, most time was consumed in org.eclipse.ltk.core.refactoring.TextFileChange.performEdits()

   -Deeper in the call stack, Neon accounts too many calls to Parser.parse(), while Juno remains without a call.

   -Neon compiles the file as part of the save process, while in Juno the namespace "org.eclipse.jdt.internal.compiler.*" is not even present in the call tree.


   -java.io is performed in the leafs of the call three.


Delay observed is more than 10 seconds.

Please Advise
Snapshots Attached
Comment 1 Andrey Loskutov CLA 2018-11-12 15:51:35 EST
David, 4.6 is not supported anymore. Please grab 4.9 and check if you still have this regression.
Comment 2 David Christensen CLA 2018-11-12 15:52:42 EST
Created attachment 276555 [details]
Snapshot Juno
Comment 3 Jay Arthanareeswaran CLA 2018-11-13 03:23:01 EST
Went through the snapshots and just looking at the history of TextFileChange and such, I didn't find any clue.

Just have few questions:

1. Can we confirm that the experiments between two versions were on the same workspace and the action performed was same on the same file.

2. Confirm that no compiler or editor preference was changed explicitly?

3. What exactly was the change done?

4. Can you confirm that this does/doesn't happen when a non-java file is changed.

Noopur, please add if you have more questions.
Comment 4 Noopur Gupta CLA 2018-11-13 10:16:36 EST
(In reply to Jay Arthanareeswaran from comment #3)
> Noopur, please add if you have more questions.
I have a few additional queries:

1. Can you compare the checked/enabled save actions between the two releases under Preferences > Java > Editor > Save Actions to see if there is a change? Also, compare the additional save actions under "Configure".

2. Can you please try to narrow it down by unchecking the save actions one by one? This will help us to identify if a particular save action is causing the problem.

3. If possible, attach a file or sample project along with the steps which show the issue.
Comment 5 David Christensen CLA 2018-12-03 12:46:49 EST
Created attachment 276801 [details]
Save Actions Screen
Comment 6 David Christensen CLA 2018-12-03 12:50:56 EST
(In reply to Jay Arthanareeswaran from comment #3)
> Went through the snapshots and just looking at the history of TextFileChange
> and such, I didn't find any clue.
> 
> Just have few questions:
> 
> 1. Can we confirm that the experiments between two versions were on the same
> workspace and the action performed was same on the same file.

That’s correct. 

> 
> 2. Confirm that no compiler or editor preference was changed explicitly?

That’s correct. 

> 
> 3. What exactly was the change done?

Varies. But makes no difference weather a single comment was added or several dozen lines of Java Method. Lag was observed in all cases. 

> 
> 4. Can you confirm that this does/doesn't happen when a non-java file is
> changed.

That’s correct. A change on a text-file for example is instantaneous. 

> 
> Noopur, please add if you have more questions.
(In reply to Noopur Gupta from comment #4)
> (In reply to Jay Arthanareeswaran from comment #3)
> > Noopur, please add if you have more questions.
> I have a few additional queries:
> 
> 1. Can you compare the checked/enabled save actions between the two releases
> under Preferences > Java > Editor > Save Actions to see if there is a
> change? Also, compare the additional save actions under "Configure".

Both in 9.1 & 9.6 this is what the Save Actions settings look like: (see attachment 276801 [details] )

> 
> 2. Can you please try to narrow it down by unchecking the save actions one
> by one? This will help us to identify if a particular save action is causing
> the problem.

Unchecked “organize imports” : 24 seconds on save
Unchecked “format source code”: 8 seconds on save

> 
> 3. If possible, attach a file or sample project along with the steps which
> show the issue.

Sorry, It is not possible
Comment 7 David Christensen CLA 2018-12-03 12:58:27 EST
Correction. I wrote:

>'Both in 9.1 & 9.6 this is what the Save Actions settings look like'

but it is:

'Both in Juno (4.2.2) & Neon (4.6.3) this is what the Save Actions settings look like'
Comment 8 Jay Arthanareeswaran CLA 2018-12-04 09:36:03 EST
Manoj, does the window include our formatter changes by any chance?
Comment 9 Mateusz Matela CLA 2018-12-05 07:35:02 EST
(In reply to Jay Arthanareeswaran from comment #8)
> Manoj, does the window include our formatter changes by any chance?

Yes, the formatter redesign happened in Mars (4.5). But there were some serious optimizations after 4.6, so it's definitely worth checking the latest version.
Comment 10 Jay Arthanareeswaran CLA 2018-12-10 02:30:54 EST
(In reply to Mateusz Matela from comment #9)
> (In reply to Jay Arthanareeswaran from comment #8)
> > Manoj, does the window include our formatter changes by any chance?
> 
> Yes, the formatter redesign happened in Mars (4.5). But there were some
> serious optimizations after 4.6, so it's definitely worth checking the
> latest version.

By any chance can you recollect what those changes were?
Comment 11 Mateusz Matela CLA 2018-12-10 15:56:57 EST
(In reply to Jay Arthanareeswaran from comment #10)
> By any chance can you recollect what those changes were?

Not right away, I'd need to look at the commits. But it would be some obscure technical details, why do you ask?
Comment 12 Cesar Orozco CLA 2018-12-18 14:34:12 EST
Hi, is it possible to provide the list of commits that were delivered? this is blocking a customer that is not able to migrate to the latest Eclipse version, thanks!
Comment 13 Mateusz Matela CLA 2018-12-19 17:03:57 EST
(In reply to Cesar Orozco from comment #12)

I was mostly thinking about bug 493296.
Before cherry-picking, you can easily check if given Eclipse version is really faster - no need to migrate anything, just run with an empty workspace, open the java file that causes problems and press Ctrl+Shift+F.
Comment 14 Manoj N Palat CLA 2018-12-20 23:17:28 EST
(In reply to Cesar Orozco from comment #12)
> Hi, is it possible to provide the list of commits that were delivered? this
> is blocking a customer that is not able to migrate to the latest Eclipse
> version, thanks!

latest version of Eclipse is 4.10 [or you can try 4.9]. 
Did you try on any of the above?
Comment 15 Manoj N Palat CLA 2018-12-21 00:22:13 EST
(In reply to David Christensen from comment #6)
> > 
> > 2. Can you please try to narrow it down by unchecking the save actions one
> > by one? This will help us to identify if a particular save action is causing
> > the problem.
> 
> Unchecked “organize imports” : 24 seconds on save
> Unchecked “format source code”: 8 seconds on save
> 
> > 
> > 3. If possible, attach a file or sample project along with the steps which
> > show the issue.
> 
> Sorry, It is not possible

Since organize imports is also found to be a culprit, Is it possible to copy just the part which contains the imports including comments if any so that to "fabricate" a test case/project that could reproduce the issue?
You can obfuscate the client-specific import names, but leave the standard imports in-tact. Let us know whether that is possible.
Comment 16 Dani Megert CLA 2018-12-21 05:17:13 EST
Please get confirmation from the customer whether disabling 'Format source code' on Save fixes the problem for them.
Comment 17 Cesar Orozco CLA 2018-12-21 12:40:41 EST
Yes, when the "Format source code" option is disabled the performance is improved
Comment 18 Dani Megert CLA 2018-12-21 16:21:08 EST
(In reply to Cesar Orozco from comment #17)
> Yes, when the "Format source code" option is disabled the performance is
> improved

This does not answer my question:
"
Please get confirmation from the customer whether disabling 'Format source code' on Save fixes the problem for them.
"

So, please answer with only YES or NO.
Comment 19 David Christensen CLA 2018-12-26 11:55:46 EST
(In reply to Dani Megert from comment #16)
> Please get confirmation from the customer whether disabling 'Format source
> code' on Save fixes the problem for them.

"Yes. Disabling formatting source code and organize imports improves the time to save a file. 
However, we cannot leave that option turned off as it is quite useful for us during development."   -Customer
Comment 20 David Christensen CLA 2018-12-26 18:11:25 EST
(In reply to Manoj Palat from comment #15)

> Since organize imports is also found to be a culprit, Is it possible to copy
> just the part which contains the imports including comments if any so that
> to "fabricate" a test case/project that could reproduce the issue?
> You can obfuscate the client-specific import names, but leave the standard
> imports in-tact. Let us know whether that is possible.


Here is the requested data to troubleshoot the formatter perf:

It is an example of imports from one of their source files. They've managed to obfuscate the organizational specific imports.

Also provided a test class to use the imports against. Both files are attached.
Comment 21 David Christensen CLA 2018-12-26 18:12:05 EST
Created attachment 277003 [details]
example of imports
Comment 22 David Christensen CLA 2018-12-26 18:12:45 EST
Created attachment 277004 [details]
MainTestCase.java
Comment 23 Eclipse Genie CLA 2020-12-17 13:26:22 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 24 Eclipse Genie CLA 2022-12-31 12:52:46 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.