Conversation
|
ready to test. |
配置文件内 Routing 加个配置项来指定名称吧,同时也是开启该功能的标志,不然开多个 Xray 会炸,DNS 的你也看一下 |
|
@yiguodev libXray 或许需要更新 BuildDomainMatcherCache() |
|
本来以为 mmap 是把磁盘空间当运行内存用结果它确实是懒加载,不知道会不会像 swap,不过仍然 https://t.me/projectXtls/1384
有了这项优化,前面的 123 全被解决了, |
|
@iambabyninja 要测试的是这个 PR, |
a7f19fe to
be0263c
Compare
|
When use this PR (with XRAY_CACHED_MATCHER to prevent build Domains) on iOS memory decrease to 20MB (main branch 23-25MB). last changes (based on mmap) 15.5MB at start! |
|
我感觉这个 PR 还是可以有的,毕竟把前面的流程都跳过了,不过 mmap 对“降低跑代理时的总体内存占用”有帮助吗 |
没有 |
那感觉实际意义不大,如果本来就已经不会因为 peak memory usage 而炸掉的话 所以 #5581 (comment) 是什么原因 |
|
因为 core 要全部加载完所有配置,再启动核心 他的 pr 不是单纯的 mmap,而是那个把 geosite 下放到 core 启动时再读 |
In my tests, I did not use GeoIP or GeoSite in DNS, so DNS memory usage is not involved. |
I will remove it. |
|
能 config 的话就 config,把环境变量删了吧,dns 和 routing 内加个 config 就行了, |
oh , I removed config parameter not environment, also if we use env, so we can prevent the loadSite func to unmarshall the geo that increase memory in : Xray-core/infra/conf/router.go Lines 206 to 208 in 2c92339 |
|
加个简单的 ./xray command 来调用构建缓存 |
|
I agree. |
|
buildCache 改名 buildMphCache xray.mph.path 改成 xray.mph.cache |
|
文件也需要改名 buildmphcache.go |
|
现在的原理还是 #5488 (comment) 吧?也就是说只有非 Windows 能用, |
|
没用mmap 就是把前缀树构建结果保存下来下次不用从geosite编译了 |
|
|
The principle is still the same, but we no longer use mmap. |
|
准备合并了,更新一下 #5505 (comment) 的示例(环境变量和 command),或者你直接更新到 PR 正文吧 |
…of building from geosite.dat when Xray starts) (#5505) Like #5488 (comment)
|
https://t.me/projectXray/4631555 这个是因为没用到 geosite 的 rule 也要写 tag 吗, |
Of course, as I mentioned before, all routing rules and DNS entries must have tags, because all domain based rules will be cached, whether they come from geosite or not. |
I've implemented serialization for MphMatcherGroup and the memory usage decreased.
Same rules, This PR : 22 MB
Domain matcher cache now works across routing, DNS, and hosts.
It also useful for routers or devices with limited memory, benchmarks are included below.
#5488 (comment)
@RPRX @iambabyninja @mangustyura
Build the cache file :
1- required rules to have ruleTag :
{ "dns" : { "hosts" : { "geosite:cn" : "2.2.2.2", "cloudflare-dns.com" : [ .... "servers" : [ { "tag" : "dns1", // important "address" : "8.8.8.8", "domains" : [ "geosite:cn" ], .... "routing" : { "rules" : [ { "domain" : [ "geosite:cn" ], "outboundTag" : "direct", "ruleTag" : "rule-1" // important }2- Sample command for pre-built domain matcher :
./xray buildMphCache -c config.json -o test.cachethen set
os.Setenv("XRAY_MPH_CACHE", "./domain.cache")orexport XRAY_MPH_CACHE=./domain.cache.Note: Your DNS servers and routing rules must have tags set, otherwise the cache won’t be used.
benchmark
Without MPHCache :
With MPHCache :