reuse proxy.Request and redis.Resp in proxy #1561
Open
Conversation
|
谢谢。类似的方法其实我很早是写过的,自己维护一个 pool 而不是用 sync.Pool:
此外,Request{} 和 Resp{} 对象的大小被控制的足够小,go 对这种小对象分配足够快。并且,gc 的时候对象间不存在引用,gc 压力其实非常小的。 我建议你在生产环境中先进行足够长时间的测试,确定性能和堆的使用足够稳定。(至少爆堆我是经过压力测试后发现的,gc 不及时最后爆到大概100GB)。其实 codis 里面大量内存都在堆外分配,堆内 gc 的压力其实很小。 |
|
@spinlock soga,多谢提醒!我是在减小那个为了降低 GC 频率的 256M 预分配内存后想到的一个补偿方案 |
|
用 用 redis-benchmark 目前看性能没有明显变化,初衷是有时候业务部门会反应极其偶尔慢一下,想尽量减少 GC 的因素,这边先跑跑看看 :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
proxy 处理请求的过程中经常需要分配
proxy.Request和redis.Resp两种对象。这个 PR 通过sync.Pool进行了复用,应当可以降低GC压力。proxy.Requestandredis.Respis allocated most often in request processing. This PR try to reuse these objects usingsync.Poolwhich should reduce the GC pressure.