Skip to content

fix: use lru-cache lib to improve alive minApp #8187

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

kovsu
Copy link
Contributor

@kovsu kovsu commented Jul 16, 2025

Related: #8160 (comment)

@alephpiece 现在这样是不是就可以了(不好意思又 ping 你了 😂

Electron.mp4

@GeorgeDong32 GeorgeDong32 added this to the v1.5.0 milestone Jul 16, 2025
@0xfullex
Copy link
Collaborator

这个库820kb

@0xfullex 0xfullex removed this from the v1.5.0 milestone Jul 16, 2025
@0xfullex 0xfullex added the Pending On hold due to priority/low, unresolved issues, suboptimal solution or needs more research label Jul 16, 2025
@0xfullex
Copy link
Collaborator

先把原来出错的pr revert掉,这个再慢慢看

@alephpiece
Copy link
Collaborator

这个库820kb

这个库应该是我之前重构代码块的时候就引入了😂

@alephpiece
Copy link
Collaborator

image

@0xfullex
Copy link
Collaborator

这个库820kb

这个库应该是我之前重构代码块的时候就引入了😂

那还好。这个测试就交给你看看了

@alephpiece
Copy link
Collaborator

这个库820kb

这个库应该是我之前重构代码块的时候就引入了😂

那还好。这个测试就交给你看看了

#4167 当时做代码块缓存的时候引入了,后来虽然移除了这个缓存,重构shiki高亮的时候又用上了😂

@alephpiece
Copy link
Collaborator

收到

@kovsu kovsu requested a review from alephpiece July 16, 2025 06:43
@alephpiece
Copy link
Collaborator

@0xfullex
Copy link
Collaborator

这个1.5.0就先不上了,不着急,弄好先
我把之前的有问题的先revert掉

@0xfullex 0xfullex removed the Pending On hold due to priority/low, unresolved issues, suboptimal solution or needs more research label Jul 16, 2025
@alephpiece alephpiece added the needs-review the feature/bug/pr needs a product/development reviewing label Jul 18, 2025
@alephpiece
Copy link
Collaborator

打开多个小程序后,直接进设置里把小程序缓存数量减少,会crash

image

@GeorgeDong32
Copy link
Collaborator

数量增加也有uncaught error
image

@GeorgeDong32 GeorgeDong32 self-requested a review July 18, 2025 10:50
@kovsu
Copy link
Contributor Author

kovsu commented Jul 18, 2025

@alephpiece @GeorgeDong32 麻烦两位再看看

@alephpiece
Copy link
Collaborator

这还有个 warning
https://github.com/CherryHQ/cherry-studio/pull/8187/files#annotation_36839243404

刚才又遇到一次崩溃,不过现在我没法复现了😂

if (minAppsCache.size <= maxKeepAliveMinapps) {
const oldEntries = Array.from(minAppsCache.entries())
minAppsCache = createLRUCache()
oldEntries.forEach(([key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里好像会导致LRU cache翻转,活跃的小程序反而会被最先出缓存

Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 Jul 19, 2025

Choose a reason for hiding this comment

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

开了几个小程序之后调整小程序最大数量即可复现

PixPin_2025-07-19_21-30-51

Copy link
Contributor Author

Choose a reason for hiding this comment

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

脑子转不过来hhhh。看来要从后往前set

Copy link
Collaborator

Choose a reason for hiding this comment

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

感觉是不是可以把 miniapp cache 的逻辑拆出来,作为一个小 service,utils 什么的,然后加些测试

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我觉的先把这个做完 然后把 整个 lru-cache 的包去掉,自己定义 LRU 的逻辑

@kovsu kovsu requested a review from GeorgeDong32 July 19, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review the feature/bug/pr needs a product/development reviewing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants