-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Return nil instead of emptyTablet in groupi.Tablet() #5469
Conversation
groupi.Tablet returns error and empty Tablet when error is returned while querying zero for Tablet serving info. Allocation of space by empty Tablet shows up in alloc_space profile. . . 463:func (g *groupi) Tablet(key string) (*pb.Tablet, error) { 16.22GB 16.22GB 464: emptyTablet := pb.Tablet{} . . 465: . . 466: // TODO: Remove all this later, create a membership state and apply it . . 467: g.RLock() . . 468: tablet, ok := g.tablets[key] . . 469: g.RUnlock() . . 470: if ok { . . 471: return tablet, nil . . 472: } . . 473: . . 474: // We don't know about this tablet. . . 475: // Check with dgraphzero if we can serve it. . . 476: pl := g.connToZeroLeader() . . 477: zc := pb.NewZeroClient(pl.Get()) . . 478: . . 479: tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} . 1.07MB 480: out, err := zc.ShouldServe(context.Background(), tablet) . . 481: if err != nil { . . 482: glog.Errorf("Error while ShouldServe grpc call %v", err) . . 483: return &emptyTablet, err . . 484: } This can be avoided. We can return nil instead of emptyTablet and save allocations here. Caller function always checks for error first before accessing tablet information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @manishrjain and @vvbalaji-dgraph)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks fine to me but please get it approved by @manishrjain as well.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @ashish-goswami, @manishrjain, and @vvbalaji-dgraph)
worker/groups.go, line 462 at r1 (raw file):
} // Do not modify the returned Tablet
We should check why this comment was added. Maybe this comment is no longer valid.
There was a problem hiding this 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 r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ashish-goswami and @vvbalaji-dgraph)
groupi.Tablet returns error and empty Tablet when error is returned while querying zero for Tablet serving info. Allocation of space by empty Tablet shows up in alloc_space profile. . . 463:func (g *groupi) Tablet(key string) (*pb.Tablet, error) { 16.22GB 16.22GB 464: emptyTablet := pb.Tablet{} . . 465: . . 466: // TODO: Remove all this later, create a membership state and apply it . . 467: g.RLock() . . 468: tablet, ok := g.tablets[key] . . 469: g.RUnlock() . . 470: if ok { . . 471: return tablet, nil . . 472: } . . 473: . . 474: // We don't know about this tablet. . . 475: // Check with dgraphzero if we can serve it. . . 476: pl := g.connToZeroLeader() . . 477: zc := pb.NewZeroClient(pl.Get()) . . 478: . . 479: tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} . 1.07MB 480: out, err := zc.ShouldServe(context.Background(), tablet) . . 481: if err != nil { . . 482: glog.Errorf("Error while ShouldServe grpc call %v", err) . . 483: return &emptyTablet, err . . 484: } This can be avoided. We can return nil instead of emptyTablet and save allocations here. Caller function always checks for error first before accessing tablet information. (cherry picked from commit 428f3bd)
groupi.Tablet returns error and empty Tablet when error is returned while querying zero for Tablet serving info. Allocation of space by empty Tablet shows up in alloc_space profile. . . 463:func (g *groupi) Tablet(key string) (*pb.Tablet, error) { 16.22GB 16.22GB 464: emptyTablet := pb.Tablet{} . . 465: . . 466: // TODO: Remove all this later, create a membership state and apply it . . 467: g.RLock() . . 468: tablet, ok := g.tablets[key] . . 469: g.RUnlock() . . 470: if ok { . . 471: return tablet, nil . . 472: } . . 473: . . 474: // We don't know about this tablet. . . 475: // Check with dgraphzero if we can serve it. . . 476: pl := g.connToZeroLeader() . . 477: zc := pb.NewZeroClient(pl.Get()) . . 478: . . 479: tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} . 1.07MB 480: out, err := zc.ShouldServe(context.Background(), tablet) . . 481: if err != nil { . . 482: glog.Errorf("Error while ShouldServe grpc call %v", err) . . 483: return &emptyTablet, err . . 484: } This can be avoided. We can return nil instead of emptyTablet and save allocations here. Caller function always checks for error first before accessing tablet information. (cherry picked from commit 428f3bd)
groupi.Tablet returns error and empty Tablet when error is returned while querying zero for Tablet serving info. Allocation of space by empty Tablet shows up in alloc_space profile. . . 463:func (g *groupi) Tablet(key string) (*pb.Tablet, error) { 16.22GB 16.22GB 464: emptyTablet := pb.Tablet{} . . 465: . . 466: // TODO: Remove all this later, create a membership state and apply it . . 467: g.RLock() . . 468: tablet, ok := g.tablets[key] . . 469: g.RUnlock() . . 470: if ok { . . 471: return tablet, nil . . 472: } . . 473: . . 474: // We don't know about this tablet. . . 475: // Check with dgraphzero if we can serve it. . . 476: pl := g.connToZeroLeader() . . 477: zc := pb.NewZeroClient(pl.Get()) . . 478: . . 479: tablet = &pb.Tablet{GroupId: g.groupId(), Predicate: key} . 1.07MB 480: out, err := zc.ShouldServe(context.Background(), tablet) . . 481: if err != nil { . . 482: glog.Errorf("Error while ShouldServe grpc call %v", err) . . 483: return &emptyTablet, err . . 484: } This can be avoided. We can return nil instead of emptyTablet and save allocations here. Caller function always checks for error first before accessing tablet information.
groupi.Tablet()
returns error and empty Tablet when error is returned while querying zero for Tabletserving info. This results in allocation of space by empty Tablet and it shows up in alloc_space
profile.
This can be avoided. We can return nil instead of emptyTablet and save
allocations here. Caller function always checks for error first before
accessing tablet information.
This change is