Repository navigation
core: speed up loading of builtin SDKs - #6714
Conversation
Signed-off-by: Erik Sipsma <[email protected]>
7837ad8 to
3799303
Compare
Signed-off-by: Erik Sipsma <[email protected]>
|
Confirmed that the memory usage issues were pre-existing: #6719 Also, while test execution time is noisy, it seems like there's a pretty consistent improvement in CI runtime. I suspect the improvements for day-to-day usage of dagger locally will be less dramatic in terms of individual runs, but they should add up over the course of the day. And any users running shared engines with lots of clients connecting to them (i.e. for CI) should see the benefits more clearly. I may end up doing another iteration on this in response to #6706 (comment), but it should most likely be incremental rather than throwing everything in this PR away, so worth merging this one as is to get the test runtime improvements in the meantime. |
|
|
||
| dagql.Func("builtinContainer", func(ctx context.Context, parent *core.Query, args struct { | ||
| Digest string `doc:"Digest of the image manifest"` | ||
| }) (*core.Container, error) { |
There was a problem hiding this comment.
re: #6704 (comment) - are you thinking of asserting dagql.IsInternal here to avoid people depending on it? Or using dagql.IsInternal to conditionally register the API somehow? (That'd be neat)
There's an interesting consideration either way: you'd want to prevent these hidden/internal APIs from ending up in an ID that the user cares about, since that ID would then only work if it was part of an internal call.
I think everything that matters might still work since we don't want this to end up in any published/long-term IDs anyway (it's an impl. detail of the APIs that actually do end up in IDs). But it's a little spooky. Just fyi!
There was a problem hiding this comment.
Or using dagql.IsInternal to conditionally register the API somehow? (That'd be neat)
Ya that's what I was imagining. And maybe also grouping everything in this category under like Query.internal or something just to avoid hidden namespace conflicts between user APIs and APIs they don't even know about.
There's an interesting consideration either way: you'd want to prevent these hidden/internal APIs from ending up in an ID that the user cares about, since that ID would then only work if it was part of an internal call.
Right right, I guess you could deal with that by returning always returning a dagql.Instance from these internal APIs such that the returned instance is constructed purely from non-internal APIs. So like builtinContainer could use Select to create a Container from scratch using withRootfs, withEnvVariable, etc. etc. and return that instance.
I don't know if we could enforce this automatically or if it'd just need to be a manually enforced rule. But yeah definitely a medium sized wrench in that whole idea...
There was a problem hiding this comment.
👀 I also really want this for #6601 actually!
The accessor field/and co on the secret object shouldn't be visible anywhere to SDK callers, it shouldn't appear in the graphql documentation either. They're only ever needed so that setSecret can return a dagql.Instance anyways.
| f, err := c.Host().File(tarballPath).Sync(ctx) | ||
| if err != nil { | ||
| panic(err) | ||
| func goSDKContent(ctx context.Context, c *dagger.Client, arch string) dagger.WithContainerFunc { |
There was a problem hiding this comment.
Seems like these could be deduped (I am the linter now)
nbd either way though, not worth it if it explodes complexity or requires 1000 args or tiny functions.
There was a problem hiding this comment.
Oh ya totally, split out the sections that were identical between the 3 to a separate func
| return ctr. | ||
| WithEnvVariable(distconsts.GoSDKManifestDigestEnvName, manifestDgst). | ||
| WithDirectory(distconsts.EngineContainerBuiltinContentDir, sdkDir, dagger.ContainerWithDirectoryOpts{ | ||
| Include: []string{"blobs/"}, |
There was a problem hiding this comment.
Neat - I've never actually realized that WithDirectory copies additively to the target directory. 🤯
Signed-off-by: Erik Sipsma <[email protected]>
|
Nice, neat solution! 🎉 (sorry I didn't review earlier, but have a post-merge LGTM from me) |
* core: speed up loading of builtin SDKs Signed-off-by: Erik Sipsma <[email protected]> * regen docs/sdks Signed-off-by: Erik Sipsma <[email protected]> * dedupe sdk->content dir impl code Signed-off-by: Erik Sipsma <[email protected]> --------- Signed-off-by: Erik Sipsma <[email protected]>
@vito noticed a while back that we were spending a lot of time loading the builtin Go SDK tarball. This fixes that bottleneck by avoiding use of local imports for built-in SDKs and instead using OCI store sources, which avoid the various problems with local sources (re-importing when used in parallel, need to always re-read tarball when importing containers, etc.).