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

[Feature Request] 改进 prepare 阶段的性能问题 #12224

Closed
sorrycc opened this issue Mar 22, 2024 · 3 comments · Fixed by #12324
Closed

[Feature Request] 改进 prepare 阶段的性能问题 #12224

sorrycc opened this issue Mar 22, 2024 · 3 comments · Fixed by #12324

Comments

@sorrycc
Copy link
Member

sorrycc commented Mar 22, 2024

Background

image

某个非典型项目,执行 umi setup,总耗时 1m6s,其中 1m1s 的时间都在做 deepClone。

注释掉这段代码的前后对比。

image

代码在 https://github.com/umijs/umi/blob/a278fad/packages/preset-umi/src/features/prepare/prepare.ts#L23

Proposal

应该不需要做 deep clone。

@fz6m
Copy link
Contributor

fz6m commented Mar 22, 2024

这里 clone 后续把 file.contents 删了,如果不 clone 的话,其他用 prepare 钩子的函数里这个 buildResult 参数里面就没有 contents 了,所以目测得想个其他的方法,另外 delete 其实也是比较耗性能的操作。

@stormslowly
Copy link
Member

这部分的信息只有 mfsu 在用,可以直接用引用;删除 content 的初衷估计想尽快释放这部分的内存。如果一直挂在 appData 上相当于多存了一份代码。

@xusd320
Copy link
Contributor

xusd320 commented Apr 23, 2024

yuyanAssets watch mode, 进入到 mako bundler 之前 delay 3s, mako bundler 反而能快个 2s 多,也是这个 deepClone 造成的

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 a pull request may close this issue.

4 participants