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

Benchmark: fix build tags #2099

Merged
merged 9 commits into from
Jul 12, 2018
Merged

Conversation

lyuxuan
Copy link
Contributor

@lyuxuan lyuxuan commented May 22, 2018

some syscall and unix package functions/variables are not defined in environments like windows, darwin, etc.

Restrict to linux only.


This change is Reviewable

@lyuxuan lyuxuan requested a review from MakMukhi May 22, 2018 23:34
@menghanl
Copy link
Contributor

Those are all cpu time related syscalls.
We should move only that function to a separate file, and add build constraints to that file.

Or, since they are all the same function, we should move those to a separate internal/ package.

@dfawley dfawley assigned menghanl and unassigned lyuxuan Jun 28, 2018
@menghanl
Copy link
Contributor

Review status: 0 of 7 files reviewed, 2 unresolved discussions (waiting on @lyuxuan and @menghanl)


internal/benchmarkutil/benchmarkutil_linux.go, line 21 at r2 (raw file):

 */

package benchmarkutil

Name this package syscall?


internal/benchmarkutil/benchmarkutil_linux.go, line 44 at r2 (raw file):

// Getrusage returns the resource usage of current process.
func Getrusage(rusage *Rusage) {

Make this function return *Rusage instead?


Comments from Reviewable

@lyuxuan
Copy link
Contributor Author

lyuxuan commented Jun 29, 2018

Review status: 0 of 7 files reviewed, 2 unresolved discussions (waiting on @menghanl and @lyuxuan)


internal/benchmarkutil/benchmarkutil_linux.go, line 21 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…

Name this package syscall?

both syscall and unix package functions are included here.


internal/benchmarkutil/benchmarkutil_linux.go, line 44 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…

Make this function return *Rusage instead?

done


Comments from Reviewable

@menghanl
Copy link
Contributor

Review status: 0 of 7 files reviewed, 2 unresolved discussions (waiting on @menghanl)


internal/benchmarkutil/benchmarkutil_linux.go, line 21 at r2 (raw file):

Previously, lyuxuan wrote…

both syscall and unix package functions are included here.

What I was thinking is, this will be the grpc syscall package. Whenever there's a requirement for syscall in grpc, the code should go here.

unix should be considered as part of syscall. (And it's under x/sys)


Comments from Reviewable

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 8 files at r2, 6 of 6 files at r4.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @lyuxuan)


benchmark/server/main.go, line 35 at r4 (raw file):

	"google.golang.org/grpc/benchmark"
	"google.golang.org/grpc/grpclog"
	grpcsyscall "google.golang.org/grpc/internal/syscall"

Why does this need to be renamed?


internal/syscall/syscall_linux.go, line 40 at r4 (raw file):

// Rusage is an alias for syscall.Rusage under linux non-appengine environment.
// TODO(lyuxuan): use type alias after go1.8 is no longer supported.

Nit: I don't think we want to do this.
type alias actually leaks details of how Rusage is implemented, but I think we want to keep that internal to this package.

Copy link
Contributor Author

@lyuxuan lyuxuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @lyuxuan)


benchmark/server/main.go, line 35 at r4 (raw file):

Previously, menghanl (Menghan Li) wrote…

Why does this need to be renamed?

Because we also import syscall.


internal/syscall/syscall_linux.go, line 40 at r4 (raw file):

Previously, menghanl (Menghan Li) wrote…

Nit: I don't think we want to do this.
type alias actually leaks details of how Rusage is implemented, but I think we want to keep that internal to this package.

OK.


internal/benchmarkutil/benchmarkutil_linux.go, line 21 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…

What I was thinking is, this will be the grpc syscall package. Whenever there's a requirement for syscall in grpc, the code should go here.

unix should be considered as part of syscall. (And it's under x/sys)

done

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r5.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @menghanl)


benchmark/server/main.go, line 35 at r4 (raw file):

Previously, lyuxuan wrote…

Because we also import syscall.

Hmm, it shouldn't... syscall should always be guarded: https://go-proverbs.github.io/

It seems syscall.SIGTERM is only defined for unix-like systems. This file might not build on windows.

It's defined here:
https://github.com/golang/go/blob/go1.10/src/syscall/zerrors_linux_amd64.go#L1365

But not on windows:
https://github.com/golang/go/blob/go1.10/src/syscall/zerrors_windows.go

@lyuxuan lyuxuan merged commit 8c15646 into grpc:master Jul 12, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants