-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Geofiles: Implement mmap in filesystem to reduce ram usage #5480
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
Conversation
|
我觉得这么点东西用runtime包的OS判断一下就好 |
Tested and works. I will change it to runtime. |
seems only works when separated, syscall.Mmap not exist in windows and wasm. |
00409be to
d66d752
Compare
|
好吧 我还以为会有类似 panic("not implemented") 之类的东西 |
|
|
|
可以少一次把文件load进内存 会少一些 但是后续proto的解析还是会全部读进来 有时候启动时峰值会莫名其妙上一两百 这是一份十几二十的file造不出来的 我也不知道哪来的 最终大概还是geo file的设计问题 用proto message少不了一整个放进内存读一会( |
我早写了先找到需要的部分再 unmarshal,不用全解析啊,所以先把它们切成小文件那种做法意义也不大了,基本都不缺 ROM |
|
|
|
|
从调用里跳到test文件了 里面还是旧的看错了 不过一个简单写了geosite:cn和geoip:cn两座大山的config峰值内存(VmHWM)还真是123136 kB |
|
没这么夸张吧你这像是全 unmarshal 了,我咋记得 unmarshal 且 build 后的 geosite:cn 就十几 MB,你看静置内存多少 |
|
静置只有40mb没啥问题 不然早炸缸了 |
|
但是 build 后的 geosite:cn 才十几 MB,unmarshal 后的 proto 更紧凑只会占用更少啊,你这峰值内存顶天 50MB 才对 |
|
我不知道 别打我( 命令是 |
|
|
|
但是这个方法针对每个处理器架构都要搞一次,还好 iOS 都是 darwin arm64,@hossinasaadi 下一步可以试试这个
|
这不是 把自己手动放进swap 会变慢的( |
|
btw 这还算小问题 毕竟人们可以使用精简geofile或者减少路由条目 最近看到最多的complain是xhttp吃的ram太多无法在ios使用 |
|
|
|
我也看到了,可能因为 packet-up 上行自带缓存吧,因为可能有自动重传 之前 iOS 还有一个问题是没 TUN,现在 TUN 也快有了, |
load geo assets use mmap to reduce memory usage in ios #4422
and also no need to chunk geo files to smaller assets. #4422 (comment)