Skip to content
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

Shard hub to reduce lock contention #184

Merged
merged 5 commits into from
Feb 25, 2021
Merged

Shard hub to reduce lock contention #184

merged 5 commits into from
Feb 25, 2021

Conversation

FZambia
Copy link
Member

@FZambia FZambia commented Feb 24, 2021

The benchmark added here shows 3x difference – but in practice, the effect can be larger a smaller depending on a use-case scenario (channel distribution, connect rate, number of cores etc).

1 shard:

go test -run xxx -bench BenchmarkHub_Contention
goos: darwin
goarch: amd64
pkg: github.com/centrifugal/centrifuge
cpu: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
BenchmarkHub_Contention-8   	    3283	    411077 ns/op

64 shards:

go test -run xxx -bench BenchmarkHub_Contention
goos: darwin
goarch: amd64
pkg: github.com/centrifugal/centrifuge
cpu: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
BenchmarkHub_Contention-8   	    9630	    147781 ns/op

@codecov
Copy link

codecov bot commented Feb 25, 2021

Codecov Report

Merging #184 (d1d022b) into master (aa6f7c3) will increase coverage by 0.09%.
The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #184      +/-   ##
==========================================
+ Coverage   83.16%   83.26%   +0.09%     
==========================================
  Files          33       33              
  Lines        4361     4393      +32     
==========================================
+ Hits         3627     3658      +31     
- Misses        467      471       +4     
+ Partials      267      264       -3     
Impacted Files Coverage Δ
hub.go 85.15% <96.87%> (+4.28%) ⬆️
broker_redis.go 73.12% <0.00%> (-0.86%) ⬇️
metrics.go 86.53% <0.00%> (-0.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa6f7c3...d1d022b. Read the comment docs.

@FZambia FZambia merged commit 4891646 into master Feb 25, 2021
@FZambia FZambia deleted the sharded_hub branch February 25, 2021 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant