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

[WIP]perf: nocopy read binary #1357

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/protocol/bthrift/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Binary protocol for bthrift.
Binary binaryProtocol
_ BTProtocol = binaryProtocol{}
spanCache = mem.NewSpanCache(1024 * 1024) // 1MB

Check failure on line 37 in pkg/protocol/bthrift/binary.go

View workflow job for this annotation

GitHub Actions / staticcheck

[staticcheck] reported by reviewdog 🐶 var spanCache is unused Raw Output: {"source":{"name":"staticcheck","url":"https://staticcheck.io"},"message":"var spanCache is unused","code":{"value":"U1000","url":"https://staticcheck.io/docs/checks#U1000"},"location":{"path":"/data00/runner/cloudwego-sg-runner-05/kitex/kitex/pkg/protocol/bthrift/binary.go","range":{"start":{"line":37,"column":2}}},"severity":"ERROR"}

Check failure on line 37 in pkg/protocol/bthrift/binary.go

View workflow job for this annotation

GitHub Actions / lint

var `spanCache` is unused (unused)
)

const binaryInplaceThreshold = 4096 // 4k
Expand Down Expand Up @@ -467,8 +467,7 @@
if size < 0 || int(size) > len(buf) {
return value, length, perrors.NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadString] the string size greater than buf length")
}
data := spanCache.Copy(buf[length : length+int(size)])
value = utils.SliceByteToString(data)
value = utils.SliceByteToString(buf[length : length+int(size)])
length += int(size)
return
}
Expand All @@ -484,7 +483,7 @@
if size < 0 || size > len(buf) {
return value, length, perrors.NewProtocolErrorWithType(thrift.INVALID_DATA, "[ReadBinary] the binary size greater than buf length")
}
value = spanCache.Copy(buf[length : length+size])
value = buf[length : length+size]
length += size
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/codec/thrift/binary_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ func (p *BinaryProtocol) ByteBuffer() remote.ByteBuffer {

// next ...
func (p *BinaryProtocol) next(size int) ([]byte, error) {
buf, err := p.trans.Next(size)
buf, err := p.trans.ReadBinary(size)
if err != nil {
return buf, perrors.NewProtocolError(err)
}
Expand Down
Loading