swiftwasm / swiftwasm/JavaScriptKit

Event loop scheduling improvement

未關閉
#282 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Swift
星號
986
分支
76
平均合併
21 小時 11 分鐘
30 天內合併 PR
4

描述

Motivation

Think the following situation:

  1. The browser event loop has a pending event that fires an event listener that schedules high-priority work to JSKit's executor.
  2. But the current JSKit's executor loop does not yield its control to JS event loop until all enqueued works are done
  • Even if some of them are low-priority

It resulted in the higher priority works planned to be enqueued to JSKit's executor are blocked by lower priority works that are already enqueued even though browser engine knows about the pending event.

Outcome

  • Performance gain

Potential solution

Although yielding control to JS engine for every Swift job is not a realistic approach due to high overheads, but it's still considerable to yield control when certain time is spent for the current JSKit's executor loop.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Sources/JavaScriptEventLoop/JobQueue.swift 中的執行器迴圈開始,尤其關注連結的部分,並追蹤排入佇列的 Swift 工作如何執行,以及控制權如何返回瀏覽器事件迴圈。定義並評估一種排程方法,使其在執行器執行達到有界時長後讓出執行權;透過顯示較高優先級的待處理工作不再被低優先級工作阻塞,並測量對效能的影響,來證明該方法已完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, swift, wasm
領域
performance, web-dev
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。