KEMBAR78
Support advanced stack walking features with cstack=vm by apangin · Pull Request #1537 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

apangin
Copy link
Member

@apangin apangin commented Oct 15, 2025

Description

This PR is a prerequisite to making cstack=vm the default stack walking mode.
It includes the following changes:

  1. vm and vmx are no longer different stack walking modes. It's now a single vm mode with an optional mixed feature. There is already -F argument for choosing various stack walking features, and the ability to display mixed stack (where native frames interleave Java frames) fits this paradigm well. cstack=vmx remains for backward compatibility as a shorthand for cstack=vm,features=mixed.
  2. StackDetail enum is gone. Now, I pass features argument instead.
  3. VMStructs stack walker now supports vtable and comptask features.
  4. For nativemem profiles, I chop everything above malloc hook frames, similarly to fp and dwarf modes.

I haven't changed logic around allocation and lock profiling. They still use JVMTI API for getting stack traces. This will keep familiar user experience after switching to vm by default.

Related issues

#1533, #1370

Motivation and context

VMStructs should support all stack walking features that fp and dwarf modes do.

How has this been tested?

--cstack vm -F comptask+vtable

Integration tests will be amended in the subsequent PR that changes default mode.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Baraa-Hasheesh
Copy link
Contributor

Baraa-Hasheesh commented Oct 15, 2025

I haven't changed logic around allocation

But wouldn't that keep the known issue of allocation profiling not collecting native samples for alloc samples when vm is selected?
For example the following samples

image image

When using VM stack walker they won't have these native frames,
This is because we're skipping native portion for vm on the Profiler::getNativeTrace function & only collect the java samples using the JVMTI stack walker

You can test this change against the AllocTests.startup I think it will fail if you enable vm

}
continue;
} else {
if (features.vtable_target && nm->isVTableStub() && depth == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a test for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added tests for vtable stub and itable stub

@apangin
Copy link
Member Author

apangin commented Oct 15, 2025

@Baraa-Hasheesh You are right: ideally, allocation profiling should use VMStructs stack walker too. But let's do it in a separate PR.

@apangin apangin merged commit 5aee9cd into async-profiler:master Oct 15, 2025
25 checks passed
@Baraa-Hasheesh
Copy link
Contributor

@Baraa-Hasheesh You are right: ideally, allocation profiling should use VMStructs stack walker too. But let's do it in a separate PR.

That's should be fine

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.

2 participants