Closed Bug 1610682 Opened 4 years ago Closed 4 years ago

Eager evaluations doesn't recover from infinite loops

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(firefox74 fixed)

RESOLVED FIXED
Firefox 74
Tracking Status
firefox74 --- fixed

People

(Reporter: Harald, Assigned: loganfsmyth)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Attached image image.png

STR: With eager eval on type while (true); in Console

ER: Eager eval fails to run the loop and recovers gracefully.

AR: Browser locks up and slow-script dialog shows.

Logan, is it possible to guard against long-running scripts in the eager eval backend?

Flags: needinfo?(loganfsmyth)

What would also help here and might be useful for general performance – if a new eager eval request it could cancel the currently running one.

Would it make sense to put a timeout on all eager evaluation? I can't really see a case where we'd want any eager eval to be long-running. If it's that long, we'd probably want to just wait for the user to finish typing what they were typing anyway. Even if we just said all eager eval requests have to run in 20ms or less or something. I think that would be easier than trying to cancel an in-progress operation.

That said, it does surprise me that the slow-script dialog doesn't come up eventually, so I'm also curious why that's happening. I'll leave myself NIed for now to try to look into that.

Even if we just said all eager eval requests have to run in 20ms or less or something. I think that would be easier than trying to cancel an in-progress operation

I'd be in favor of that. It also caps overhead caused by eager eval.

That said, it does surprise me that the slow-script dialog doesn't come up eventually, so I'm also curious why that's happening. I'll leave myself NIed for now to try to look into that.

The dialog does come up, but I wasn't sure if it actually recovers. I think a few slow scripts queued up, so it's hard to pause effectively but it should work.

The dialog does come up, but I wasn't sure if it actually recovers.

Ahh gotcha. I'll have to check whether the console waits to dispatch an eager eval if the previous one is still running. If it doesn't, that's probably also a bug that we should file so that we don't accumulate a queue of things to eager-eval after we've stopped caring about the result.

Logan, to make the situation better for the initial release in 74; would you propose a short-term fix or is capping eager eval execution time something we could aim to include for 74? This assumes there is no better long-term fix, which is my understanding from the comments so far.

I can look into it, but honestly I don't know, most likely that would be a bit rushed at this point. I know that SpiderMonkey has some infrastructure for interrupting execution, but I've never tried to use them and I don't know how easy it will be set up a timer to do what I want to do.

Looked into this quickly and wrote a couple of helper functions fib(25) consistently takes ~70 ms, which would be a good candidate to be canceled:

function f(n) {
    if (n == 1 || n == 0) {
      return 1;
    }

    return f(n-1) + f(n-2)
}

function fib(m) {
  function f(n) {
    if (n == 1 || n == 0) {
      return 1;
    }

    return f(n-1) + f(n-2)
  }

  const startTime = new Date();   
  const r = f(m)
  const endTime = new Date(); 
  return [(endTime - startTime), r]
}
Assignee: nobody → loganfsmyth
Status: NEW → ASSIGNED
Pushed by loganfsmyth@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/ac19d46c04f9
Time out of eager evaluation after 100ms. r=jlast
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 74
Flags: needinfo?(loganfsmyth)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: