Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Slow parsing due to huge ClassImpl.subClasses in GarbageCleaner #59

Closed
turbanoff opened this issue Jun 11, 2024 · 5 comments · Fixed by #63
Closed

Slow parsing due to huge ClassImpl.subClasses in GarbageCleaner #59

turbanoff opened this issue Jun 11, 2024 · 5 comments · Fixed by #63
Assignees

Comments

@turbanoff
Copy link

I have a heap dump, which Eclipse MAT have troubles to open.
image

Thread dump always show this stack trace:

"Worker-1: Parsing heap dump from 'C:\Users\turbanov\Documents\broqa_dumps\java_pid789.hprof\java_pid789.hprof'@8474" prio=5 tid=0x29 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	  at org.eclipse.mat.parser.model.ClassImpl.removeSubClass(ClassImpl.java:467)
	  at org.eclipse.mat.parser.internal.GarbageCleaner.clean(GarbageCleaner.java:238)
	  at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:466)
	  at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:224)
	  at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:149)
	  at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:99)
	  at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

I was able to attach debugger.
Seems issue with huge lists, used by org.eclipse.mat.parser.internal.GarbageCleaner
First one is - org.eclipse.mat.parser.model.ClassImpl#subClasses
image
Second one is - classes2remove
image

I think at least org.eclipse.mat.parser.model.ClassImpl#subClasses could be converted to HashSet/LinkedHashSet to make ClassImpl.removeSubClass to be run in O(1).

@turbanoff
Copy link
Author

Yes, solution to use LinkedHashSet instead of ArrayList for ClassImpl.subClasses works. After changing I was able to open the heap dump in reasonable time.

@jasonk000
Copy link
Contributor

looks related in #57

@jasonk000
Copy link
Contributor

jasonk000 commented Jun 13, 2024

@turbanoff , thank you for the issue/analysis/fix. Are you able to share the heapdump or do any more analysis here?

As we saw in #57, the patch to GarbageCleaner to use FJ pool seems to have triggered this.
7c2cb09

But the patch does not change the ClassImpl, which makes me wonder -- does the new ObjectMarker implementation have a different bug that is leading to a larger list than expected?

@jasonk000 jasonk000 self-assigned this Jun 13, 2024
@turbanoff
Copy link
Author

Here the dump, which Eclipse MAT opens very slowly. Was able to create it with quite small program.
java_pid12932.hprof.gz

@turbanoff turbanoff changed the title Slow parsing due to huge classes2remove in GarbageCleaner Slow parsing due to huge ClassImpl.subClasses in GarbageCleaner Jun 13, 2024
@jasonk000
Copy link
Contributor

@turbanoff thanks for the report, fix, and repro, I've put together patch in #63 , though I only addressed the first list/set, which led to a significant boost. Let me know if you disagree with it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants