You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Install-span lookup for a bound service walks every result ever built on it, on every exec #15024
What happens. Every exec that binds a service looks up the service's install spans (lookupServiceOriginSpanContexts in core/services.go and core/container_exec.go, then Cache.ResultInstallSpans). To find closure-owning installs, sessionResultInstallSpanContexts calls installAncestorIDsLocked, which walks dep edges upward from the service through depParents. depParents holds every result built on that value in any session, not only the current one. When many execs share one service, each lookup walks everything already built on it, so the total cost grows roughly with the square of the number of execs.
Reproduction. Bind one service (we use a Postgres container) to many test execs built from the same base, then run them with dagger check -j 48. Engine CPU stays near two cores, and a CPU profile puts most of it under installAncestorIDsLocked. Removing the binding makes the time go away.
Cost. Our dashboard package has about 1,000 jest test files, each one check, and every check bound Postgres and an HTTP proxy service. Profiled at -j 48 on main 092b01e, 45% of engine CPU was in installAncestorIDsLocked under lookupServiceOriginSpanContexts. On a freshly started engine (m8id.16xlarge) the package took 398-399 s, and 163-174 s warm.
Proposed fix. Index closure owners per session: queue each closure-owning install as it is recorded, walk its deps downward once on the next lookup, and answer lookups from that index. The walk is then bounded by the session's own closures, and the index goes away with the session. With that change the same package took 154 s on a fresh engine and 135 s warm. PR to follow.
Activity