puerts icon indicating copy to clipboard operation
puerts copied to clipboard

探索指针压缩特性(v8_enable_pointer_compression = true)的使用,可节省可观的内存

Open chexiongsheng opened this issue 2 years ago • 14 comments

detail | 详细描述

目前puerts所用的v8的指针压缩是禁用了(v8_enable_pointer_compression = false),而官方宣称其开启可以节省40%内存,原理是将64bit的指针,通过相对偏移量,压缩到了32bit。

某puerts unreal重度使用脚本项目,开启后实测(windows)内存占用从93.6M降到到67.1M,虽说没宣传那么多,但也十分可观,值得一试。

开启方式

  • v8编译加入v8_enable_pointer_compression = true
  • 使用v8的c++代码,要加入V8_COMPRESS_POINTERS宏编译

chexiongsheng avatar Apr 12 '23 03:04 chexiongsheng

指针压缩:https://v8.js.cn/blog/pointer-compression/

chexiongsheng avatar Apr 23 '23 05:04 chexiongsheng

目前已知的问题:由于开启v8_enable_pointer_compression后,v8需要预留一大块内存(8G),所以ios下签名需要开启increased-memory-limit(ios15才支持),否则会挂(启动报OOM)。而低端android机器不知道是否有影响。

chexiongsheng avatar Apr 23 '23 09:04 chexiongsheng

在v8 11.8下面,如果要开启指针压缩(只测试了PC平台) v8编译需要设置两个选项: v8_enable_pointer_compression = true (这个上面写过了) v8_enable_sandbox = false

然后使用v8的C++代码,也有两个宏需要设置: V8_COMPRESS_POINTERS (这个上面也写过了) V8_31BIT_SMIS_ON_64BIT_ARCH

zhaojunmeng avatar Jun 21 '24 03:06 zhaojunmeng