-
Notifications
You must be signed in to change notification settings - Fork 327
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 TruffleLogger bound to the engine to prevent illegal usage #8169
Conversation
private final RuntimeStubsGenerator stubsGenerator; | ||
|
||
TruffleCompilerContext(EnsoContext context) { | ||
this.context = context; | ||
this.compiler = context.getLogger(Compiler.class); | ||
this.serializationManager = context.getLogger(SerializationManager.class); | ||
this.compilerLogger = context.getLogger(Compiler.class); |
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 left this logger as-is as I haven't seen the same illegal state failures as with SerializationManager, potentially because (de-)serializationis is typically run in a separate thread. We could change it as well, I'm open for suggestions.
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 think we want to bound all loggers to engine. No need to have two getLogger
and getLoggerBoundToEngine
method.
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 don't see a reason to have getLogger
and getLoggerBoundToEngine
next to each other - especially when there is 1:1 mapping between Engine
and EnsoContext
.
private final RuntimeStubsGenerator stubsGenerator; | ||
|
||
TruffleCompilerContext(EnsoContext context) { | ||
this.context = context; | ||
this.compiler = context.getLogger(Compiler.class); | ||
this.serializationManager = context.getLogger(SerializationManager.class); | ||
this.compilerLogger = context.getLogger(Compiler.class); |
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 think we want to bound all loggers to engine. No need to have two getLogger
and getLoggerBoundToEngine
method.
engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java
Outdated
Show resolved
Hide resolved
...uments/src/test/java/org/enso/interpreter/test/instrument/AvoidIdInstrumentationTagTest.java
Show resolved
Hide resolved
Partial fix for Truffle logger crashes - context required log levels. With a suggested change of log level in `SerializationManager` `sbt:enso> runtime/testOnly *SerdeCompilerTest` now passes but `sbt:enso> runtime/test` ...will continue to fail in `SerdeCompilerTest`, which is really confusing.
TruffleLoggers bound to the context were problematic when being invoked in threads coming from a thread pool. By explicitly using a TruffleLogger that is bound to the engine we can prevent such illegal usage.
Logs were often sent to null outpu stream or `ByteArrayOutputStream`, ending up in a black hole. We want to see the logs above the specific level because they are relevant to debugging problems.
9fc5834
to
6bb7a45
Compare
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.
Using environment.getLogger(clazz)
seems like correct fix.
Pull Request Description
Using a
TruffleLogger
inSerializationManager
that is bound to the engine rather than the context prevents reaching an illegal state when using thread pools.Also cleaned up some tests for consistency.
To verify the fix
and run
sbt:enso> runtime/test
Closes #8147.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.