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

querydiff: perform the profile selections concurrently #2242

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ require (
go.opentelemetry.io/otel/trace v1.11.1
golang.org/x/exp v0.0.0-20221204150635-6dcec336b2bb
golang.org/x/net v0.2.0
golang.org/x/sync v0.1.0
google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.1
Expand Down Expand Up @@ -226,7 +227,6 @@ require (
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/oauth2 v0.2.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
Expand Down
30 changes: 23 additions & 7 deletions pkg/query/columnquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/go-kit/log"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

Expand Down Expand Up @@ -274,14 +275,29 @@ func (q *ColumnQueryAPI) selectDiff(ctx context.Context, d *pb.DiffProfile) (*pr
return nil, status.Error(codes.InvalidArgument, "requested diff mode, but did not provide parameters for diff")
}

base, err := q.selectProfileForDiff(ctx, d.A)
if err != nil {
return nil, fmt.Errorf("reading base profile: %w", err)
}
g, ctx := errgroup.WithContext(ctx)
var base *profile.Profile
g.Go(func() error {
var err error
base, err = q.selectProfileForDiff(ctx, d.A)
if err != nil {
return fmt.Errorf("reading base profile: %w", err)
}
return nil
})

compare, err := q.selectProfileForDiff(ctx, d.B)
if err != nil {
return nil, fmt.Errorf("reading compared profile: %w", err)
var compare *profile.Profile
g.Go(func() error {
var err error
compare, err = q.selectProfileForDiff(ctx, d.B)
if err != nil {
return fmt.Errorf("reading compared profile: %w", err)
}
return nil
})

if err := g.Wait(); err != nil {
return nil, err
}

// TODO: This is cheating a bit. This should be done with a sub-query in the columnstore.
Expand Down