apache / dubbo-getty

a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Apache License 2.0
218 stars 69 forks source link

fix: add read buffer collection option #75

Closed LaurenceLiZhixin closed 2 years ago

LaurenceLiZhixin commented 2 years ago

What this PR does: Create an option to let user define if the session would collect read buffer.

if s.readBufferCollectionOpen {
        pktBuf = gxbytes.GetBytesBuffer()
    } else {
        pktBuf = new(bytes.Buffer)
    }

    defer func() {
        gxbytes.PutBytes(bufp)
        if s.readBufferCollectionOpen {
            gxbytes.PutBytesBuffer(pktBuf)
        }
    }()

Consider the case for TCP conn that sometimes pass large data. If the large Buffer is collected, other TCP conn will be polluted, resulting in large buffers received by other TCP coon, and take up a large scale of memeory.

codecov-commenter commented 2 years ago

Codecov Report

Merging #75 (cb1b367) into master (917228c) will increase coverage by 0.20%. The diff coverage is 91.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #75      +/-   ##
==========================================
+ Coverage   69.14%   69.34%   +0.20%     
==========================================
  Files           8        8              
  Lines        1426     1442      +16     
==========================================
+ Hits          986     1000      +14     
- Misses        347      348       +1     
- Partials       93       94       +1     
Impacted Files Coverage Δ
session.go 70.10% <81.81%> (-0.18%) :arrow_down:
client.go 71.86% <100.00%> (+0.32%) :arrow_up:
options.go 83.01% <100.00%> (+2.16%) :arrow_up:
server.go 68.23% <100.00%> (+0.34%) :arrow_up:

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 917228c...cb1b367. Read the comment docs.