berty / go-orbit-db

Go version of P2P Database on IPFS
https://berty.tech
Apache License 2.0
412 stars 56 forks source link

fix: change pubsub channels to be buffered channels #70

Closed phanhuynhquy closed 3 years ago

phanhuynhquy commented 4 years ago

Signed-off-by: phanquy phanhuynhquy@gmail.com

[Change Description]

Mainly of this ticket to improve stability of https://github.com/berty/berty/blob/master/go/pkg/bertyprotocol/scenario_test.go Because the implementation of low level (pubsub library) at: https://github.com/libp2p/go-libp2p-pubsub/blob/master/pubsub.go#L841:

for f := range subs {
            select {
            case f.ch <- msg:
            default:
                log.Infof("Can't deliver message to subscription for topic %s; subscriber too slow", topic)
            }
        }

By default f.ch has size is 32. So if too much of subscribed message come, new messages will be discarded, also with peer monitoring.

So I change channels in WatchPeers() and WatchMessages() to be buffered channel.

Notes: I tried to make this size is configurable, but if I use a variable - it seem that code not work - not sure why.

codecov[bot] commented 4 years ago

Codecov Report

Merging #70 into master will decrease coverage by 1.18%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
- Coverage   67.67%   66.49%   -1.19%     
==========================================
  Files          29       29              
  Lines        2410     2077     -333     
==========================================
- Hits         1631     1381     -250     
+ Misses        564      486      -78     
+ Partials      215      210       -5     
Flag Coverage Δ
#unittests 66.49% <100.00%> (-1.19%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pubsub/pubsubcoreapi/pubsub.go 74.02% <100.00%> (-2.32%) :arrow_down:
pubsub/pubsubraw/pubsub.go 79.03% <100.00%> (+1.25%) :arrow_up:
stores/operation/operation.go 76.47% <0.00%> (-6.87%) :arrow_down:
accesscontroller/utils/utils.go 36.00% <0.00%> (-4.75%) :arrow_down:
accesscontroller/manifest.go 71.60% <0.00%> (-4.40%) :arrow_down:
pubsub/oneonone/channel.go 67.21% <0.00%> (-4.22%) :arrow_down:
stores/kvstore/keyvalue.go 45.94% <0.00%> (-4.06%) :arrow_down:
utils/create_db_manifest.go 77.77% <0.00%> (-4.05%) :arrow_down:
events/events.go 79.62% <0.00%> (-3.71%) :arrow_down:
address/address.go 82.60% <0.00%> (-3.11%) :arrow_down:
... and 21 more

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 27b0d3d...e5a42bf. Read the comment docs.

github-actions[bot] commented 3 years ago

:tada: This PR is included in version 1.10.11 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: