Open Bug 1538053 Opened 5 years ago Updated 2 years ago

Schedule nursery GC and slices around requestAnimationFrame

Categories

(Core :: JavaScript: GC, enhancement, P3)

enhancement

Tracking

()

Performance Impact low

People

(Reporter: pbone, Unassigned)

References

(Blocks 2 open bugs)

Details

(Keywords: perf:responsiveness)

If there are active callbacks for requestAnimationFrame then it'd be nice we we alter GC behavior to fit into the animation loop. IMHO we should:

  • Maybe collect the nursery with each frame, if it's not going to tenure
    things too much.
  • Run a slice of an incermental collection if one is active.
  • Give both of these a budget determined by the budget left for this frame.

While we can control slice budgets directly, we cannot control the budget for a minor GC. However I proposed Bug 1397549 which could be used to do this.

Is requestAnimationFrame the only way that JS can create animation loops?

Actually, nursery collection should use the same logic as idle time nursery collection, maybe with a lower threshold. But in this case the goal is to deliberately use spare time at the end of a frame and avoid a longer collection in some other frame which we mightn't have the budget for. Maybe something like.

"Last time we collected the nursery it took 3ms, we have > 3ms+some margin left in this frame and the nursery is >50% full so collect the nursery now." Or "we have less than 3ms left this frame, don't collect the nursery and maybe we'll get it next frame if there's more time left then"

Whiteboard: [qf?] → [qf:p3:responsiveness]
Blocks: 1530397
Performance Impact: --- → P3
Whiteboard: [qf:p3:responsiveness]
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.