Bug 438240 - Pasting ~2000 lines of code takes ~20000 sec
Summary: Pasting ~2000 lines of code takes ~20000 sec
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2014-06-26 04:35 EDT by Michal Niewrzal CLA
Modified: 2020-05-14 10:16 EDT (History)
3 users (show)

See Also:


Attachments
Code to paste (49.30 KB, text/plain)
2014-06-26 04:35 EDT, Michal Niewrzal CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Niewrzal CLA 2014-06-26 04:35:25 EDT
Created attachment 244540 [details]
Code to paste

Kepler SR2 Build: 20140224-0627 + PDT 3.3.0.201406251911 (3.3-nightly)

Pasting ~2000 lines of code takes ~20000 sec.
To reproduce:
* Create new php file with only "<?php ?>"
* Paste code from attachment into php block

Clean workspace, no preference changed. Different code examples e.g. longer classes also are pasted very slowly.

Almost whole time is spend on code:
PhpFormatter.formatLine(IStructuredDocument document, int lineNumber) {
....
insertionStrategy.placeMatchingBlanks(document, resultBuffer, lineNumber, document.getLineOffset(lineNumber));
....
}

and 'insertionStrategy' is an instance of DefaultIndentationStrategy.
Comment 1 Michal Niewrzal CLA 2014-07-15 11:50:37 EDT
Patch proposition https://git.eclipse.org/r/#/c/29913/
Comment 2 Dawid Pakula CLA 2014-07-16 10:15:37 EDT
Merged: http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/commit/?id=c16afbf986341721816d0fcffd5efbea8c6a0090

Pasting is now much faster. Thank you Michal!

It's still working too slow, so I keep this bug open.
Comment 3 Michal Niewrzal CLA 2014-07-26 09:10:02 EDT
optimization + refactoring - https://git.eclipse.org/r/#/c/30545/
Comment 4 Dawid Pakula CLA 2014-07-30 10:53:47 EDT
Merged, http://git.eclipse.org/c/pdt/org.eclipse.pdt.git/commit/?id=3d6def3803ad3aa4fdd3d622d088fef58ab86f64

Thank you! Issue is still open.
Comment 5 Toby Thain CLA 2015-01-05 15:03:21 EST
I am also having major performance issues with copying and pasting code of any length in PDT.

Michal, what memory configuration have you given Eclipse? I find that Eclipse idles at ~ 100MB active heap, but the moment I touch copy or paste, it uses 1GB or more of transient heap (as observed in jvisualvm), and takes several seconds to respond. This is on an 8 core machine, so clearly unacceptable.

Not sure if I should open a separate bug for that problem, or if it might be related to this one.
Comment 6 Toby Thain CLA 2015-01-05 15:05:30 EST
(version Luna 4.4.1. Currently with Eclipse max heap 2GB)
Comment 7 Michal Niewrzal CLA 2015-01-06 06:38:40 EST
This issue is not closed because copy/paste is far from perfect, but related code is old and difficult to refactor. I was able to speed it up, but during my work I didn't notice so big memory consumption like in your case. Can you use attached example and check if this code will use also such amount of memory? Or maybe you can provide your code snippet? 

I think we can stay with this bug, no need to open another.
Comment 8 Toby Thain CLA 2015-01-07 23:28:13 EST
I have a possible culprit. Over the years, my DLTK h2 database had grown to this size:

[toby@macpro .plugins]$ ls -l *.h2
total 7941496
-rw-r--r--  1 toby  staff     5947808  7 Jul  2013 model.285.log.db
-rw-r--r--  1 toby  staff  2684354608  7 Jul  2013 model.data.db
-rw-r--r--  1 toby  staff  1375731760  7 Jul  2013 model.index.db


I removed it and re-launched Eclipse, which now means that Content Assist works again!

I'm pretty sure this has fixed my copy/paste issue (huge memory spikes, and long pauses).
Comment 9 Michal Niewrzal CLA 2015-01-08 05:35:24 EST
Ok, it looks that I was wrong:) Your issue was something difference than this issue. Problem described here is visible even with new and clean workspace. There are some cases where copy/paste takes more time because indentation algorithm is not optimal. Your problem is probably related to too big indexer database. 

Please create additional bug report with info you provided here. Thanks:)
Comment 10 Dawid Pakula CLA 2015-01-08 05:36:13 EST
(In reply to Toby Thain from comment #8)
> I removed it and re-launched Eclipse, which now means that Content Assist
> works again!
> 
> I'm pretty sure this has fixed my copy/paste issue (huge memory spikes, and
> long pauses).

You probably was affected by bug #456902
Comment 11 Toby Thain CLA 2015-01-08 10:22:45 EST
Yes, I probably was affected by that bug.

About the copy and paste issue - Seems I spoke too soon (it was late and I didn't test thoroughly). Looks like the slow copy and paste issue still exists, even after clearing DLTK. Also the memory spikes are still there.
Comment 12 Michal Niewrzal CLA 2015-01-08 13:49:09 EST
Can you attach any code sample you were testing?
Comment 13 Toby Thain CLA 2015-01-16 11:55:08 EST
(In reply to Michal Niewrzal from comment #12)
> Can you attach any code sample you were testing?

I have this problem with any mixed HTML/JS/PHP file.

Today the web/PDT performance problems are so severe (just maxed out 8 3GHz cores indefinitely again in a gc hang, heap set at 2gb) that I now have to move to IntelliJ. First time in more than 10 years using Eclipse.
Comment 14 Dawid Pakula CLA 2015-01-16 12:02:46 EST
If you have big (compiled/minimized) JS file in your JavaScript include path, JSDT will kill any eclipse installation :/