starwing / lua-protobuf

A Lua module to work with Google protobuf
MIT License
1.73k stars 387 forks source link

GC problem in decode #187

Closed rayss1 closed 2 years ago

rayss1 commented 2 years ago

环境: tolua lua:5.1

调用3000多次大概有110MB的gc decode 存在比较大的gc问题 这个有办法优化掉么

starwing commented 2 years ago

使用第三个参数复用表。

rayss1 @.***>于2022年3月19日 周六15:20写道:

环境: tolua lua:5.1

调用3000多次大概有110MB的gc decode 存在比较大的gc问题 这个有办法优化掉么

— Reply to this email directly, view it on GitHub https://github.com/starwing/lua-protobuf/issues/187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- regards, Xavier Wang.

rayss1 commented 2 years ago

使用第三个参数复用表。 rayss1 @.>于2022年3月19日 周六15:20写道: 环境: tolua lua:5.1 调用3000多次大概有110MB的gc decode 存在比较大的gc问题 这个有办法优化掉么 — Reply to this email directly, view it on GitHub <#187>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ . You are receiving this because you are subscribed to this thread.Message ID: @.> -- regards, Xavier Wang.

你好 感谢回复 试过了使用第三个参数复用表 gc从1.62KB 下降到1.4KB 这1.4K还有办法优化掉么

starwing commented 2 years ago

那你可以看下代码看看实 内存分配都在哪儿。pb本身是不会做内存分配的,分配的主要是提供给Lua的数据结构,比如说子消息等等,理论上长时间运行之后所有表都分配了最大的内存后就不会再分配了。另外注意repeated,你需要清空,默认的行为是往数组后面添加。

rayss1 @.***>于2022年3月19日 周六17:26写道:

使用第三个参数复用表。 rayss1 @. >于2022年3月19日 周六15:20写道: 环境: tolua lua:5.1 调用3000多次大概有110MB的gc decode 存在比较大的gc问题 这个有办法优化掉么 — Reply to this email directly, view it on GitHub <#187 https://github.com/starwing/lua-protobuf/issues/187>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ . You are receiving this because you are subscribed to this thread.Message ID: @.> -- regards, Xavier Wang.

你好 感谢回复 试过了使用第三个参数复用表 gc从1.62KB 下降到1.4KB 这1.4K还有办法优化掉么

— Reply to this email directly, view it on GitHub https://github.com/starwing/lua-protobuf/issues/187#issuecomment-1072976051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M4XZXQSC74ESNM7PI3VAWMT7ANCNFSM5RDUVOLQ . You are receiving this because you commented.Message ID: @.***>

-- regards, Xavier Wang.

rayss1 commented 2 years ago

那你可以看下代码看看实 内存分配都在哪儿。pb本身是不会做内存分配的,分配的主要是提供给Lua的数据结构,比如说子消息等等,理论上长时间运行之后所有表都分配了最大的内存后就不会再分配了。另外注意repeated,你需要清空,默认的行为是往数组后面添加。 rayss1 @.>于2022年3月19日 周六17:26写道: 使用第三个参数复用表。 rayss1 @. >于2022年3月19日 周六15:20写道: 环境: tolua lua:5.1 调用3000多次大概有110MB的gc decode 存在比较大的gc问题 这个有办法优化掉么 — Reply to this email directly, view it on GitHub <#187 <#187>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ https://github.com/notifications/unsubscribe-auth/AAA36M2P7LOUV2K6PDRSZWDVAV55VANCNFSM5RDUVOLQ . You are receiving this because you are subscribed to this thread.Message ID: @.> -- regards, Xavier Wang. 你好 感谢回复 试过了使用第三个参数复用表 gc从1.62KB 下降到1.4KB 这1.4K还有办法优化掉么 — Reply to this email directly, view it on GitHub <#187 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA36M4XZXQSC74ESNM7PI3VAWMT7ANCNFSM5RDUVOLQ . You are receiving this because you commented.Message ID: @.> -- regards, Xavier Wang.

是的 感谢大佬 我已经发现问题了,是socket那里每次读取都申请了buffer