Skip to content

Commit 1f763f7

Browse files
authored
Disable visualizations for subexpressions (#11949)
The possibility of attaching visualizations to subexpressions meant that we (currently) have to invalidate caches for their parent expression every time a request comes. That was an acceptable cost when an expression is relatively fast to compute but unacceptable when dealing with slow computations that would have to be repeated. Since currently attaching visualizations is not used at all and we can rely on caching RHS and self, it is _safe_ to disable it. An observable pattern is better suited for visualizations and would mitigate this problem by design, something that we planned for a while in #10525 Should help with long running visualizations in #11882. Partial visualization results should be addressed on GUI side. # Important Notes For the example in #11882 we would at least re-read the large file at least twice, which adds 40-60seconds to the overall startup. Exchanges before the change: ![Screenshot from 2024-12-27 16-52-46](https://github.com/user-attachments/assets/63e7a6db-73f8-48dd-a24a-a44e197e4ee6) Responses after the change: ![Screenshot from 2024-12-30 12-18-28](https://github.com/user-attachments/assets/08020b1c-58f0-4c0f-b06d-1d904373b946) Results in the same (final) data: ![Screenshot from 2024-12-30 12-24-02](https://github.com/user-attachments/assets/280f6ef5-6691-4744-b67a-2a0898f55b8b)
1 parent bc6a8aa commit 1f763f7

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/execution/JobExecutionEngine.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ final class JobExecutionEngine(
9696
assertInJvm(timeSinceRequestedToCancel > 0)
9797
val timeToCancel =
9898
forceInterruptTimeout - timeSinceRequestedToCancel
99+
assertInJvm(timeToCancel > 0)
99100
logger.log(
100101
Level.FINEST,
101102
"About to wait {}ms to cancel job {}",
@@ -107,7 +108,8 @@ final class JobExecutionEngine(
107108
runningJob.future.get(timeToCancel, TimeUnit.MILLISECONDS)
108109
logger.log(
109110
Level.FINEST,
110-
"Job {} finished within the allocated soft-cancel time"
111+
"Job {} finished within the allocated soft-cancel time",
112+
runningJob.id
111113
)
112114
} catch {
113115
case _: TimeoutException =>

engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/EnsureCompiledJob.scala

+2
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ class EnsureCompiledJob(
484484
)
485485
invalidatedVisualizations.foreach { visualization =>
486486
UpsertVisualizationJob.upsertVisualization(visualization)
487+
// Cache invalidation disabled because of #11882
488+
// ctx.state.executionHooks.add(InvalidateCaches(visualization.expressionId))
487489
}
488490
if (invalidatedVisualizations.nonEmpty) {
489491
ctx.executionService.getLogger.log(

engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ object ProgramExecutionSupport {
9494

9595
val onComputedValueCallback: Consumer[ExpressionValue] = { value =>
9696
if (callStack.isEmpty) {
97-
logger.log(Level.FINEST, s"ON_COMPUTED ${value.getExpressionId}")
9897

9998
if (VisualizationResult.isInterruptedException(value.getValue)) {
99+
logger.log(Level.FINEST, s"ON_INTERRUPTED ${value.getExpressionId}")
100100
value.getValue match {
101101
case e: AbstractTruffleException =>
102102
sendInterruptedExpressionUpdate(
@@ -110,6 +110,7 @@ object ProgramExecutionSupport {
110110
case _ =>
111111
}
112112
}
113+
logger.log(Level.FINEST, s"ON_COMPUTED ${value.getExpressionId}")
113114
sendExpressionUpdate(contextId, executionFrame.syncState, value)
114115
sendVisualizationUpdates(
115116
contextId,

engine/runtime-instrument-common/src/main/scala/org/enso/interpreter/instrument/job/UpsertVisualizationJob.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class UpsertVisualizationJob(
121121
)
122122
None
123123
case None =>
124+
// Caching disabled due to #11882
125+
// ctx.state.executionHooks.add(InvalidateCaches(expressionId))
124126
Some(Executable(config.executionContextId, stack))
125127
}
126128
}
@@ -160,7 +162,7 @@ class UpsertVisualizationJob(
160162
object UpsertVisualizationJob {
161163

162164
/** Invalidate caches for a particular expression id. */
163-
sealed private case class InvalidateCaches(
165+
sealed case class InvalidateCaches(
164166
expressionId: Api.ExpressionId
165167
)(implicit ctx: RuntimeContext)
166168
extends Runnable {
@@ -511,7 +513,6 @@ object UpsertVisualizationJob {
511513
arguments
512514
)
513515
setCacheWeights(visualization)
514-
ctx.state.executionHooks.add(InvalidateCaches(expressionId))
515516
ctx.contextManager.upsertVisualization(
516517
visualizationConfig.executionContextId,
517518
visualization

engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeVisualizationsTest.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -4419,7 +4419,8 @@ class RuntimeVisualizationsTest extends AnyFlatSpec with Matchers {
44194419
new String(data1, StandardCharsets.UTF_8) shouldEqual "C"
44204420
}
44214421

4422-
it should "emit visualization update for the target of a method call (subexpression) with IdMap" in withContext() {
4422+
// Attaching visualizations to subexpressions is currently disabled, see #11882
4423+
ignore should "emit visualization update for the target of a method call (subexpression) with IdMap" in withContext() {
44234424
context =>
44244425
val contextId = UUID.randomUUID()
44254426
val requestId = UUID.randomUUID()

0 commit comments

Comments
 (0)