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

Keepalive pings should be sent every [Time+Timeout] period and not every [Time] period #2790

Closed
wants to merge 12 commits into from
Closed
30 changes: 15 additions & 15 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ See [CONTRIBUTING.md](https://github.com/grpc/grpc-community/blob/master/CONTRIB
for general contribution guidelines.

## Maintainers (in alphabetical order)
- [canguler](https://github.com/canguler), Google Inc.
- [cesarghali](https://github.com/cesarghali), Google Inc.
- [dfawley](https://github.com/dfawley), Google Inc.
- [easwars](https://github.com/easwars), Google Inc.
- [jadekler](https://github.com/jadekler), Google Inc.
- [menghanl](https://github.com/menghanl), Google Inc.
- [srini100](https://github.com/srini100), Google Inc.
- [canguler](https://github.com/canguler), Google LLC
- [cesarghali](https://github.com/cesarghali), Google LLC
- [dfawley](https://github.com/dfawley), Google LLC
- [easwars](https://github.com/easwars), Google LLC
- [jadekler](https://github.com/jadekler), Google LLC
- [menghanl](https://github.com/menghanl), Google LLC
- [srini100](https://github.com/srini100), Google LLC

## Emeritus Maintainers (in alphabetical order)
- [adelez](https://github.com/adelez), Google Inc.
- [iamqizhao](https://github.com/iamqizhao), Google Inc.
- [jtattermusch](https://github.com/jtattermusch), Google Inc.
- [lyuxuan](https://github.com/lyuxuan), Google Inc.
- [makmukhi](https://github.com/makmukhi), Google Inc.
- [matt-kwong](https://github.com/matt-kwong), Google Inc.
- [nicolasnoble](https://github.com/nicolasnoble), Google Inc.
- [yongni](https://github.com/yongni), Google Inc.
- [adelez](https://github.com/adelez), Google LLC
- [iamqizhao](https://github.com/iamqizhao), Google LLC
- [jtattermusch](https://github.com/jtattermusch), Google LLC
- [lyuxuan](https://github.com/lyuxuan), Google LLC
- [makmukhi](https://github.com/makmukhi), Google LLC
- [matt-kwong](https://github.com/matt-kwong), Google LLC
- [nicolasnoble](https://github.com/nicolasnoble), Google LLC
- [yongni](https://github.com/yongni), Google LLC
24 changes: 14 additions & 10 deletions benchmark/benchresult/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func compareTwoMap(m1, m2 map[string]stats.BenchResults) {
changes += intChange("TotalOps", v1.Data.TotalOps, v2.Data.TotalOps)
changes += intChange("SendOps", v1.Data.SendOps, v2.Data.SendOps)
changes += intChange("RecvOps", v1.Data.RecvOps, v2.Data.RecvOps)
changes += intChange("Bytes/op", v1.Data.AllocedBytes, v2.Data.AllocedBytes)
changes += intChange("Allocs/op", v1.Data.Allocs, v2.Data.Allocs)
changes += floatChange("Bytes/op", v1.Data.AllocedBytes, v2.Data.AllocedBytes)
changes += floatChange("Allocs/op", v1.Data.Allocs, v2.Data.Allocs)
changes += floatChange("ReqT/op", v1.Data.ReqT, v2.Data.ReqT)
changes += floatChange("RespT/op", v1.Data.RespT, v2.Data.RespT)
changes += timeChange("50th-Lat", v1.Data.Fiftieth, v2.Data.Fiftieth)
Expand All @@ -93,9 +93,16 @@ func compareBenchmark(file1, file2 string) {
compareTwoMap(createMap(file1), createMap(file2))
}

func printline(benchName, total, send, recv, allocB, allocN, reqT, respT, ltc50, ltc90, l99, lAvg interface{}) {
fmt.Printf("%-80v%12v%12v%12v%12v%12v%18v%18v%12v%12v%12v%12v\n",
benchName, total, send, recv, allocB, allocN, reqT, respT, ltc50, ltc90, l99, lAvg)
func printHeader() {
fmt.Printf("%-80s%12s%12s%12s%18s%18s%18s%18s%12s%12s%12s%12s\n",
"Name", "TotalOps", "SendOps", "RecvOps", "Bytes/op (B)", "Allocs/op (#)",
"RequestT", "ResponseT", "L-50", "L-90", "L-99", "L-Avg")
}

func printline(benchName string, d stats.RunData) {
fmt.Printf("%-80s%12d%12d%12d%18.2f%18.2f%18.2f%18.2f%12v%12v%12v%12v\n",
benchName, d.TotalOps, d.SendOps, d.RecvOps, d.AllocedBytes, d.Allocs,
d.ReqT, d.RespT, d.Fiftieth, d.Ninetieth, d.NinetyNinth, d.Average)
}

func formatBenchmark(fileName string) {
Expand All @@ -122,12 +129,9 @@ func formatBenchmark(fileName string) {
wantFeatures[i] = !wantFeatures[i]
}

printline("Name", "TotalOps", "SendOps", "RecvOps", "Alloc (B)", "Alloc (#)",
"RequestT", "ResponseT", "L-50", "L-90", "L-99", "L-Avg")
printHeader()
for _, r := range results {
d := r.Data
printline(r.RunMode+r.Features.PrintableName(wantFeatures), d.TotalOps, d.SendOps, d.RecvOps,
d.AllocedBytes, d.Allocs, d.ReqT, d.RespT, d.Fiftieth, d.Ninetieth, d.NinetyNinth, d.Average)
printline(r.RunMode+r.Features.PrintableName(wantFeatures), r.Data)
}
}

Expand Down
12 changes: 6 additions & 6 deletions benchmark/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ type RunData struct {
// run. Only makes sense for unconstrained workloads.
RecvOps uint64
// AllocedBytes is the average memory allocation in bytes per operation.
AllocedBytes uint64
AllocedBytes float64
// Allocs is the average number of memory allocations per operation.
Allocs uint64
Allocs float64
// ReqT is the average request throughput associated with this run.
ReqT float64
// RespT is the average response throughput associated with this run.
Expand Down Expand Up @@ -275,8 +275,8 @@ func (s *Stats) EndRun(count uint64) {
r := &s.results[len(s.results)-1]
r.Data = RunData{
TotalOps: count,
AllocedBytes: s.stopMS.TotalAlloc - s.startMS.TotalAlloc,
Allocs: s.stopMS.Mallocs - s.startMS.Mallocs,
AllocedBytes: float64(s.stopMS.TotalAlloc-s.startMS.TotalAlloc) / float64(count),
Allocs: float64(s.stopMS.Mallocs-s.startMS.Mallocs) / float64(count),
ReqT: float64(count) * float64(r.Features.ReqSizeBytes) * 8 / r.Features.BenchTime.Seconds(),
RespT: float64(count) * float64(r.Features.RespSizeBytes) * 8 / r.Features.BenchTime.Seconds(),
}
Expand All @@ -296,8 +296,8 @@ func (s *Stats) EndUnconstrainedRun(req uint64, resp uint64) {
r.Data = RunData{
SendOps: req,
RecvOps: resp,
AllocedBytes: (s.stopMS.TotalAlloc - s.startMS.TotalAlloc) / ((req + resp) / 2),
Allocs: (s.stopMS.Mallocs - s.startMS.Mallocs) / ((req + resp) / 2),
AllocedBytes: float64(s.stopMS.TotalAlloc-s.startMS.TotalAlloc) / float64((req+resp)/2),
Allocs: float64(s.stopMS.Mallocs-s.startMS.Mallocs) / float64((req+resp)/2),
ReqT: float64(req) * float64(r.Features.ReqSizeBytes) * 8 / r.Features.BenchTime.Seconds(),
RespT: float64(resp) * float64(r.Features.RespSizeBytes) * 8 / r.Features.BenchTime.Seconds(),
}
Expand Down
3 changes: 3 additions & 0 deletions credentials/alts/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ var (
// running on GCP.
func isRunningOnGCP() bool {
manufacturer, err := readManufacturer()
if os.IsNotExist(err) {
return false
}
if err != nil {
log.Fatalf("failure to read manufacturer information: %v", err)
}
Expand Down
47 changes: 34 additions & 13 deletions credentials/alts/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,42 @@ package alts
import (
"context"
"io"
"os"
"strings"
"testing"

altspb "google.golang.org/grpc/credentials/alts/internal/proto/grpc_gcp"
"google.golang.org/grpc/peer"
)

func setupManufacturerReader(testOS string, reader func() (io.Reader, error)) func() {
tmpOS := runningOS
tmpReader := manufacturerReader

// Set test OS and reader function.
runningOS = testOS
manufacturerReader = reader
return func() {
runningOS = tmpOS
manufacturerReader = tmpReader
}

}

func setup(testOS string, testReader io.Reader) func() {
reader := func() (io.Reader, error) {
return testReader, nil
}
return setupManufacturerReader(testOS, reader)
}

func setupError(testOS string, err error) func() {
reader := func() (io.Reader, error) {
return nil, err
}
return setupManufacturerReader(testOS, reader)
}

func TestIsRunningOnGCP(t *testing.T) {
for _, tc := range []struct {
description string
Expand All @@ -53,20 +82,12 @@ func TestIsRunningOnGCP(t *testing.T) {
}
}

func setup(testOS string, testReader io.Reader) func() {
tmpOS := runningOS
tmpReader := manufacturerReader

// Set test OS and reader function.
runningOS = testOS
manufacturerReader = func() (io.Reader, error) {
return testReader, nil
}

return func() {
runningOS = tmpOS
manufacturerReader = tmpReader
func TestIsRunningOnGCPNoProductNameFile(t *testing.T) {
reverseFunc := setupError("linux", os.ErrNotExist)
if isRunningOnGCP() {
t.Errorf("ErrNotExist: isRunningOnGCP()=true, want false")
}
reverseFunc()
}

func TestAuthInfoFromContext(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/helloworld/greeter_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ func main() {
if err != nil {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Greeting: %s", r.Message)
log.Printf("Greeting: %s", r.GetMessage())
}
4 changes: 2 additions & 2 deletions examples/helloworld/greeter_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type server struct{}

// SayHello implements helloworld.GreeterServer
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
log.Printf("Received: %v", in.Name)
return &pb.HelloReply{Message: "Hello " + in.Name}, nil
log.Printf("Received: %v", in.GetName())
return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil
}

func main() {
Expand Down
12 changes: 4 additions & 8 deletions internal/transport/controlbuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func (*registerStream) isTransportResponseFrame() bool { return false }
type headerFrame struct {
streamID uint32
hf []hpack.HeaderField
endStream bool // Valid on server side.
initStream func(uint32) (bool, error) // Used only on the client side.
endStream bool // Valid on server side.
initStream func(uint32) error // Used only on the client side.
onWrite func()
wq *writeQuota // write quota for the stream created.
cleanup *cleanupStream // Valid on the server side.
Expand Down Expand Up @@ -637,21 +637,17 @@ func (l *loopyWriter) headerHandler(h *headerFrame) error {

func (l *loopyWriter) originateStream(str *outStream) error {
hdr := str.itl.dequeue().(*headerFrame)
sendPing, err := hdr.initStream(str.id)
if err != nil {
if err := hdr.initStream(str.id); err != nil {
if err == ErrConnClosing {
return err
}
// Other errors(errStreamDrain) need not close transport.
return nil
}
if err = l.writeHeader(str.id, hdr.endStream, hdr.hf, hdr.onWrite); err != nil {
if err := l.writeHeader(str.id, hdr.endStream, hdr.hf, hdr.onWrite); err != nil {
return err
}
l.estdStreams[str.id] = str
if sendPing {
return l.pingHandler(&ping{data: [8]byte{}})
}
return nil
}

Expand Down
Loading