-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor: optimize queue job #4859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @GaoFuhong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the job queuing mechanism to improve performance and efficiency. By introducing task deduplication, the system avoids redundant processing of identical jobs within a single tick. Furthermore, the scheduling logic has been refined to leverage browser idle time more effectively and to ensure smoother execution across different environments, aiming for a more consistent 60 frames per second experience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
你好,感谢你对 JobQueue 的优化。这次重构通过引入 pendingJobs 来合并重复任务,显著减少了不必要的队列操作,从性能测试图来看效果很明显。在 flushJobs 中动态调整执行预算,以及在 scheduleJob 中增加 requestAnimationFrame 作为备用方案,都是非常棒的改进,提升了渲染的流畅性和环境兼容性。
代码整体质量很高,我只发现了一些小问题,主要是在 cancelScheduleJob 中有一个潜在的逻辑 bug,以及一处可以简化的代码。具体细节请看我的评论。
做得很好!
|
这类代码人工加单测,每个 pr 都注意加单测。之前批量 ai 加单测,其实单测质量、有效性不高的。 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4859 +/- ##
==========================================
- Coverage 81.94% 81.89% -0.05%
==========================================
Files 327 329 +2
Lines 38019 38044 +25
Branches 7637 7625 -12
==========================================
+ Hits 31153 31156 +3
- Misses 6841 6863 +22
Partials 25 25
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Description
主要改动:
pendingJobs,去重合并同一任务,对同一id的重复任务不再追加多条队列项,使用Map更新已存在任务的cb和priority。flushJobs()中在requestIdleCallback有timeRemaining()时优先使用剩余时间作为预算,否则才用帧预算frameInterval,把原来的frameInterval33 改为 16,更接近 60 fps。scheduleJob()中增加requestAnimationFrame,处理 Safari 等环境。试验对比:
Motivation and Context
Types of changes
Self Check before Merge