Skip to content
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

[BOLT][NFC] Log through JournalingStreams #81524

Merged
merged 9 commits into from
Feb 12, 2024

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Feb 12, 2024

Make core BOLT functionality more friendly to being used as a
library instead of in our standalone driver llvm-bolt. To
accomplish this, we augment BinaryContext with journaling streams
that are to be used by most BOLT code whenever something needs to
be logged to the screen. Users of the library can decide if logs
should be printed to a file, no file or to the screen, as
before. To illustrate this, this patch adds a new option
--log-file that allows the user to redirect BOLT logging to a
file on disk or completely hide it by using
--log-file=/dev/null. Future BOLT code should now use
BinaryContext::outs() for printing important messages instead of
llvm::outs(). A new test log.test enforces this by verifying that
no strings are print to screen once the --log-file option is
used.

In previous patches we also added a new BOLTError class to report
common and fatal errors, so code shouldn't call exit(1) now. To
easily handle problems as before (by quitting with exit(1)),
callers can now use
BinaryContext::logBOLTErrorsAndQuitOnFatal(Error) whenever code
needs to deal with BOLT errors. To test this, we have fatal.s
that checks we are correctly quitting and printing a fatal error
to the screen.

Because this is a significant change by itself, not all code was
yet ported. Code from Profiler libs (DataAggregator and friends)
still print errors directly to screen.

Co-authored-by: Rafael Auler rafaelauler@fb.com

Test Plan: NFC

@aaupov aaupov marked this pull request as draft February 12, 2024 20:14
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov aaupov marked this pull request as ready for review February 12, 2024 21:01
Copy link
Contributor

@rafaelauler rafaelauler left a comment

Choose a reason for hiding this comment

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

Thanks, here's what I think is a suitable commit message for this one:

Make core BOLT functionality more friendly to being used as a
library instead of in our standalone driver llvm-bolt. To
accomplish this, we augment BinaryContext with journaling streams
that are to be used by most BOLT code whenever something needs to
be logged to the screen. Users of the library can decide if logs
should be printed to a file, no file or to the screen, as
before. To illustrate this, this patch adds a new option
--log-file that allows the user to redirect BOLT logging to a
file on disk or completely hide it by using
--log-file=/dev/null. Future BOLT code should now use
BinaryContext::outs() for printing important messages instead of
llvm::outs(). A new test log.test enforces this by verifying that
no strings are print to screen once the --log-file option is
used.

In previous patches we also added a new BOLTError class to report
common and fatal errors, so code shouldn't call exit(1) now. To
easily handle problems as before (by quitting with exit(1)),
callers can now use
BinaryContext::logBOLTErrorsAndQuitOnFatal(Error) whenever code
needs to deal with BOLT errors. To test this, we have fatal.s
that checks we are correctly quitting and printing a fatal error
to the screen.

Because this is a significant change by itself, not all code was
yet ported. Code from Profiler libs (DataAggregator and friends)
still print errors directly to screen.

Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@aaupov aaupov changed the base branch from users/aaupov/spr/main.bolt-log-through-journalingstreams to main February 12, 2024 22:51
@aaupov aaupov changed the title [BOLT] Log through JournalingStreams [BOLT][NFC] Log through JournalingStreams Feb 12, 2024
Created using spr 1.3.4
@aaupov aaupov merged commit 52cf071 into main Feb 12, 2024
3 of 4 checks passed
@aaupov aaupov deleted the users/aaupov/spr/bolt-log-through-journalingstreams branch February 12, 2024 22:53
maksfb added a commit to maksfb/llvm-project that referenced this pull request Feb 19, 2024
Use journaling streams introduced in llvm#81524 for LinuxKernelRewriter.
maksfb added a commit that referenced this pull request Feb 19, 2024
Use journaling streams introduced in #81524 for LinuxKernelRewriter.
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.

None yet

2 participants