mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Replace os.File with fd.FD in fsgofer
os.NewFile() accounts for 38% of CPU time in localFile.Walk(). This change switchs to use fd.FD which is much cheaper to create. Now, fd.New() in localFile.Walk() accounts for only 4%. PiperOrigin-RevId: 244944983 Change-Id: Ic892df96cf2633e78ad379227a213cb93ee0ca46
This commit is contained in:
committed by
Shentubot
parent
df21460cfd
commit
908edee04f
@@ -167,6 +167,24 @@ func NewFromFile(file *os.File) (*FD, error) {
|
||||
return New(fd), nil
|
||||
}
|
||||
|
||||
// Open is equivallent to open(2).
|
||||
func Open(path string, openmode int, perm uint32) (*FD, error) {
|
||||
f, err := syscall.Open(path, openmode|syscall.O_LARGEFILE, perm)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return New(f), nil
|
||||
}
|
||||
|
||||
// OpenAt is equivallent to openat(2).
|
||||
func OpenAt(dir *FD, path string, flags int, mode uint32) (*FD, error) {
|
||||
f, err := syscall.Openat(dir.FD(), path, flags, mode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return New(f), nil
|
||||
}
|
||||
|
||||
// Close closes the file descriptor contained in the FD.
|
||||
//
|
||||
// Close is safe to call multiple times, but will return an error after the
|
||||
|
||||
+131
-99
File diff suppressed because it is too large
Load Diff
@@ -257,6 +257,8 @@ func createInterfacesAndRoutesFromNS(conn *urpc.Client, nsPath string, enableGSO
|
||||
return fmt.Errorf("unable to enable the PACKET_VNET_HDR option: %v", err)
|
||||
}
|
||||
link.GSOMaxSize = ifaceLink.Attrs().GSOMaxSize
|
||||
} else {
|
||||
log.Infof("GSO not available in host.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user