Repository navigation
feat: add dagop - #9395
feat: add dagop#9395
Conversation
513947d to
2c8c2e8
Compare
f44f9e4 to
6adcacd
Compare
|
Hm, seems to be some issues with running some of the jobs, looks like |
02fe939 to
b30810f
Compare
|
Oooookay, have done a lot of refactoring, and now - these DagOps are implemented as middlewares 🎉 And all tests are passing 😄 There's also a few related dagql fixes+improvements that I found while in the area. This is the first step - it's very easy to mark the However, the end goal is to completely own the cache refs - this is completely possible, it's just not immediately apparent how this should look in dagql. One option is something like 7a36d89. This is another custom op, and requires a lot more manual intervention, but you can write directly to a cache ref and skip the nasty |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
|
This PR was closed because it has been stalled for 7 days with no activity. |
There was a problem hiding this comment.
As a general comment, probably worth a double check we aren't accidentally leaking dagql/client/session memory via all this plumbing through buildkit. I couldn't see anything obvious but there's too many layers of abstraction to really know just by looking at the code
|
|
||
| const InstrumentationLibrary = "dagger.io/engine.server" | ||
|
|
||
| func (srv *Server) DagqlServer(ctx context.Context) (*dagql.Server, error) { |
There was a problem hiding this comment.
nit: if we just store this dag var on the client we can use that (the LLM branch needed to do that anyways too) https://github.com/sipsma/dagger/blob/6a2c1b9bf9aa4ba124d5f7fdb3517e1683c26259/engine/server/session.go#L558-L558
There was a problem hiding this comment.
I'm probably missing something, but on creation, the CustomOp only has access to the worker. We don't actually have access to the engine server, or the list of sessions, or even a specific client - so I don't think there's a way of getting it out?
We just need some interface to pass this through via, we could use core.Server honestly, it's just that that's in core, and we need this in buildkit. So I just selected the one function we need here.
There was a problem hiding this comment.
I misread this originally, I thought it was a method on session.... This all lgtm
| if err != nil { | ||
| return nil, err | ||
| } | ||
| deps := make([]llb.State, 0, len(depsDefs)) |
There was a problem hiding this comment.
nit: it looks like some of our impls of PBDefinitions use a map so the order is random, which I think might change the buildkit cache key and result in extra invalidation?
I'm sort of doubtful this is anything remotely near a big deal atm, so not a blocker. If there's a really easy fix then maybe worth it, otherwise just worth keeping in mind
There was a problem hiding this comment.
Gooood catch! This doesn't actually effect us at the moment, since only user interfaces/structs rely on a Fields map - since you can only add this to core implementations, this isn't an issue.
But this is actually a really easy fix, so thrown this into a new commit - we can just iterate over the typedef fields, which are more consistently ordered.
Anything specific to do here? I've added the |
For now, just start the dev engine locally with debug endpoints exposed, run some reasonable set of tests for a while (I often just run |
sipsma
left a comment
There was a problem hiding this comment.
Double checking memory here is worth a check before merge, but overall LGTM!
0b90187 to
5fe6ac6
Compare
Signed-off-by: Justin Chadwell <[email protected]>
This little refactor ensures we can get the Typed value of an array, even if it doesn't actually have any values in it. Signed-off-by: Justin Chadwell <[email protected]>
Without evaluating any of the fields! This allows neatly deferring operations, but primarily is there to ensure that we can serialized selectors for the use in DagOP. Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Because we start using these as cache keys for dagop, it makes sense that we should order these (to avoid bad invalidations). We won't hit this case in practice soon, but good practice to do it anyways, so at least it works as expected if we try. Signed-off-by: Justin Chadwell <[email protected]>
Implements sipsma's suggestions, and also renames middlewares to wrappers - since the llm branch is using middlewares to mean something entirely different (and that was claimed first). Signed-off-by: Justin Chadwell <[email protected]>
|
Okay, having gone through a few runs of Still seeing a lot of |
@jedevc those shouldn't be leaking anymore after the other fixes, if they are then something might be going wrong. I'll try locally too. EDIT: I didn't see any leaks after running |
Fixes #6927, enables #9098, and continues the project of rebuilding the Ship of Theseus 🎉
This PR introduces a new way of marrying dagger's dagql and buildkit's LLB. Currently, dagql is used to query the graphql API schema, while LLB is used to query the buildkit dag. dagql is much more flexible and easy to extend, while LLB has significantly better caching behavior.
DagOpallows us to combine the best of both worlds. Essentially, it allows us to execute a graphql selection as a buildkit op - caching it exactly as a native buildkit operation.How it works
Descriptionmap of an existing LLB operation. Then duringResolveOp, we transform this into a magicalCustomOpWrapper. This LLB is very hacky, but such is life 🤷 Without entirely ripping out LLB (or forking that package), there's not really a neat way of handling this.CustomOpWrapperdelegates all of it's operations toRegisteredCustomOps - at the moment, onlyDagOp.CustomOps are serialized into astring, then theDagOphas to be JSON-marshallable. This means we have to do some hackery around sendingIDs instead ofSelectors directly.DagOpevaluates the query, and gets the result as a rootDirectory- it then evaluates this theDirectorys ref, and returns it.This effectively allows the dagql query execution to be cached!
Performance
To show this off, I've ported
AsTarballto use this (to fix #6927). Essentially,AsTarballattempts to self-call itself inside aDagOp(using a similar technique to #8724). This now means that if theContainerreceiver hasn't changed, then theFileresult isn't forced to be re-evaluated (which it was before).Just this simple transformation seems to shave a couple seconds off an engine build with
dagger call engine container.Without this patch:
With this patch:
In the traces, you can see that before, the tar unpacking as part of unbundling the SDK images is uncached, while after, they are:
Before:


After:
TODO
Selectors,IDs might not be it (support for custom digests in dagql #9204 is probably related)AsTarball