Skip to content

Commit

Permalink
Pre-resolve dependency graph
Browse files Browse the repository at this point in the history
Resolve the dependency graph in parallel immediately once the capture
data is resolve. This speed up the GAPIS side a bit (~30 sec for a
typical Vulkan app, 1.8G trace file) for buliding the instructions to
get the framebuffer data from the replay device.
  • Loading branch information
Qining committed Sep 5, 2018
1 parent 6402de1 commit ffc9356
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gapis/api/vulkan/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (a API) Replay(
if opt {
// If we have not set up the dependency graph, do it now.
if dceInfo.ft == nil {
ft, err := dependencygraph.GetFootprint(ctx, intent.Device)
ft, err := dependencygraph.GetFootprint(ctx, intent.Capture)
if err != nil {
return 0, err
}
Expand Down
14 changes: 3 additions & 11 deletions gapis/resolve/dependencygraph/footprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/google/gapid/gapis/api"
"github.com/google/gapid/gapis/capture"
"github.com/google/gapid/gapis/database"
"github.com/google/gapid/gapis/replay"
"github.com/google/gapid/gapis/resolve/initialcmds"
"github.com/google/gapid/gapis/service/path"
)
Expand Down Expand Up @@ -163,10 +162,9 @@ type FootprintBuilder interface {
}

// GetFootprint returns a pointer to the resolved Footprint.
func GetFootprint(ctx context.Context, device *path.Device) (*Footprint, error) {
func GetFootprint(ctx context.Context, c *path.Capture) (*Footprint, error) {
r, err := database.Build(ctx, &FootprintResolvable{
Capture: capture.Get(ctx),
Device: device,
Capture: c,
})
if err != nil {
return nil, fmt.Errorf("Counld not get execution foot print: %v", err)
Expand All @@ -176,18 +174,12 @@ func GetFootprint(ctx context.Context, device *path.Device) (*Footprint, error)

// Resolve implements the database.Resolver interface.
func (r *FootprintResolvable) Resolve(ctx context.Context) (interface{}, error) {
ctx = capture.Put(ctx, r.Capture)
if d := r.Device; d != nil {
ctx = replay.PutDevice(ctx, d)
}

c, err := capture.Resolve(ctx)
c, err := capture.ResolveFromPath(ctx, r.Capture)
if err != nil {
return nil, err
}
cmds := c.Commands
// If the capture contains initial state, prepend the commands to build the state.

initialCmds, ranges, err := initialcmds.InitialCommands(ctx, r.Capture)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions gapis/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ go_library(
"//gapis/replay:go_default_library",
"//gapis/replay/devices:go_default_library",
"//gapis/resolve:go_default_library",
"//gapis/resolve/dependencygraph:go_default_library",
"//gapis/service:go_default_library",
"//gapis/service/path:go_default_library",
"//gapis/stringtable:go_default_library",
Expand Down
11 changes: 11 additions & 0 deletions gapis/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
"sync/atomic"
"time"

"github.com/google/gapid/core/app/crash"
"github.com/google/gapid/core/app/crash/reporting"
"github.com/google/gapid/core/context/keys"

"github.com/google/gapid/core/app"
"github.com/google/gapid/core/app/analytics"
Expand All @@ -43,6 +45,7 @@ import (
"github.com/google/gapid/gapis/replay"
"github.com/google/gapid/gapis/replay/devices"
"github.com/google/gapid/gapis/resolve"
"github.com/google/gapid/gapis/resolve/dependencygraph"
"github.com/google/gapid/gapis/service"
"github.com/google/gapid/gapis/service/path"
"github.com/google/gapid/gapis/stringtable"
Expand Down Expand Up @@ -230,6 +233,14 @@ func (s *server) LoadCapture(ctx context.Context, path string) (*path.Capture, e
if _, err = capture.ResolveFromPath(ctx, p); err != nil {
return nil, err
}
// Pre-resolve the dependency graph.
crash.Go(func() {
newCtx := keys.Clone(context.Background(), ctx)
_, err = dependencygraph.GetFootprint(newCtx, p)
if err != nil {
log.E(newCtx, "Error resolve dependency graph: %v", err)
}
})
return p, nil
}

Expand Down

0 comments on commit ffc9356

Please sign in to comment.