-
Notifications
You must be signed in to change notification settings - Fork 323
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
Log histograms with -Dorg.enso.persist.Logger.level=debug #8881
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -9,8 +9,7 @@ | |||
import java.util.IdentityHashMap; | ||||
import java.util.Map; | ||||
import java.util.function.Function; | ||||
import java.util.logging.Level; | ||||
import java.util.logging.Logger; | ||||
import org.slf4j.Logger; | ||||
|
||||
final class PerGenerator { | ||||
static final byte[] HEADER = new byte[] {0x0a, 0x0d, 0x03, 0x0f}; | ||||
|
@@ -31,7 +30,7 @@ private PerGenerator( | |||
} | ||||
|
||||
static byte[] writeObject(Object obj, Function<Object, Object> writeReplace) throws IOException { | ||||
var histogram = PerUtils.LOG.isLoggable(Level.FINE) ? new Histogram() : null; | ||||
var histogram = PerUtils.LOG.isDebugEnabled() ? new Histogram() : null; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whether or not we will log is decided up-front before creating |
||||
|
||||
var out = new ByteArrayOutputStream(); | ||||
var data = new DataOutputStream(out); | ||||
|
@@ -140,16 +139,14 @@ private void dump(Logger log, int length) { | |||
return a.getValue()[0] - b.getValue()[0]; | ||||
}); | ||||
|
||||
log.fine("==== Top Bytes & Counts of Classes ====="); | ||||
log.debug("==== Top Bytes & Counts of Classes ====="); | ||||
for (var i = 0; i < list.size(); i++) { | ||||
if (i == 30) { | ||||
break; | ||||
} | ||||
var elem = list.get(list.size() - 1 - i); | ||||
log.log( | ||||
Level.FINE, | ||||
" {0} {1} {2}", | ||||
new Object[] {elem.getValue()[0], elem.getValue()[1], elem.getKey().getName()}); | ||||
log.debug( | ||||
" " + elem.getValue()[0] + " " + elem.getValue()[1] + " " + elem.getKey().getName()); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the correct way to do this in slf4j is just use empty brackets Line 160 in c109886
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Concatenating strings manually relies on standard Java mechanism rather than relying on the logging framework semantics. As it is guaranteed the message is going to be printed, I opted for the generic mechanism known to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is fine for this case. But generally, you should avoid string concatenation for logs. If you do string concatenation, the concatenation is evaluated before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, it is absolutely fine in this case as we know we are going to log. |
||||
} | ||||
} | ||||
|
||||
|
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.
Bye, bye "no dependencies" of
lib/java/persitance
project...