Bug 553201 - out of memory [mac]
Summary: out of memory [mac]
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 5.5   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-19 01:35 EST by Patrik Suzzi CLA
Modified: 2019-11-28 03:36 EST (History)
4 users (show)

See Also:


Attachments
Eclipse not responding, plus wrong CPU usage reporting (453.40 KB, image/png)
2019-11-19 01:35 EST, Patrik Suzzi CLA
no flags Details
Error log for the session (75.28 KB, text/plain)
2019-11-19 01:37 EST, Patrik Suzzi CLA
no flags Details
State of the UI and List of errors - just before eclipse shutdown (137.83 KB, image/png)
2019-11-19 01:40 EST, Patrik Suzzi CLA
no flags Details
Thread dump (24.66 KB, text/plain)
2019-11-19 21:05 EST, Patrik Suzzi CLA
no flags Details
Heap histogram. (656.22 KB, text/plain)
2019-11-19 21:08 EST, Patrik Suzzi CLA
no flags Details
Weird error message: An internal error occurred while showing an internal error. (45.67 KB, image/png)
2019-11-19 21:12 EST, Patrik Suzzi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrik Suzzi CLA 2019-11-19 01:35:47 EST
Created attachment 280687 [details]
Eclipse not responding, plus wrong CPU usage reporting

Out of memory error and CPU usage at 683% while right-clicking on a git repository for getting information.

Notes:
- This kind of freeze happens frequently. As a result, Eclipse's usability on Mac feels very poor.
- The reporting of CPU usage (and CPU time) to the MacOs system is wrong.

Details: 
- eclipse-SDK-I20191113-2315 + Tools for Developers (as per Platform Dev. guide)
- using theme Dark [Windows] (because no dark mac is available)
- eclipse Platform UI projects loaded in the workspace


Eclipse SDK
Version: 2019-12 (4.14)
Build id: I20191113-2315
OS: Mac OS X, v.10.15.1, x86_64 / cocoa
Java version: 10.0.1
Comment 1 Patrik Suzzi CLA 2019-11-19 01:37:56 EST
Created attachment 280688 [details]
Error log for the session
Comment 2 Andrey Loskutov CLA 2019-11-19 01:38:34 EST
Can you please create a thread dump via jstack and heap dump + heap histogram via jmap?
Comment 3 Patrik Suzzi CLA 2019-11-19 01:40:50 EST
Created attachment 280689 [details]
State of the UI and List of errors - just before eclipse shutdown
Comment 4 Patrik Suzzi CLA 2019-11-19 01:43:41 EST
(In reply to Andrey Loskutov from comment #2)
> Can you please create a thread dump via jstack and heap dump + heap
> histogram via jmap?

Eclipse was unresponsive and then I had to restart it. Hence, I cannot create a thread dump for that session. 

I will create a thread dump the next time I get the same error.
Comment 5 Andrey Loskutov CLA 2019-11-19 03:15:03 EST
Patrik, can you please point to the git repository you were working with, if it is open source? Which egit version are you using?
Comment 6 Patrik Suzzi CLA 2019-11-19 04:10:57 EST
I was working with the Eclipse I20191113-2315 plus the development tools installed via the psf provided in the Platform/How_to_Contribute [ref.1]. No other plugins were installed.

When I got the error, I had four repositories open: 
- the three repositories listed in p2f provided in Platform/How_to_Contribute [ref.2], plus a local repository


[ref.1] https://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/releng/org.eclipse.ui.releng/platformUiTools.p2f
[ref.2] http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/releng/org.eclipse.ui.releng/platformUiProjectsGerrit.psf
Comment 7 Thomas Wolf CLA 2019-11-19 10:25:28 EST
How did you end up with a git repository in your user home directory? Is that intentional?

What happens if you do

 $ cd ~
 $ git status

?
Comment 8 Thomas Wolf CLA 2019-11-19 10:33:08 EST
If unintentional: before deleting that ~/.git folder, please check the contents of directory ~/.git/hooks. If it contains *.sample files, it was created by command-line git. If it's empty, it was created by JGit. In that case I'd like to know what you did in Eclipse to make EGit/JGit create a git repo there...
Comment 9 Patrik Suzzi CLA 2019-11-19 20:05:43 EST
(In reply to Thomas Wolf from comment #7)
> How did you end up with a git repository in your user home directory? Is
> that intentional?

No, unintentional.

> What happens if you do
> 
>  $ cd ~
>  $ git status
> 
> ?

After a few seconds, I get the status. All the actual repositories result modified, while other files/folders are untracked.


(In reply to Thomas Wolf from comment #8)
> If unintentional: <...> check contents of directory ~/.git/hooks. 
> If it contains *.sample files, it was created by command-line git. 
> If it's empty, it was created by JGit. <...>

Indeed, there are .sample files. So, it was not created by JGit.
Comment 10 Patrik Suzzi CLA 2019-11-19 21:03:36 EST
(In reply to Andrey Loskutov from comment #2)
> Can you please create a thread dump via jstack and heap dump + heap
> histogram via jmap?

I reproduced the issue, it's related to the staging view.

I generated the logs with the following script

pid=39857 &&\
tst=$(date '+%Y%m%d_%H%M%S') &&\
jstack -l "${pid}" >> "dumps/threaddumps-${pid}-${tst}.log" &&\
jmap -J-d64 -histo:live "${pid}" >> "dumps/jmapheap-histo-${pid}-${tst}.log" 

With the next two comments, I'll attach the thread dump and the heap histogram.
Comment 11 Patrik Suzzi CLA 2019-11-19 21:05:06 EST
Created attachment 280708 [details]
Thread dump
Comment 12 Patrik Suzzi CLA 2019-11-19 21:08:24 EST
Created attachment 280709 [details]
Heap histogram.


Note: I also generated a heap dump, but it's 1.45 GB. I guess I can't attach it here.
Comment 13 Patrik Suzzi CLA 2019-11-19 21:12:19 EST
Created attachment 280710 [details]
Weird error message: An internal error occurred while showing an internal error.


Bonus: weird error of the day!
Comment 14 Thomas Wolf CLA 2019-11-20 03:45:52 EST
The "weird error" is not weird at all. In fact, I'm surprised you get a reasonable error dialog when the JVM has run out of memory.

Remove that ~/.git repository from Eclipse. It's bound to have millions of unstaged files, and the staging view is trying to add a million items to a TreeViewer. (To be precise: according to your heap histogram, it's 1072037 unstaged files in 313718 directories.)

If you can't remove it the IDE because of these OOMs, do it outside Eclipse: open the file .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs in your workspace directory and remove "/Users/psuzzi/.git" from the two keys "GitRepositoriesView.GitDirectories" and "GitRepositoriesView.GitDirectories.relative".

Then delete that spurious ~/.git directory including its contents.

Then start Eclipse again.
Comment 15 Matthias Sohn CLA 2019-11-20 04:25:44 EST
(In reply to Thomas Wolf from comment #14)
> The "weird error" is not weird at all. In fact, I'm surprised you get a
> reasonable error dialog when the JVM has run out of memory.
> 
> Remove that ~/.git repository from Eclipse. It's bound to have millions of
> unstaged files, and the staging view is trying to add a million items to a
> TreeViewer. (To be precise: according to your heap histogram, it's 1072037
> unstaged files in 313718 directories.)

Maybe we should teach the StagingView not to try loading such a mass of unstaged files. Who wants to scroll 1 mio files in a view ?
Comment 16 Andrey Loskutov CLA 2019-11-20 04:47:21 EST
(In reply to Matthias Sohn from comment #15)
> Maybe we should teach the StagingView not to try loading such a mass of
> unstaged files. Who wants to scroll 1 mio files in a view ?

We have already a preference for "compact" mode, limit is 10000. May be add a limit for other modes as well?
Comment 17 Thomas Wolf CLA 2019-11-20 04:54:24 EST
(In reply to Matthias Sohn from comment #15)
> Maybe we should teach the StagingView not to try loading such a mass of
> unstaged files. Who wants to scroll 1 mio files in a view ?

Perhaps. Though the interesting thing is: Patrik even has two commits in that ~/.git repo, and the file diff viewer in the history view (see his screenshot [1]) apparently can display fine. The scrollbar thumb in that view is small, so I suppose there's quite a lot of files in that commit, too.

The CommitFileDiffViewer uses a virtual table, though.

Patrik, how many files are in commit 919ad39 in ~/.git? You can find out by doing

  $ cd ~
  $ git diff-tree --no-commit-id --name-only -r 919ad39 | wc -l

[1] https://bugs.eclipse.org/bugs/attachment.cgi?id=280687
Comment 18 Patrik Suzzi CLA 2019-11-20 18:36:02 EST
(In reply to Thomas Wolf from comment #17)
> Patrik, how many files are in commit 919ad39 in ~/.git? You can find out by
> doing
> 
>   $ cd ~
>   $ git diff-tree --no-commit-id --name-only -r 919ad39 | wc -l
> 
> [1] https://bugs.eclipse.org/bugs/attachment.cgi?id=280687

:~ (master)
$ git diff-tree --no-commit-id --name-only -r 919ad39 | wc -l
    5148
Comment 19 Thomas Wolf CLA 2019-11-21 03:18:20 EST
(In reply to Patrik Suzzi from comment #18)
> $ git diff-tree --no-commit-id --name-only -r 919ad39 | wc -l
>     5148

While large it's clearly a number that SWT trees/tables can handle easily.

So yes, we should perhaps add some absolute upper limit for these viewers in the staging view. But then? Staging a million files likely is going to have problems, too. If the user manages to commit the changes, we have a commit with a million items (and a git tree with a million items). If the user tries to show that commit in the history view, we'll add a million items to the CommitFileDiffViewer. If he opens the commit viewer on that commit, we'll try to produce a unified diff of a million items, and the outline will try to show a million items. There'll be a million items in the index, and index diff will take a while.

This is just not going to work at all.

My suggestion is not to do anything in software for this. Better run into an OOM, get a bug report, and then advise the user not to do such things.
Comment 20 Patrik Suzzi CLA 2019-11-21 04:53:34 EST
(In reply to Thomas Wolf from comment #19)
> My suggestion is not to do anything in software for this. Better run into an
> OOM, get a bug report, and then advise the user not to do such things.

IMHO, the real problem is the UI is blocked during the operation. Hence, I think we should identify the UI-blocking component, and instead of blocking, perform an asyncExec.
Comment 21 Thomas Wolf CLA 2019-11-21 15:33:50 EST
(In reply to Patrik Suzzi from comment #20)
> IMHO, the real problem is the UI is blocked during the operation. Hence, I
> think we should identify the UI-blocking component, and instead of blocking,
> perform an asyncExec.

Filling in a tree necessarily has to happen on the UI thread.
Comment 22 Patrik Suzzi CLA 2019-11-25 19:38:35 EST
(In reply to Thomas Wolf from comment #21)
> Filling in a tree necessarily has to happen on the UI thread.

I thought we should be able to precompute a model and then set it into the tree, perhaps with a TreeContentProvider. 


Anyway, I think there is another use case to consider: 

1. When I set-up the workspace, I just import a Team Project Set [ref.1] with no reference to the ~/.git repository. 

2. And then, the repository in ~/.git is automatically added to the repository view (that is unjustified as there is no reference to it in the .psf).

3. Finally, when I right-click that ~/.git repo to remove it from the view, 50% of times, Eclipse becomes unresponsive. 



[ref.1] http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/releng/org.eclipse.ui.releng/platformUiProjectsGerrit.psf
Comment 23 Thomas Wolf CLA 2019-11-26 01:22:57 EST
(In reply to Patrik Suzzi from comment #22)
> 1. When I set-up the workspace, I just import a Team Project Set [ref.1]
> with no reference to the ~/.git repository. 
> 
> 2. And then, the repository in ~/.git is automatically added to the
> repository view (that is unjustified as there is no reference to it in the
> .psf).

Now that's something we can try to fix.
Comment 24 Eclipse Genie CLA 2019-11-26 15:54:10 EST
New Gerrit change created: https://git.eclipse.org/r/153436
Comment 25 Patrik Suzzi CLA 2019-11-27 20:02:58 EST
Note: I wanted to check your change on gerrit, and I first checked how it works now on master. I observed the issue is already resolved with the master version of EGit.

To test, I just cloned EGit and JGit projects locally and launched a new Eclipse instance with the contained plugins. 
Then, in the new Eclipse (inner) instance, I verified that when I import a .psf file, the main ~/.git repository is not automatically imported.
Comment 26 Thomas Wolf CLA 2019-11-28 02:21:11 EST
Thanks for the double check, but for me it does occur. If I create a ~/.git by running git init in my home directory, start a child Eclipse in a new workspace, change the default directory for git directories to some new directory (because I already have EGit clones with a different URL) and then import the egit.psf, then open the git repositories view, I end up with ~/.git in the repositories view. The change makes sure that this doesn't happen anymore.
Comment 27 Thomas Wolf CLA 2019-11-28 02:23:17 EST
(In reply to Thomas Wolf from comment #26)
> change the default directory for git directories to some new directory

To be precise: to ~/git2. The problem occurs only if the location for the cloned repositories is underneath ~. Which is normally the case; the default is ~/git.
Comment 28 Eclipse Genie CLA 2019-11-28 03:36:45 EST
Gerrit change https://git.eclipse.org/r/153436 was merged to [stable-5.6].
Commit: http://git.eclipse.org/c/egit/egit.git/commit/?id=6dad437624f1ab9796ddf6395b248d58607a3958