Skip to content

Component chaining kills performance #102

Closed

Description

@aluzzardi

Chaining components (e.g. referencing one component from another) is exponentially slow and CPU intensive.

Example with C --> B --> A:

A: #dagger: compute: []

B: #dagger: compute: [
	dagger.#FetchContainer & { ref: "alpine" },
	dagger.#Exec & {
		args: ["sh", "-c", "echo hello world"]
		mount: "/tmp/A": from: A
	}
]

C: #dagger: compute: [
	dagger.#FetchContainer & { ref: "alpine" },
	dagger.#Exec & {
		args: ["sh", "-c", "echo hello world"]
		mount: "/tmp/B": from: B
	}
]

D: #dagger: compute: [
	dagger.#FetchContainer & { ref: "alpine" },
	dagger.#Exec & {
		args: ["sh", "-c", "echo hello world"]
		mount: "/tmp/C": from: C
	}
]
  • The above takes 13 seconds to compute (CPU at full blast)
  • If I remove a layer (C mounts from A directly), it goes down to 1.3 seconds
  • If I add a layer (D which mounts from C), I don't know how long it takes, I killed it after 12 minutes of processing

Activity

  1. added
    kind/bug
    on Feb 5, 2021
  2. aluzzardi commented on Feb 8, 2021

    @aluzzardi
    ContributorAuthor

    Update: without using the imported definition, the performance is MUCH better:

    package main
    
    A: #dagger: compute: []
    
    B: #dagger: compute: [
    	{ do: "fetch-container",  ref: "alpine" },
    	{
    		do: "exec",
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/A": from: A
    	}
    ]
    
    C: #dagger: compute: [
    	{ do: "fetch-container",  ref: "alpine" },
    	{
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/B": from: B
    	}
    ]
    
    D: #dagger: compute: [
    	{ do: "fetch-container",  ref: "alpine" },
    	{
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/C": from: C
    	}
    ]
    

    DOCKER_OUTPUT=1 dagger compute ./examples/repro-102 2.75s user 0.15s system 110% cpu 2.608 total

    This is still exponentially slow, but much better. By adding E:

    DOCKER_OUTPUT=1 dagger compute ./examples/repro-102 26.56s user 0.87s system 174% cpu 15.756 total

  3. aluzzardi commented on Feb 9, 2021

    @aluzzardi
    ContributorAuthor

    Using dagger.#Op & {} with mount: from: seems to slow down cue pretty badly.

    cue eval 1.52s user 0.06s system 185% cpu 0.854 total

    package main
    
    import "dagger.cloud/dagger"
    
    A: #dagger: compute: []
    
    B: #dagger: compute: [
    	dagger.#FetchContainer & { ref: "alpine" },
    	dagger.#Exec & {
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/A": from: A
    	}
    ]
    
    C: #dagger: compute: [
    	dagger.#FetchContainer & { ref: "alpine" },
    	dagger.#Exec & {
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/B": from: B
    	}
    ]
    
    D: #dagger: compute: [
    	dagger.#FetchContainer & { ref: "alpine" },
    	dagger.#Exec & {
    		args: ["sh", "-c", "echo hello world"]
    		mount: "/tmp/B": from: C
    	}
    ]
    
  4. verdverm commented on Mar 2, 2021

    @verdverm
    Contributor

    Relevant issues from Cue GH repo

  5. aluzzardi commented on Mar 9, 2021

    @aluzzardi
    ContributorAuthor

    I believe this has been fixed by #159

    @verdverm Do you want to keep this issue open to track down the upstream issues, or should we just close it?

  6. verdverm commented on Mar 9, 2021

    @verdverm
    Contributor

    We can probably close it since this particular repro is not an issue anymore.

    Do we have (or add) a label for kind/perf?

  7. added and removed
    kind/bug
    on Mar 9, 2021
  8. aluzzardi commented on Mar 9, 2021

    @aluzzardi
    ContributorAuthor

    We can probably close it since this particular repro is not an issue anymore.

    Okay closing this one then. Thanks!

    Do we have (or add) a label for kind/perf?

    Now we do :)

  9. added this to the beta milestone on May 11, 2021
  10. added a commit that references this issue on Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions