almond icon indicating copy to clipboard operation
almond copied to clipboard

Notebook hangs when top-level variable modified repeatedly

Open ajrnz opened this issue 2 years ago • 0 comments

Create a notebook with two cells (two cells are required):

var funcCount = 0L

def fastLoop() = {
  funcCount += 1
}

and

for(i <- Iterator.range(0,1000)) {
  fastLoop()
}

Evaluate the first cell once and then the second cell several times. It will hang after a few tries (or just make the number bigger).

I'm not exactly sure what is happening but it appears that the kernel is generating lots of messages when the variable is modified and something is breaking under the hood to do with queues. I've seen the messages of the form

2022-10-13 12:37:49.737 ServerApp] IOPub message rate exceeded.

but increasing ServerApp.iopub_msg_rate_limit didn't solve the problem. Either way, this should not be generating any messages or it will result in a significant performance problem (which is how I came across it).

If I replace the top-level variable with a class and modify a member the problem goes away. If I put both statements in the same cell the problem goes away.

Maybe related to #549 and #768

Tested under: Almond 0.13.1 Ammonite 2.5.4-13-1ebd00a6 Scala 2.13.8 Java 8 & 17

ajrnz avatar Oct 13 '22 13:10 ajrnz