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: more cache #45302

Merged
merged 9 commits into from Oct 13, 2023
Merged

refactor: more cache #45302

merged 9 commits into from Oct 13, 2023

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Oct 12, 2023

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

resolve #45296

💡 Background and solution

在组件渲染时都会经过 CSS-in-JS 的 flatten token 逻辑,原实现为 useMemo 缓存,但是对于重新创建的 Node 而言,memo 总是会重新生成。而对于 CSS-in-JS 而言,相同 token 一定出相同的 flatten key,所以在跨组件之间可以复用

v4

截屏2023-10-12 17 49 39

Before

截屏2023-10-12 17 55 46

After

截屏2023-10-12 17 49 34

📝 Changelog

Language Changelog
🇺🇸 English Optimize CSS-in-JS Design Token cache matching.
🇨🇳 Chinese 优化 CSS-in-JS Design Token 缓存命中性能。

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

🤖 Generated by Copilot at 2142bb3

The pull request enhances the design token system of the ConfigProvider component and its related hooks and types. It introduces a new override prop that allows users to specify both alias tokens and component-specific tokens in one object. It also improves the code readability and consistency by refactoring some imports and types.

🔍 Walkthrough

🤖 Generated by Copilot at 2142bb3

  • Add override prop to DesignTokenProviderProps and defaultConfig to support customizing design tokens and component-specific tokens (link, link, link)
  • Simplify token prop in ConfigProvider by extracting mergedToken constant and passing it to override prop (link)
  • Reorder imports in index.tsx and useToken.ts to group related modules and follow alphabetical order (link, link)

@stackblitz
Copy link

stackblitz bot commented Oct 12, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2023

Preview Failed

Copy link
Member

@kiner-tang kiner-tang left a comment

Choose a reason for hiding this comment

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

没看出是怎么优化缓存命中性能的,@zombieJ ,可以解释一下实现思路吗?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2023

size-limit report 📦

Path Size
./dist/antd.min.js 397.91 KB (+42 B 🔺)
./dist/antd-with-locales.min.js 457.23 KB (+41 B 🔺)

@argos-ci
Copy link

argos-ci bot commented Oct 12, 2023

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No change detected - Oct 12, 2023, 2:06 PM

@afc163
Copy link
Member

afc163 commented Oct 12, 2023

有没有可测的 ci 性能数据?

@zombieJ
Copy link
Member Author

zombieJ commented Oct 12, 2023

有没有可测的 ci 性能数据?

CPU 时间片是不稳定的,~10ms 的变化机器卡一卡就会超。

@crazyair
Copy link
Member

有没有可测的 ci 性能数据?

CPU 时间片是不稳定的,~10ms 的变化机器卡一卡就会超。

如果要加测试,可以加组件加载卸载,token 执行次数

@zombieJ
Copy link
Member Author

zombieJ commented Oct 12, 2023

如果要加测试,可以加组件加载卸载,token 执行次数

嗯。不过这样要给 token 对象合成加钩子,打包的时候会留脏的空函数。不太建议为了测试,加这个损耗。

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (bf1b73e) 100.00% compared to head (e32d4d8) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #45302   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          692       692           
  Lines        11670     11671    +1     
  Branches      3117      3117           
=========================================
+ Hits         11670     11671    +1     
Files Coverage Δ
components/config-provider/index.tsx 100.00% <100.00%> (ø)
components/theme/context.ts 100.00% <ø> (ø)
components/theme/useToken.ts 100.00% <100.00%> (ø)

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

@zombieJ zombieJ merged commit 317dac6 into master Oct 13, 2023
91 of 92 checks passed
@zombieJ zombieJ deleted the cache branch October 13, 2023 03:54
@MadCcc MadCcc mentioned this pull request Oct 13, 2023
20 tasks
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.

antd5版本的tree组件虚拟列表滚动性能下降了
6 participants