Skip to content

[WIP] pipeline caching: Re-use previous Pipeline results rather than relying on BuildKit caching. - #193

Closed
aluzzardi wants to merge 1 commit into
mainfrom
pipeline-manager
Closed

aluzzardi wants to merge 1 commit into
mainfrom
pipeline-manager

Conversation

@aluzzardi

Copy link
Copy Markdown
Contributor

WIP: For discussion, please do not merge

With the current approach, everytime a pipeline is referenced (e.g.
mount: "/src": from: bar) a new Pipeline is created and bar is
re-computed. We rely on BuildKit to figure out the operations already
happened and return the same result.

However:

  • When something goes wrong, the Pipeline is executed twice (or more).
    Either because of a buildkit hiccup (e.g. llb.Local producing a different
    vertex digest on consecutive run), or because of a consistency issue
    on our end (e.g. always: true adds a cache buster)
  • Logs can be confusing: the Pipeline will produce logs any time it's
    referenced, with a CACHED status

This change attepts a different approach:

  • Keep a cache of all executed Pipelines, keyed by de-referenced Value
    (e.g. for mount: "/src": from: bar, the key will be bar's path)
  • Lazy compute Pipelines, re-use the result of previous run if already
    computed

Signed-off-by: Andrea Luzzardi [email protected]

on BuildKit caching.

With the current approach, everytime a pipeline is referenced (e.g.
`mount: "/src": from: bar`) a new Pipeline is created and *bar* is
re-computed. We rely on BuildKit to figure out the operations already
happened and return the same result.

However:
- When something goes wrong, the Pipeline is executed twice (or more).
  Either because of a buildkit hiccup (e.g. `llb.Local` producing a different
  vertex digest on consecutive run), or because of a consistency issue
  on our end (e.g. `always: true` adds a cache buster)
- Logs can be confusing: the Pipeline will produce logs any time it's
  referenced, with a `CACHED` status

This change attepts a different approach:
- Keep a cache of all executed Pipelines, keyed by de-referenced Value
  (e.g. for `mount: "/src": from: bar`, the key will be bar's path)
- Lazy compute Pipelines, re-use the result of previous run if already
  computed

Signed-off-by: Andrea Luzzardi <[email protected]>
@aluzzardi

Copy link
Copy Markdown
Contributor Author

NOTE: currently not working well because Dereference() doesn't do what I thought it would do

Comment thread dagger/manager.go
}

func (m *PipelineManager) Do(ctx context.Context, v *compiler.Value, out *Fillable) (*Pipeline, error) {
pv := v.Dereference()

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.

what does v.Concrete() report here?

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.

Is Reference's second return value (path []string) the same as the .Path().String() here? (also both before and after v&pv)

@aluzzardi aluzzardi closed this Apr 6, 2021
@aluzzardi
aluzzardi deleted the pipeline-manager branch April 20, 2021 01:12
aluzzardi pushed a commit that referenced this pull request Sep 16, 2022
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.

2 participants