-
Notifications
You must be signed in to change notification settings - Fork 69
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
Use wrapper for logging. #1225
base: master
Are you sure you want to change the base?
Use wrapper for logging. #1225
Conversation
In my opinion, the default for release build should be no logs. But we should add a cargo feature that allows info-level logs (and above) for release builds. Also "hot_log" is not a very descriptive feature name. Maybe it should be "release_hot_path_logging" or "release_max_level_trace" to be similar to the log crate feature. EDIT:
Reason for this being that we don't want to break expectations of runtimes such as OpenJDK etc. |
Actually the right way to do this is not bundling Alternatively we can add a section in the tutorial and let the binding depend on |
We made it clear here that if the binding wants to initialize its logger, they should do it before initializing MMTk. In that case, MMTk will fail to set up a logger and use the logger from the binding. Otherwise MMTk will initialize a logger itself: mmtk-core/src/memory_manager.rs Line 41 in 3830168
This is a resonable choice. For MMTk, most VMs are not written in Rust, and they do not have their own Rust logger set up. If every binding needs to set up the same logger, why not set it up in mmtk-core? Also we allows the binding to set up a logger if they want to. |
I dont see why we need custom logging functions. I prefer using Rust's standard logging. If the binding wants to control the logging, we should allow it. If they don't, we use the logger we initialize and control the logging. If our current implementation uses features to disable logging in release builds, or to control logging levels which cannot be changed by the binding, we can fix that. |
One potential benefit of using custom logging functions is that later we can forward the logging calls to the binding so if necessary, the binding can use the VM logging facilities and MMTk logs will be part of the VM logs. Other than this, I can't think of why we want to deviate from Rust standard logging. |
I think Kunshan's point was that for cases like OpenJDK or ART, they don't print logs to stderr but print to a log file or the logcat buffer in ART's case. So it may be the case that mmtk-openjdk or mmtk-art will want to change the logging implementation (and indeed I already use the But I agree with your general sentiment. It should be lowest overhead to get it to work imo. |
Like @k-sareen said, some VMs do have their own logging framework. OpenJDK, for example, has its own unified logging framework described in https://openjdk.org/jeps/158, and has a category for "gc" which can be enabled by Anyway, I don't intend to remove the
There are several reasons. One is that the de-facto standard logging facade The other problem is for engineering. There are other more advanced logging interfaces and implementations in Rust, including slog and tracing. If we want to make a project-wide change, and all logging operations already go through our own wrapper, we can only change that wrapper and quickly adapt to a new logging framework. |
Remove (release_)max_level_*The So it seems obvious that we should not use
|
We no longer use the `max_level_trace` and `release_max_level_off` features of the `log` crate. By doing this, mmtk-core, as a library, won't conflict with its users which need to use the log level features of the `log` crate. We no longer directly use logging macros in the `log` crate. Now all logging operations are done through wrapper macros in the `crate::util::log` module. Logs of level DEBUG and TRACE are disabled at compile time for release builds, and can be enabled using the "hot_log" Cargo feature. By doing this, we can disable logging statements on hot paths in mmtk-core, only, without affecting log statements in other crates. It also allow developers to use logs in release builds in order to debug the performance.
223c9d7
to
6c946ae
Compare
We no longer use the
max_level_trace
andrelease_max_level_off
features of thelog
crate. By doing this, mmtk-core, as a library, won't conflict with its users which need to use the log level features of thelog
crate.We no longer directly use logging macros in the
log
crate. Now all logging operations are done through wrapper macros in thecrate::util::log
module. Logs of level DEBUG and TRACE are disabled at compile time for release builds, and can be enabled using the "hot_log" Cargo feature. By doing this, we can disable logging statements on hot paths in mmtk-core, only, without affecting log statements in other crates. It also allow developers to use logs in release builds in order to debug the performance.TODO:
RUST_LOG
towarn
ifinfo
is still too verbose.