summaryrefslogtreecommitdiffhomepage
path: root/pkg/p9/client.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-04-29 15:32:45 -0700
committerShentubot <shentubot@google.com>2019-04-29 15:33:47 -0700
commitddab854b9a895603664fa4abfa525f6a29047083 (patch)
tree349b428a042c7e7e0d7de71e56a319f7df3ae29b /pkg/p9/client.go
parent4d52a5520101a88424fb63dd99412a1db33fbd06 (diff)
Reduce memory allocations on serving path
Cache last used messages and reuse them for subsequent requests. If more messages are needed, they are created outside the cache on demand. PiperOrigin-RevId: 245836910 Change-Id: Icf099ddff95df420db8e09f5cdd41dcdce406c61
Diffstat (limited to 'pkg/p9/client.go')
-rw-r--r--pkg/p9/client.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/p9/client.go b/pkg/p9/client.go
index 2f9c716d0..56587e2cf 100644
--- a/pkg/p9/client.go
+++ b/pkg/p9/client.go
@@ -110,16 +110,16 @@ type Client struct {
// You should not use the same socket for multiple clients.
func NewClient(socket *unet.Socket, messageSize uint32, version string) (*Client, error) {
// Need at least one byte of payload.
- if messageSize <= largestFixedSize {
+ if messageSize <= msgRegistry.largestFixedSize {
return nil, &ErrMessageTooLarge{
size: messageSize,
- msize: largestFixedSize,
+ msize: msgRegistry.largestFixedSize,
}
}
// Compute a payload size and round to 512 (normal block size)
// if it's larger than a single block.
- payloadSize := messageSize - largestFixedSize
+ payloadSize := messageSize - msgRegistry.largestFixedSize
if payloadSize > 512 && payloadSize%512 != 0 {
payloadSize -= (payloadSize % 512)
}