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 — Profiling output respects loglevel. by krk · Pull Request #986 · async-profiler/async-profiler

Conversation

@krk

@krk krk commented Sep 4, 2024

Copy link
Copy Markdown
Contributor

Description

"Profiling started" and other messages are now INFO loglevel and will respect the current loglevel.

Related issues

#960

Motivation and context

All messages should respect loglevel, "Profiling started" etc. messages did not.

How has this been tested?

With different loglevel parameters:

java ... -agentpath: ...,loglevel=info ...
Profiling started
java ... -agentpath: ...,loglevel=warn ...

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.

geertn reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@apangin

apangin commented Sep 4, 2024

Copy link
Copy Markdown
Collaborator

I'd argue that Profiler output should not respect loglevel.
Output and logs are two different streams. The former is where profiling results go to; results must be dumped regardless of the log level.

I think a better approach to the problem is to make "Profiler started" a log message, which it essentially is, with an exception of Java API, where this message is a valid response returned from execute method.

All reactions

Sorry, something went wrong.

Uh oh!

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

@apangin

apangin commented Sep 4, 2024

Copy link
Copy Markdown
Collaborator

When testing, please verify all 3 ways to run profiler:

  1. as an agent;
  2. using asprof;
  3. via Java API.
All reactions

Sorry, something went wrong.

Uh oh!

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

@krk
krk force-pushed the profiling-started branch 2 times, most recently from 5cb4148 to 7b448d7 Compare September 9, 2024 10:55
@krk

krk commented Sep 9, 2024

Copy link
Copy Markdown
Contributor Author

Simplified the approach, introduced a new LogWriter class to be used instead of FileWriter out(STDOUT_FILENO).

Tested as an agent, asprof and Java API.

❯ asprof start jps
Profiling started

❯ asprof start -L info jps
Profiling started

❯ asprof start -L warn jps
All reactions

Sorry, something went wrong.

Uh oh!

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

@krk
krk force-pushed the profiling-started branch from 9203db6 to 3cd9fc8 Compare September 9, 2024 14:44
@krk

krk commented Sep 9, 2024

Copy link
Copy Markdown
Contributor Author

(rebased)

All reactions

Sorry, something went wrong.

Uh oh!

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

@krk
krk force-pushed the profiling-started branch from 3cd9fc8 to 6bdcbbd Compare September 10, 2024 12:57
apangin
apangin reviewed Sep 10, 2024
View reviewed changes
Comment thread src/log.cpp Outdated
LogLevel Log::_level = LOG_INFO;

int Log::fd() {
return _file ? fileno(_file) : 0;

@apangin apangin Sep 10, 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.

_file must not be NULL, I think.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/writer.h Outdated
int _fd;
char* _buf;
size_t _size;
bool _keepOpen = false;

@apangin apangin Sep 10, 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 will issue a compiler warning with older gcc.
We should migrate to a newer C++ standard first, but that's a separate story.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/writer.h Outdated
class LogWriter : public FileWriter {
LogLevel _logLevel;
public:
LogWriter(LogLevel logLevel = LOG_INFO) : FileWriter(Log::fd(), true) {

@apangin apangin Sep 10, 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 creates an implicit coupling with Log::_file, which lives its own life.
Currently, it's not a problem, since Log is always closed after the output file, but this dependency is fragile.
Alternatively, LogWriter could call Log::writeRaw or something.

Sorry, something went wrong.

Uh oh!

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

All reactions
@krk
Profiling output respects loglevel
7583ccc
"Profiling started" and other messages are now INFO loglevel and will respect the current loglevel.
@krk
krk force-pushed the profiling-started branch from 6bdcbbd to 7583ccc Compare September 16, 2024 14:22
@apangin
apangin merged commit 6d7f73a into async-profiler:master Sep 17, 2024
@apangin

apangin commented Sep 17, 2024

Copy link
Copy Markdown
Collaborator

After this change, "Profiling started" message goes to asprof output. This is intended, but does not look perfect, given that asprof prints its own start/stop messages:

Profiling started
Profiling for 5 seconds
Done

I'm more are more inclined to believe this message is redundant and can be removed entirely except for the Java API call.

krk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@krk krk mentioned this pull request Oct 9, 2024
"Profiler started" doesn't honor loglevel #960
Closed
@krk krk mentioned this pull request Oct 17, 2024
Option to prevent "Profiling started" output #1031
Closed
1 of 2 tasks
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

@krk @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.