Skip to content

Commit 92fafce

Browse files
author
Tanat Boozayaangool
authored
Add validation info to gapis (google#992)
* Add validation info to gapis - Always download perfetto trace from validation - Include path to trace in result proto
1 parent 32b7c31 commit 92fafce

File tree

15 files changed

+120
-52
lines changed

15 files changed

+120
-52
lines changed

cmd/gapit/validate_gpu_profiling.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ func (verb *validateGpuProfilingVerb) Run(ctx context.Context, flags flag.FlagSe
5151
someDeviceFailed := false
5252
for i, p := range devices {
5353
fmt.Fprintf(stdout, "-- Device %v: %v --\n", i, p.ID.ID())
54-
err = client.ValidateDevice(ctx, p)
54+
res, err := client.ValidateDevice(ctx, p)
5555
if err != nil {
56-
fmt.Fprintf(stdout, "%v\n", log.Err(ctx, err, "Failed to validate device"))
56+
fmt.Fprintf(stdout, "%v\n", log.Errf(ctx, err, "Failed to start device validation: %s", err))
57+
someDeviceFailed = true
58+
continue
59+
} else if len(res.ValidationFailureMsg) > 0 {
60+
fmt.Fprintf(stdout, "%v\n", log.Errf(ctx, nil, "Device validation failed: %s, trace file: %s", res.ValidationFailureMsg, res.TracePath))
5761
someDeviceFailed = true
5862
continue
5963
}

core/os/file/path.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package file
1616

1717
import (
1818
"encoding/json"
19+
"fmt"
1920
"io/ioutil"
2021
"net/url"
2122
"os"
@@ -56,6 +57,16 @@ func Temp() (Path, error) {
5657
return Abs(p.Name()), nil
5758
}
5859

60+
// TempWithExt creates a new temp file with the given name and extension and returns its path.
61+
func TempWithExt(name string, ext string) (Path, error) {
62+
p, err := ioutil.TempFile("", fmt.Sprintf("%s*.%s", name, ext))
63+
if err != nil {
64+
return Path{}, err
65+
}
66+
p.Close()
67+
return Abs(p.Name()), nil
68+
}
69+
5970
// ExecutablePath returns the path to the running executable.
6071
func ExecutablePath() Path {
6172
path := Abs(os.Args[0])

gapic/src/main/com/google/gapid/models/Devices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public DeviceValidationResult(Service.Error error, boolean passed, boolean skipp
446446
}
447447

448448
public DeviceValidationResult(Service.ValidateDeviceResponse r) {
449-
this(r.getError(), !r.hasError(), false);
449+
this(r.getError(), !r.hasError() && r.getResult().getValidationFailureMsg().length() == 0, false);
450450
}
451451

452452
@Override

gapis/client/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,17 +577,17 @@ func (c *client) PerfettoQuery(ctx context.Context, capture *path.Capture, query
577577
return res.GetResult(), nil
578578
}
579579

580-
func (c *client) ValidateDevice(ctx context.Context, device *path.Device) error {
580+
func (c *client) ValidateDevice(ctx context.Context, device *path.Device) (*service.DeviceValidationResult, error) {
581581
res, err := c.client.ValidateDevice(ctx, &service.ValidateDeviceRequest{
582582
Device: device,
583583
})
584584
if err != nil {
585-
return err
585+
return nil, err
586586
}
587587
if err := res.GetError(); err != nil {
588-
return err.Get()
588+
return nil, err.Get()
589589
}
590-
return nil
590+
return res.GetResult(), nil
591591
}
592592

593593
func (c *client) InstallApp(ctx context.Context, d *path.Device, app string) error {

gapis/config/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ const (
3838
// DumpReplayProfile dumps the perfetto trace of a replay profile.
3939
DumpReplayProfile = false
4040

41-
// DumpValidationTrace dumps the perfetto trace of a validation profile.
42-
DumpValidationTrace = false
43-
4441
// AllInitialCommandsLive forces all initial commands to be considered as
4542
// live when computing dead code elimination.
4643
AllInitialCommandsLive = false

gapis/server/grpc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,11 @@ func (s *grpcServer) PerfettoQuery(ctx xctx.Context, req *service.PerfettoQueryR
688688

689689
func (s *grpcServer) ValidateDevice(ctx xctx.Context, req *service.ValidateDeviceRequest) (*service.ValidateDeviceResponse, error) {
690690
defer s.inRPC()()
691-
err := s.handler.ValidateDevice(s.bindCtx(ctx), req.Device)
691+
res, err := s.handler.ValidateDevice(s.bindCtx(ctx), req.Device)
692692
if err := service.NewError(err); err != nil {
693-
return &service.ValidateDeviceResponse{Error: err}, nil
693+
return &service.ValidateDeviceResponse{Res: &service.ValidateDeviceResponse_Error{Error: err}}, nil
694694
}
695-
return &service.ValidateDeviceResponse{}, nil
695+
return &service.ValidateDeviceResponse{Res: &service.ValidateDeviceResponse_Result{Result: res}}, nil
696696
}
697697

698698
func (s *grpcServer) InstallApp(ctx xctx.Context, req *service.InstallAppRequest) (*service.InstallAppResponse, error) {

gapis/server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,11 +930,11 @@ func (s *server) PerfettoQuery(ctx context.Context, c *path.Capture, query strin
930930
return res, nil
931931
}
932932

933-
func (s *server) ValidateDevice(ctx context.Context, d *path.Device) error {
933+
func (s *server) ValidateDevice(ctx context.Context, d *path.Device) (*service.DeviceValidationResult, error) {
934934
ctx = status.Start(ctx, "RPC ValidateDevice")
935935
defer status.Finish(ctx)
936936
ctx = log.Enter(ctx, "ValidateDevice")
937-
return trace.Validate(ctx, d)
937+
return trace.Validate(ctx, d, s.enableLocalFiles)
938938
}
939939

940940
func (s *server) InstallApp(ctx context.Context, d *path.Device, app string) error {

gapis/service/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ type Service interface {
190190

191191
// ValidateDevice validates the GPU profiling capabilities of the given device and returns
192192
// an error if validation failed or the GPU profiling data is invalid.
193-
ValidateDevice(ctx context.Context, d *path.Device) error
193+
ValidateDevice(ctx context.Context, d *path.Device) (*DeviceValidationResult, error)
194194

195195
// InstallApp installs an application on the given device.
196196
InstallApp(ctx context.Context, d *path.Device, app string) error

gapis/service/service.proto

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,23 @@ message ValidateDeviceRequest {
14821482
}
14831483

14841484
message ValidateDeviceResponse {
1485-
Error error = 1;
1485+
reserved 1;
1486+
oneof res {
1487+
DeviceValidationResult result = 2;
1488+
1489+
// Internal error from being unable to start validation
1490+
// (doesn't include failure from the validation itself).
1491+
Error error = 3;
1492+
}
1493+
}
1494+
1495+
message DeviceValidationResult {
1496+
// Message with details of how the device failed validation (doesn't
1497+
// include internal errors where we somehow failed to start validation).
1498+
string validation_failure_msg = 1;
1499+
1500+
// Path to the perfetto trace file to help debug validation issues.
1501+
string trace_path = 2;
14861502
}
14871503

14881504
message FuchsiaTraceConfig {

gapis/trace/android/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ go_library(
3030
"//core/os/android/apk:go_default_library",
3131
"//core/os/device:go_default_library",
3232
"//core/os/device/bind:go_default_library",
33+
"//core/os/file:go_default_library",
3334
"//gapidapk:go_default_library",
3435
"//gapidapk/pkginfo:go_default_library",
3536
"//gapii/client:go_default_library",
3637
"//gapis/api:go_default_library",
3738
"//gapis/api/sync:go_default_library",
38-
"//gapis/config:go_default_library",
3939
"//gapis/perfetto:go_default_library",
4040
"//gapis/perfetto/android:go_default_library",
4141
"//gapis/service:go_default_library",

0 commit comments

Comments
 (0)