Skip to content

Very high memory usage in dagger engine #6719

Closed

Description

@sipsma

I noticed that on main when running go test -run=TestModule ... the engine ends up using over 6GB of RSS at times. By eye, it seems like it particularly spikes during TestModuleLotsOfFunctions (but did not fully confirm yet).

pprof is showing:

File: dagger-engine
Type: inuse_space
Time: Feb 22, 2024 at 10:18am (PST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 1811.45MB, 71.51% of 2533.09MB total
Dropped 846 nodes (cum <= 12.67MB)
Showing top 10 nodes out of 239
      flat  flat%   sum%        cum   cum%
  622.26MB 24.57% 24.57%   622.26MB 24.57%  github.com/moby/buildkit/solver/pb.(*FileActionMkFile).Unmarshal
  605.22MB 23.89% 48.46%   605.22MB 23.89%  github.com/moby/buildkit/solver/pb.(*Op).Marshal
  104.69MB  4.13% 52.59%   104.69MB  4.13%  google.golang.org/grpc/internal/transport.newBufWriter
  103.08MB  4.07% 56.66%   103.08MB  4.07%  encoding/json.(*decodeState).literalStore
   90.83MB  3.59% 60.25%   201.88MB  7.97%  github.com/dagger/dagger/core.(*ModDeps).lazilyLoadSchema
   90.26MB  3.56% 63.81%    90.26MB  3.56%  bufio.NewReaderSize
   75.57MB  2.98% 66.79%    75.57MB  2.98%  google.golang.org/protobuf/internal/impl.consumeStringValidateUTF8
   51.02MB  2.01% 68.81%    69.52MB  2.74%  google.golang.org/grpc/internal/transport.(*http2Server).operateHeaders
   34.51MB  1.36% 70.17%    34.51MB  1.36%  github.com/moby/buildkit/client/llb.mergeMetadata
   34.02MB  1.34% 71.51%    34.02MB  1.34%  github.com/dagger/dagger/dagql.Class[go.shape.*uint8].Install

The top memory users seem pretty consistent across two runs.

I can't help but wonder to what extent the goroutine leak as mentioned by @jedevc could be related: #6597. I.e. the goroutine leak is resulting in memory allocated by the above still be reachable. Just a superficial connection in that goroutine leaks are a very common culprit of memory leaks, could be red herring.

Also wondering if the recent changes to make more heavy use of caching OpDAG modifications could be related, just in that it could be connected to the heavy usage of Op.Marshal in the pprof output.

  • Can test by going back before that commit and seeing if the memory usage was any different.

Activity

  1. modified the milestones: v0.10.x, v0.10.1 on Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions