Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: more backend capabilities for heapdump #233

Closed
wants to merge 4 commits into from

Conversation

y1yang0
Copy link
Contributor

@y1yang0 y1yang0 commented Sep 13, 2023

Add more backend capabilities for heapdump analysis

static {
ARGS.put("queryString", OQL);
JDK_MANAGED_BUFFER_ARGS.put("queryString", JDK_MANAGED_BUFFER_OQL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about?

static final Map<String, Object> JDK_MANAGED_BUFFER_ARGS = Collections.singletonMap("queryString", ...);

or even with a helper:

static final Map<String, Object> JDK_MANAGED_BUFFER_ARGS = makeQueryMap(oql);

queryGc.put("queryString", "SELECT toString(g.name) AS GC FROM sun.management.GarbageCollectorImpl g");
return $(() -> {
List<String> options = new ArrayList<>();
List<String> gc =new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonk000
Hi, I cannot see the content after nit:. I guess there is a typo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the whitespace:

-List<String> gc  =new ArrayList<>();
+List<String> gc = new ArrayList<>();

"SELECT s.@displayName as label, s.position as position, s.limit as limit, s.capacity as " +
"capacity FROM java.nio.DirectByteBuffer s where s.cleaner = null and s.att = null";
static final String ALL_BUFFER_OQL =
"SELECT s.@displayName as label, s.position as position, s.limit as limit, s.capacity as " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break the existing default behaviour now?

Previously the default was equivalent to JDK_MANAGED_BUFFER_OQL, but below we default to ALL. I'm not sure which is intended.

Copy link
Contributor Author

@y1yang0 y1yang0 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend will be synced later by @D-D-H

The existing default behavior is problematic because actual direct buffer(and related off-heap memory) is less than presented, that why we provide these fine-grained options to inspect direct buffer.

return data;
AnalysisContext context, String mode) throws SnapshotException {
DirectByteBufferData data = new DirectByteBufferData();
Map<String, Object> queryArg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd add final here to avoid potential bug from missing break.


RefinedResultBuilder builder =
new RefinedResultBuilder(new SnapshotQueryContext(context.snapshot), table);
builder.setSortOrder(3, Column.SortDirection.DESC);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sort order important for summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we want to sort by retaiend heap


return $(() -> {
if(type == Model.Histogram.ItemType.PACKAGE){
IResult result = queryByCommand(context, "histogram -groupBy " + "BY_PACKAGE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can remove +

@@ -71,10 +73,13 @@ PageView<ClassLoader.Item> getChildrenOfClassLoader(int classLoaderId,
PageView<UnreachableObject.Item> getUnreachableObjects(int page, int pageSize);

@ApiMeta(aliases = "directByteBuffer.summary")
DirectByteBuffer.Summary getSummaryOfDirectByteBuffers();
DirectByteBuffer.Summary getSummaryOfDirectByteBuffers(String mode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making 'mode' optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See queryDirectByteBufferData, default to query all byte buffers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional here means that front-end doesn't have to pass the parameter.
see @ApiParameterMeta.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making mode as an Enum type like 'grouping'?

queryGc.put("queryString", "SELECT toString(g.name) AS GC FROM sun.management.GarbageCollectorImpl g");
return $(() -> {
List<String> options = new ArrayList<>();
List<String> gc =new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonk000
Hi, I cannot see the content after nit:. I guess there is a typo.

Copy link
Contributor

@D-D-H D-D-H left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to refine the commit title to align the purpose of this patch.

@y1yang0 y1yang0 closed this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants