smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.08k stars 1.16k forks source link

Smmoth_round_roubine:Performance improvement #836

Closed blight19 closed 8 months ago

blight19 commented 8 months ago

update smmoth_round_roubine

rewrite this part code. when initional i calc the server's weight ,and then add them to a ring. and then select the server ,only get it from ring. benchmark from

goos: linux
goarch: amd64
pkg: github.com/smallnest/rpcx/client
cpu: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx  
BenchmarkWeightedRoundRobinSelector_Select
BenchmarkWeightedRoundRobinSelector_Select-8    52450845             19.27 ns/op

to

goos: linux
goarch: amd64
pkg: github.com/smallnest/rpcx/client
cpu: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx  
BenchmarkWeightedRoundRobinSelector_Select
BenchmarkWeightedRoundRobinSelector_Select-8    384278872            3.044 ns/op

but i think it shuod add a rwlock, old code didn't use it .

blight19 commented 8 months ago

i add a s.buildRing() when call UpdateServer to fix it.