-
Notifications
You must be signed in to change notification settings - Fork 317
Provide a safe default stackwalker for non-hotspot JVMs #9930
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...rofiling-ddprof/src/test/java/com/datadog/profiling/ddprof/DatadogProfilerConfigTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package com.datadog.profiling.ddprof; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import datadog.trace.api.config.ProfilingConfig; | ||
| import datadog.trace.bootstrap.config.provider.ConfigProvider; | ||
| import java.util.Properties; | ||
| import java.util.stream.Stream; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| class DatadogProfilerConfigTest { | ||
| private String originalVmName; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| originalVmName = System.getProperty("java.vm.name"); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void tearDown() { | ||
| if (originalVmName != null) { | ||
| System.setProperty("java.vm.name", originalVmName); | ||
| } else { | ||
| System.clearProperty("java.vm.name"); | ||
| } | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("j9StackwalkerTestCases") | ||
| void testGetCStackWithJ9(String configuredStackwalker, String expectedStackwalker) { | ||
| System.setProperty("java.vm.name", "Eclipse OpenJ9 VM"); | ||
|
|
||
| Properties props = new Properties(); | ||
| props.put(ProfilingConfig.PROFILING_DATADOG_PROFILER_CSTACK, configuredStackwalker); | ||
| ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props); | ||
|
|
||
| String result = DatadogProfilerConfig.getCStack(configProvider); | ||
|
|
||
| assertEquals( | ||
| expectedStackwalker, | ||
| result, | ||
| "J9 JVM with configured stackwalker '" | ||
| + configuredStackwalker | ||
| + "' should return '" | ||
| + expectedStackwalker | ||
| + "'"); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("zingStackwalkerTestCases") | ||
| void testGetCStackWithZing(String configuredStackwalker, String expectedStackwalker) { | ||
| System.setProperty("java.vm.name", "Zing 64-Bit Tiered VM"); | ||
|
|
||
| Properties props = new Properties(); | ||
| props.put(ProfilingConfig.PROFILING_DATADOG_PROFILER_CSTACK, configuredStackwalker); | ||
| ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props); | ||
|
|
||
| String result = DatadogProfilerConfig.getCStack(configProvider); | ||
|
|
||
| assertEquals( | ||
| expectedStackwalker, | ||
| result, | ||
| "Zing JVM with configured stackwalker '" | ||
| + configuredStackwalker | ||
| + "' should return '" | ||
| + expectedStackwalker | ||
| + "'"); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("hotspotStackwalkerTestCases") | ||
| void testGetCStackWithHotspot(String configuredStackwalker, String expectedStackwalker) { | ||
| System.setProperty("java.vm.name", "Java HotSpot(TM) 64-Bit Server VM"); | ||
|
|
||
| Properties props = new Properties(); | ||
| props.put(ProfilingConfig.PROFILING_DATADOG_PROFILER_CSTACK, configuredStackwalker); | ||
| ConfigProvider configProvider = ConfigProvider.withPropertiesOverride(props); | ||
|
|
||
| String result = DatadogProfilerConfig.getCStack(configProvider); | ||
|
|
||
| assertEquals( | ||
| expectedStackwalker, | ||
| result, | ||
| "HotSpot JVM with configured stackwalker '" | ||
| + configuredStackwalker | ||
| + "' should return '" | ||
| + expectedStackwalker | ||
| + "'"); | ||
| } | ||
|
|
||
| private static Stream<Arguments> j9StackwalkerTestCases() { | ||
| return Stream.of( | ||
| // Unsupported stackwalkers - should fall back to dwarf | ||
| Arguments.of("vm", "dwarf"), | ||
| Arguments.of("vmx", "dwarf"), | ||
| // Supported stackwalkers - should pass through | ||
| Arguments.of("dwarf", "dwarf"), | ||
| Arguments.of("fp", "fp"), | ||
| Arguments.of("lbr", "lbr"), | ||
| Arguments.of("no", "no")); | ||
| } | ||
|
|
||
| private static Stream<Arguments> zingStackwalkerTestCases() { | ||
| return Stream.of( | ||
| // Unsupported stackwalkers - should fall back to dwarf | ||
| Arguments.of("vm", "dwarf"), | ||
| Arguments.of("vmx", "dwarf"), | ||
| // Supported stackwalkers - should pass through | ||
| Arguments.of("dwarf", "dwarf"), | ||
| Arguments.of("fp", "fp"), | ||
| Arguments.of("lbr", "lbr"), | ||
| Arguments.of("no", "no")); | ||
| } | ||
|
|
||
| private static Stream<Arguments> hotspotStackwalkerTestCases() { | ||
| return Stream.of( | ||
| // All stackwalkers should pass through unchanged | ||
| Arguments.of("vm", "vm"), | ||
| Arguments.of("vmx", "vmx"), | ||
| Arguments.of("dwarf", "dwarf"), | ||
| Arguments.of("fp", "fp"), | ||
| Arguments.of("lbr", "lbr"), | ||
| Arguments.of("no", "no")); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor suggestion. I believe that
@CsvSourcewould be a better choice here. More readable.Here and similar places in this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, I've just noticed that. Will do that as a followup ...