Skip to content

fix: dedupe uncached metadata across a session - #6505

Merged
jedevc merged 1 commit into
dagger:mainfrom
jedevc:unchached-metadata-dedupe
Jan 29, 2024
Merged

jedevc merged 1 commit into
dagger:mainfrom
jedevc:unchached-metadata-dedupe

Conversation

@jedevc

@jedevc jedevc commented Jan 26, 2024 •

Copy link
Copy Markdown
Contributor

Fixes #6501.

Thank goodness it's Friday, lol.

The root cause of #6501 is that every single ExecOp gets a unique digest. This means that the buildkit solver is not able to dedupe them, and instead, to ensure it only runs once, we rely on the edge merging behavior. This was kiiiinda hacky, and not super great - edge merging is supposed to be for different vertexes that happen to produce similar output (detected by their cache keys). We were using it for pretty much everything.

Since moby/buildkit@e1da8b7 (introduced in #6481), the progress behavior changes - edge merges now duplicate the progress. This makes sense! Because edge merges are for "coincidentally" similar edges, the progress should occur for both.

The trick here is to stop relying on this edge merging behavior, by making more ExecOps have a similar digest. The cause of the different digests is the server ids and the parent client ids, so we make an explicit effort to not modify these these for ExecOps that were previously the same, by using a map to cache previous metadata. Because the cache map is on the Client, then this effectively dedupes across only the session - different sessions don't get deduped with each other, which is fine, because they would have different server ids anyways! (and in this case, we actually want the edge merge to happen, so we get progress to both! see moby/buildkit#4330)

Note

This does seem like a bizarre trick to pull. Is it actually safe to dedupe these like this?
However, we were doing it similar via edge-merges, this just forces the merge to happen at the buildkit solver level, which is much much easier.

@jedevc
jedevc force-pushed the unchached-metadata-dedupe branch from f26cf24 to 8f78058 Compare January 26, 2024 14:16
@jedevc
jedevc marked this pull request as ready for review January 26, 2024 14:58

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me considering this is effectively what happened before, just on the other side of the fence. Definitely a bit weird, but now it's explicitly weird, so maybe we can figure it out someday.

@jedevc jedevc added this to the v0.9.8 milestone Jan 26, 2024

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice idea on the approach to fixing this!

I'm wondering if there's any chance this could somehow be related to #6493 ? Just in that it seems like previously we'd always overwrite ParentClientIDs, which impacts search domains of containers with service deps. This is a completely superficial guess, haven't looked into details at all, may be completely unrelated. cc @vito

@sipsma

sipsma commented Jan 26, 2024

Copy link
Copy Markdown
Contributor

Also, agreed on the weirdness here, but that's a pre-existing issue, so all good. The solution is to move on from the ftp proxy hack, but that's a whole other can of worms.

@jedevc
jedevc merged commit 30b22dd into dagger:main Jan 29, 2024
@jedevc
jedevc deleted the unchached-metadata-dedupe branch January 29, 2024 11:51
vito added a commit to vito/dagger that referenced this pull request Jan 31, 2024
Turns out this is still needed by legacy dagger (dagger run, go run +
auto-started session, etc).

It's unfortunate to bring all this plumbing back but we obviously can't
break all that yet.

Kept everything as-is, including propagating parents, because dagger#6505
prevents the cache-busting issue that we originally ripped all this out
to avoid.

This reverts commit 3309a8e.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Jan 31, 2024
Turns out this is still needed by legacy dagger (dagger run, go run +
auto-started session, etc).

It's unfortunate to bring all this plumbing back but we obviously can't
break all that yet.

Kept everything as-is, including propagating parents, because #6505
prevents the cache-busting issue that we originally ripped all this out
to avoid.

This reverts commit 3309a8e.

Signed-off-by: Alex Suraci <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Logs are duplicated when a vertex is used multiple times

3 participants