]> Cypherpunks repositories - gostls13.git/commit
syscall: reduce redundant getwd tracking in Plan 9
authorRichard Miller <miller.research@gmail.com>
Wed, 28 Feb 2018 14:29:27 +0000 (14:29 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 28 Feb 2018 16:26:49 +0000 (16:26 +0000)
commita379b7d9acd69cd4a23eec7d7409084e15f8ace0
treea151d6bf033d9fdb3845b2370ef1e0f09fb79bfb
parentc2cdfbd1a75b74bf7b960f6904fcfaaad9edb708
syscall: reduce redundant getwd tracking in Plan 9

In Plan 9, each M is implemented as a separate OS process with
its own working directory.  To keep the wd consistent across
goroutines (or rescheduling of the same goroutine), CL 6350
introduced a Fixwd procedure which checks using getwd and calls
chdir if necessary before any syscall operating on a pathname.

This wd checking will not be necessary if the pathname is absolute
(starts with '/' or '#').  Getwd is a fairly expensive operation
in Plan 9 (implemented by opening "." and calling Fd2path on the
file descriptor).  Eliminating the redundant getwd calls can
significantly reduce overhead for common operations like
"dist test --list" which perform many syscalls on absolute pathnames.

Updates #9428.

Change-Id: I13fd9380779de27b0ac2f2b488229778d6839255
Reviewed-on: https://go-review.googlesource.com/97675
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
src/syscall/pwd_plan9.go
src/syscall/syscall_plan9.go