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

cacheKeyNormalize 存在性能问题 #624

Closed
1 task
fengmk2 opened this issue Dec 18, 2023 · 10 comments · Fixed by #625
Closed
1 task

cacheKeyNormalize 存在性能问题 #624

fengmk2 opened this issue Dec 18, 2023 · 10 comments · Fixed by #625
Assignees
Labels
bug Something isn't working

Comments

@fengmk2
Copy link
Member

fengmk2 commented Dec 18, 2023

image

node_modules/_tar@6.2.0@tar/lib/unpack.js
node_modules/_tar@6.2.0@tar/lib/normalize-unicode.js

长期方案

  • 使用 compressing 或者 tar-stream 代替
@fengmk2
Copy link
Member Author

fengmk2 commented Dec 18, 2023

@fengmk2
Copy link
Member Author

fengmk2 commented Dec 18, 2023

normalizeCache 的 key 每次 tar unpack 之后都会递增。
image

@fengmk2 fengmk2 self-assigned this Dec 18, 2023
@fengmk2 fengmk2 added the bug Something isn't working label Dec 18, 2023
@fengmk2
Copy link
Member Author

fengmk2 commented Dec 18, 2023

fengmk2 added a commit to fengmk2/node-tar that referenced this issue Dec 18, 2023
fengmk2 added a commit to fengmk2/node-tar that referenced this issue Dec 18, 2023
fengmk2 added a commit that referenced this issue Dec 18, 2023
@fengmk2
Copy link
Member Author

fengmk2 commented Dec 18, 2023

https://github.com/node-modules/compressing/blob/master/package.json#L48C6-L48C16 呃,难怪以前没有出现过这个问题

fengmk2 added a commit that referenced this issue Dec 18, 2023
@fengmk2 fengmk2 reopened this Dec 18, 2023
@fengmk2
Copy link
Member Author

fengmk2 commented Dec 18, 2023

ezm headdump 也抓到了
image

@barretlee
Copy link

barretlee commented Dec 21, 2023

从内网之前的分析来看,堆内内存占用并不大,主要是堆外占用很大,而堆外大部分都是碎片内存。

也就是说,在 unpack 之后,在 normalizeCache 对象储存了大量的 key-value 对,但是由于存在少量 key/value 仍然被后续的程序使用(猜测)导致整个 normalizeCache 对象都没有被释放,这里说的没释放是没有释放给系统,被 ptmalloc 的 main arena 给保留了,原因是 top chunk 附近存在未回收内存。

经历了多次 unpack 后,堆外内存就暴涨了。泄露的不是 heap,是 mm 区。

@fengmk2
Copy link
Member Author

fengmk2 commented Dec 21, 2023

从内网之前的分析来看,堆内内存占用并不大,主要是堆外占用很大,而堆外大部分都是碎片内存。

也就是说,在 unpack 之后,在 normalizeCache 对象储存了大量的 key-value 对,但是由于存在少量 key/value 仍然被后续的程序使用(猜测)导致整个 normalizeCache 对象都没有被释放,这里说的没释放是没有释放给系统,被 ptmalloc 的 main arena 给保留了,原因是 top chunk 附近存在未回收内存。

经历了多次 unpack 后,堆外内存就暴涨了。因此泄露的不是 heap。

这个不是的,这个是真的 heap 泄漏,js 代码实现问题。

@barretlee
Copy link

这个不是的,这个是真的 heap 泄漏,js 代码实现问题。

那就是存在不止一个问题咯

@fengmk2
Copy link
Member Author

fengmk2 commented Dec 31, 2023

RSS 内存泄漏 https://zhuanlan.zhihu.com/p/675317993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants