Open Bug 1681338 Opened 4 years ago Updated 11 days ago

Support Resuming in Warp compiled Async Functions and Generators

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mgaudet, Unassigned)

References

Details

(Whiteboard: [sp3])

(Opening this bug without committing to implementing it. We'll need some empirical evidence this would be valuable to implement)

The implementation of Warp-compiled async functions being developed in Bug 1680602 (and generators in Bug 1681336) is not total support.

The only way to re-enter a Warp compiled generator or async function is to OSR in. This means that after the first yield, we'll run in Baseline until our next opportunity to OSR. This simplification made it substantially easier to implement generators and async functions in Warp, but does mean that a hypothetical function like

function* foo() { 
  var result;
  for ( ... ) { 
    // compute expensive result
  } 
  yield result;

  for (...) { 
    // compute expensive second result
  } 
  yield result; 
}

We will only execute one of the bodies in warp at best, as we only support one OSR entry.

The way to solve this once and for all would be to allow JSOp::Resume to materialize a warp frame and start execution after a yield, in parallel to how Resume is able to do that for Baseline.

Severity: -- → N/A
Priority: -- → P3

Some data points about this:

I patched a copy of SM to keep track of a count of how many times we execute AfterYield when the script has an associated Warp script.

  • JetStream2: Basic has 2,437,181 missed opportunities for entering a warp script.
  • JetStream2 async-fs has 72,299 missed opportunities for entering a warp script.

These are the only two benchmarks where the Warp Generators / Warp Async code is really in effect. Despite the big headline numbers, I suspect that we'd -only- be improving benchmarks in the short term.

My current preference is to leave this until we see some real world desire for it. Implementing resume in Warp is potentially fraught and time intensive, and I know we have other things we can work on in the short term.

See Also: → 1745865
Summary: Support Resuming in Warp compiled Async Functions → Support Resuming in Warp compiled Async Functions and Generators
Blocks: 1839078
Whiteboard: [sp3]
See Also: → 1874632
You need to log in before you can comment on or make changes to this bug.