summaryrefslogtreecommitdiffhomepage
path: root/pkg/abi/linux/file.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-02-08 15:47:25 -0800
committerShentubot <shentubot@google.com>2019-02-08 15:48:23 -0800
commite884168e1ea5cd8be4d50c85a4ad4fbcdaca1e5c (patch)
tree15a4899c3a75b9a153ac2aedcb32fe468abea875 /pkg/abi/linux/file.go
parent967326131a875047c2b2d51bf4b2984ceefd4730 (diff)
Encode stat to bytes manually, instead of calling CopyObjectOut.
CopyObjectOut grows its destination byte slice incrementally, causing many small slice allocations on the heap. This leads to increased GC and noticeably slower stat calls. PiperOrigin-RevId: 233140904 Change-Id: Ieb90295dd8dd45b3e56506fef9d7f86c92e97d97
Diffstat (limited to 'pkg/abi/linux/file.go')
-rw-r--r--pkg/abi/linux/file.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/abi/linux/file.go b/pkg/abi/linux/file.go
index ae33f4a4d..e5a51a9fd 100644
--- a/pkg/abi/linux/file.go
+++ b/pkg/abi/linux/file.go
@@ -19,6 +19,7 @@ import (
"strings"
"gvisor.googlesource.com/gvisor/pkg/abi"
+ "gvisor.googlesource.com/gvisor/pkg/binary"
)
// Constants for open(2).
@@ -177,6 +178,9 @@ type Stat struct {
X_unused [3]int64
}
+// SizeOfStat is the size of a Stat struct.
+var SizeOfStat = binary.Size(Stat{})
+
// FileMode represents a mode_t.
type FileMode uint