Skip to content
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

refactor(dev): 🔥 reduce ensure2 chunk map size #1707

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stormslowly
Copy link
Member

@stormslowly stormslowly commented Nov 28, 2024

the former installable_descendants_chunk returns almost all the chunk in this build.
sync_dependencies_chunk is the best choice and aligning with production behaviors

Summary by CodeRabbit

  • 新功能
    • 更新了模块依赖项的获取方式,增强了动态导入模块的依赖管理。

Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

Walkthrough

该变更主要涉及对 crates/mako/src/plugins/central_ensure.rsCentralChunkEnsure 插件的 module_ensure_map 函数的修改。主要变化是将方法 installable_descendants_chunk 重命名为 sync_dependencies_chunk,用于获取动态导入模块的依赖项。此外,代码现在在 sync_dependencies_chunk 的结果上调用 once(&chunk.id),确保当前块 ID 被包含在依赖列表中。函数的整体结构保持不变,错误处理和控制流也未显著改变。

Changes

文件路径 变更摘要
crates/mako/src/plugins/central_ensure.rs installable_descendants_chunk 方法重命名为 sync_dependencies_chunk,并在其结果上调用 once(&chunk.id)

Possibly related PRs

Suggested reviewers

  • xusd320

🐰 在块中跳跃,依赖如影随形,
方法重命名,代码更清晰。
依赖同步,确保不遗漏,
小兔子欢呼,变化真美妙!
🥕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Walkthrough

This pull request refactors the chunk map size reduction in the development environment. The change replaces the installable_descendants_chunk method with sync_dependencies_chunk, which aligns better with production behaviors by returning a more optimal set of chunks.

Changes

File Summary
crates/mako/src/plugins/central_ensure.rs Replaced installable_descendants_chunk with sync_dependencies_chunk and added chain(once(&chunk.id)) to include the current chunk ID in the dependencies.

@@ -32,8 +33,9 @@ pub fn module_ensure_map(context: &Arc<Context>) -> anyhow::Result<BTreeMap<Stri
.iter()
.for_each(|chunk| {
let deps_chunks = cg
.installable_descendants_chunk(&chunk.id)
.sync_dependencies_chunk(&chunk.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that sync_dependencies_chunk provides the expected chunk IDs. This change may affect the dependency resolution logic, so verify that it aligns with the intended production behavior.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
crates/mako/src/plugins/central_ensure.rs (1)

36-38: 优化: 减少 ensure2 chunk map 大小的改动

这个改动通过以下方式优化了依赖收集:

  1. 使用 sync_dependencies_chunk 替代了返回几乎所有 chunks 的 installable_descendants_chunk
  2. 通过 chain(once(&chunk.id)) 确保当前 chunk 被包含在依赖列表中

这样的改动更符合生产环境的行为,同时也能有效减少 chunk map 的大小。

建议添加单元测试来验证:

  1. chunk map 大小确实减少
  2. 动态导入的模块仍能正确加载
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b6f638d and a12b31f.

📒 Files selected for processing (1)
  • crates/mako/src/plugins/central_ensure.rs (2 hunks)

Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 55.28%. Comparing base (b6f638d) to head (a12b31f).

Files with missing lines Patch % Lines
crates/mako/src/plugins/central_ensure.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1707      +/-   ##
==========================================
- Coverage   55.28%   55.28%   -0.01%     
==========================================
  Files         175      175              
  Lines       17699    17700       +1     
==========================================
  Hits         9785     9785              
- Misses       7914     7915       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant