GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add --nostop to always start profiler recording even when --ttsp or --start/--end are used by openorclose · Pull Request #1046 · async-profiler/async-profiler

Conversation

@openorclose

@openorclose openorclose commented Nov 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

  • Added --nostop to always start profiler recording even when --ttsp or --start/--end are used

Related issues

#833

Motivation and context

In particular, this allows us to continue recording events in --ttsp mode

How has this been tested?

Added a test for the original ttsp mode and also the newly added flag.


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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Daryl Tan
Allow recording windows between a start and stop function
365f219
@openorclose openorclose closed this Nov 5, 2024
@openorclose
openorclose deleted the ttsp branch November 5, 2024 15:45
@openorclose
openorclose restored the ttsp branch November 5, 2024 15:46
@openorclose openorclose reopened this Nov 5, 2024
Daryl Tan
Add copyright headers
9ba22a3
apangin
apangin reviewed Nov 12, 2024
View reviewed changes
Comment thread src/arguments.cpp Outdated
_mcache = value == NULL ? 1 : (unsigned char)strtol(value, NULL, 0);

CASE("recordonly")
_start_alongside_traps = true;

@apangin apangin Nov 11, 2024

Copy link
Copy Markdown
Collaborator

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.

It's hard to search and follow the logic, when asprof argument, agent argument and the variable in the code are all named differently. Let's use the same name if possible.
My suggestion is nostop (similarly to nostop option for handling signals in gdb), but other suggestions are welcome.
Consequently, arguments and the variable name will be nostop, --nostop, _nostop.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/main.cpp Outdated
Comment on lines +80 to +82
" --timebetween a b record when a is executed, and then when b is executed, and duration between\n"
" --onlyttsp only time-to-safepoint profiling \n"
" --includettsp profile as per normal, but include time-to-safepoint information\n"

@apangin apangin Nov 12, 2024

Copy link
Copy Markdown
Collaborator

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.

I understand you wanted to shortcut certain use cases, but having many options to do the same thing causes unnecessary ambiguity or even confusion, considering that asprof arguments do not match agent arguments.
If we add just one new option (e.g. --nostop as mentioned above), this will be unambiguous, will match agent argument, and will cover all use cases relatively simply. Moreover, it will remain backward compatible.
IMO, --ttsp --nostop is not much worse than --includettsp.

I would probably agree with additional --window A B option to record profiler.Window event between execution of A and B, but this is a quite rare use cases, so it does not deserve a separate option, I think.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@openorclose openorclose Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

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.

Will use nostop for now, anyone else feel free to suggest others

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/main.cpp Outdated
params << ",begin=SafepointSynchronize::begin,end=RuntimeService::record_safepoint_synchronized";

} else if (arg == "--includettsp") {
fprintf(stderr, "ZZZZ");

@apangin apangin Nov 12, 2024

Copy link
Copy Markdown
Collaborator

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.

Debug leftover.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/JfrTests.java Outdated
public void includettsp(TestProcess p) throws Exception {
p.profile("-d 5 --includettsp -f %f.jfr");
if (!containsSamplesOutsideWindow(p)) {
throw new RuntimeException("Expected to find samples outside of ttsp window, but did not find any");

@apangin apangin Nov 12, 2024

Copy link
Copy Markdown
Collaborator

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.

Same as above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/JfrTests.java
}
}

private boolean containsSamplesOutsideWindow(TestProcess p) throws Exception {

@apangin apangin Nov 12, 2024

Copy link
Copy Markdown
Collaborator

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.

Can be shortened and simplified a bit.

  1. events list is redundant; we may collect profiler windows and execution samples in the first pass.
  2. Profiler windows can be stored in a TreeMap as startTime->endTime. This will provide sorting and lookup for the closest window out of the box.
  3. Search loop can be simplified with stream().anyMatch().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@openorclose openorclose Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

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.

thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/Ttsp.java
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;

class Ttsp {

@apangin apangin Nov 12, 2024

Copy link
Copy Markdown
Collaborator

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.

This example needs some comments. How does it expose long TTSP issue? Why getAllStackTraces() is called in a loop? Writing 1GB files in a loop may not be a good thing to do in a test - IO is not what we are testing here. Furthermore, not all systems may even have a spare gigabyte in /tmp volume.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@openorclose openorclose Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

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.

Thank you, I adapted this example from an online article regarding debugging ttsp issues, will rewrite with explanation

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@apangin

apangin commented Nov 12, 2024

Copy link
Copy Markdown
Collaborator

Thank you for the PR.
The feature is indeed useful, but I think it can be implemented in a simpler way - added some comments inline.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Daryl Tan added 9 commits November 25, 2024 15:18
Daryl Tan
Merge remote-tracking branch 'origin/master' into ttsp
0ad85dd
Daryl Tan
Address PR review comments
7d21a6b
Daryl Tan
Merge remote-tracking branch 'origin/master' into ttsp
6dde474
Daryl Tan
Update TTSP tests
89bbf1d
Daryl Tan
Update TTSP tests
fbac090
Daryl Tan
Merge remote-tracking branch 'origin/master' into ttsp
74fb7ff
Daryl Tan
Update ProfilerOptions.md
6838f04
Daryl Tan
Revert "Update ProfilerOptions.md"
5501cc4
This reverts commit 6838f04.
Daryl Tan
Update ProfilerOptions.md
11992c2
@openorclose openorclose changed the title Allow recording windows between a start and stop function Add --nostop to always start profiler recording even when --ttsp or --start/--end are used Dec 6, 2024
apangin and others added 2 commits December 9, 2024 00:20
@apangin
Updated documentation and formatting
d9f9087
@apangin
Merge branch 'master' into ttsp
c63a385
Signed-off-by: Andrei Pangin <[email protected]>
apangin
apangin reviewed Dec 9, 2024
View reviewed changes
Comment thread test/test/jfr/Ttsp.java
static private byte loop() {
byte[] byteArray = new byte[1024 * 1024 * 1024];
for (int i = 0; i < 10000; i++) {
new Random().nextBytes(byteArray);

@apangin apangin Dec 9, 2024

Copy link
Copy Markdown
Collaborator

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.

Random.nextBytes contains a loop with a safepoint check - it does not cause long time-to-safepoint pauses.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/Ttsp.java
public static void main(String[] args) throws Exception {
new Thread(() -> {
while (true) {
System.gc();

@apangin apangin Dec 9, 2024

Copy link
Copy Markdown
Collaborator

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.

ThreadMXBean.dumpAllThreads is a much cheaper way to force global safepoint.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/Ttsp.java
}
}).start();

Thread.sleep(1000);

@apangin apangin Dec 9, 2024

Copy link
Copy Markdown
Collaborator

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.

Relying on Thread.sleep in tests in error-prone.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test/jfr/Ttsp.java
new Thread(() -> {
while (true) {
loop();
}

@apangin apangin Dec 9, 2024

Copy link
Copy Markdown
Collaborator

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.

A loop in this example is not very useful. The only long ttsp pause happens the very first time when allocating new byte[1024 * 1024 * 1024] array; there are no ttsp pauses afterwards.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@apangin

apangin commented Dec 9, 2024

Copy link
Copy Markdown
Collaborator

Changes look good, except for the test, which does not really demonstrate time-to-safepoint pauses.
I'll merge this PR and push a revised test afterwards.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@apangin
apangin merged commit d7ab642 into async-profiler:master Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@apangin apangin apangin left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@openorclose @apangin
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.