KEMBAR78
Save all generated logs for debug purposes by Baraa-Hasheesh · Pull Request #1373 · async-profiler/async-profiler · GitHub
Skip to content

Conversation

Baraa-Hasheesh
Copy link
Contributor

@Baraa-Hasheesh Baraa-Hasheesh commented Jul 9, 2025

Description

keep all logs for debugging purposes
This fix the following problems:

  • If multiple profiling sessions are done, each session will overwrite the previous one logs
  • If a test depends on both profiler session logs & process logs only one of those logs will be kept
  • Not all generated profiler logs were saved

Related issues

N/A

Motivation and context

Make debugging flakey tests easier

How has this been tested?

make test


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

@Baraa-Hasheesh Baraa-Hasheesh marked this pull request as draft July 9, 2025 09:23
@Baraa-Hasheesh Baraa-Hasheesh marked this pull request as ready for review July 9, 2025 10:40
@fandreuz
Copy link
Contributor

fandreuz commented Jul 9, 2025

Make debugging flakey tests easier

How does this work?

@Baraa-Hasheesh
Copy link
Contributor Author

Make debugging flakey tests easier

How does this work?

Some logs are currently messing, I.E, we can't check them if a failure happens
By saving those log files it would be possible to download them when a failure happens on GHA which makes it easier to debug


Process p = new ProcessBuilder(cmd)
.redirectOutput(createTempFile(PROFOUT))
.redirectOutput(createTempFile(PROFOUT + profilerId))
Copy link
Member

Choose a reason for hiding this comment

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

This is not very helpful. Other outputs (stdout, stderr, custom %f files) will still overwrite each other.
More logs does not mean better, we'll get the last failed one anyway. I propose to leave this as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed b447135


File profile = tmpFiles.get("%f");
moveLog(profile, "profile", true);
moveLog(tmpFiles.get(key), "profile" + key.replace('%', '-'), true);
Copy link
Member

Choose a reason for hiding this comment

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

profile- prefix is redundant. E.g. profile-perr name does not make much sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about cases where we replace other files

@Test(sh = "%testbin/non_java_app 3 %f.collapsed %s.collapsed", output = true)
public void jvmInBetween(TestProcess p) throws Exception {

ideally the test should give it a clear name so we have two options here

  • Add profile- & keep names as %f => profile-f
  • Loop & give meaningful names for all file names

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as discussed offline we will use the key as is
For future we should try to give meaningful names

Updated here b447135

moveLog(stderr, "stderr", false);
for (String key : tmpFiles.keySet()) {
if (key.equals(STDERR) || key.equals(STDOUT)) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

nit: when the body of the loop is just one line, it's better to go ahead without continue:

if (!key.equals(STDOUT) && !key.equals(STDERR)) {
    moveLog(...);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

handled here b447135

moveLog(profile, "profile", true);
for (String key : tmpFiles.keySet()) {
if (!key.equals(STDERR) && !key.equals(STDOUT)) {
moveLog(tmpFiles.get(key), key.replaceAll("%", ""), true);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe key.substring(1) instead of replaceAll? This is more efficient and matches other usages in TestProcess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated here 347d09e

@apangin apangin merged commit a70f25e into async-profiler:master Jul 9, 2025
8 of 19 checks passed
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