-
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
Conversation
@@ -1105,6 +1105,7 @@ lazy val `persistance` = (project in file("lib/java/persistance")) | |||
frgaalJavaCompilerSetting, | |||
Compile / javacOptions := ((Compile / javacOptions).value), | |||
libraryDependencies ++= Seq( | |||
"org.slf4j" % "slf4j-api" % slf4jVersion, |
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...
" {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 comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the {0} {1} {2}
format doesn't work with sfl4j
. Sad outcome of using two different logging system throughout the project.
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.
I believe the correct way to do this in slf4j is just use empty brackets {}
instead of {0}
. As an example, look into
Line 160 in c109886
"Failed to delete the database file. Attempt #{}. File does not exist [{}].", |
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.
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 comment
The 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 log.debug
method is called even if the DEBUG is disabled.
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.
It is fine for this case.
Yes, it is absolutely fine in this case as we know we are going to log.
I can execute Enso with enso$ JAVA_OPTS=-Dorg.enso.persist.Logger.level=debug ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --run test/Base_Tests/
==== Top Bytes & Counts of Classes =====
39037 844 org.enso.compiler.core.ir.Name$Literal
11480 2 scala.collection.mutable.HashMap
8592 716 scala.collection.immutable.Set$Set1
7464 622 org.enso.compiler.core.ir.IdentifiedLocation
7336 80 org.enso.compiler.data.BindingsMap$ResolvedImport
7188 84 org.enso.compiler.core.ir.expression.Application$Prefix
7155 163 org.enso.compiler.data.BindingsMap$ModuleReference$Abstract
6844 90 org.enso.compiler.core.ir.CallArgument$Specified
6376 80 org.enso.compiler.core.ir.module.scope.Import$Module
4474 167 org.enso.compiler.pass.analyse.AliasAnalysis$Graph$Occurrence$Use
3135 627 org.enso.compiler.pass.analyse.DataflowAnalysis$DependencyInfo$Type$Static
2425 164 org.enso.compiler.pass.analyse.DataflowAnalysis$DependencyInfo$Type$Dynamic
2200 91 org.enso.compiler.pass.analyse.AliasAnalysis$Graph$Scope
2040 170 org.enso.compiler.pass.analyse.AliasAnalysis$Info$Occurrence
1640 82 scala.collection.immutable.Set$Set2
1520 95 org.enso.compiler.pass.analyse.AliasAnalysis$Info$Scope$Child
1264 158 org.enso.compiler.data.BindingsMap$Resolution
1264 158 org.enso.compiler.data.BindingsMap$ResolvedModule
1260 3 scala.collection.immutable.HashSet
1097 78 org.enso.compiler.data.BindingsMap$ResolvedMethod
1052 263 org.enso.compiler.pass.analyse.CachePreferenceAnalysis$WeightInfo
895 3 org.enso.compiler.core.ir.Expression$Block
684 1 org.enso.compiler.data.BindingsMap
224 2 org.enso.compiler.core.ir.Expression$Binding
202 2 org.enso.compiler.core.ir.Function$Lambda
181 21 java.lang.String
168 6 scala.collection.immutable.Set$Set3
154 1 org.enso.compiler.core.ir.module.scope.definition.Method$Explicit
97 1 org.enso.compiler.core.ir.DefinitionArgument$Specified
84 3 org.enso.compiler.pass.analyse.AliasAnalysis$Graph$Occurrence$Def |
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.
Maybe use logger.log("Hello {}", name)
instead of string concatenation. Just a minor note though.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Whether or not we will log is decided up-front before creating new Histogram()
. Once the instance is created, it is clear we will log whatever it will have collected at the end.
Pull Request Description
Fixes #8644 by using
slf4j
instead ofjava.util.logging
.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,