Skip to content

Differ: write diff to the content store over bufio writer#2388

Merged
AkihiroSuda merged 1 commit into
moby:masterfrom
ktock:containerd-overlaydiff-bufcopy
Oct 4, 2021
Merged

Differ: write diff to the content store over bufio writer#2388
AkihiroSuda merged 1 commit into
moby:masterfrom
ktock:containerd-overlaydiff-bufcopy

Conversation

@ktock
Copy link
Copy Markdown
Collaborator

@ktock ktock commented Oct 4, 2021

Fixes: #2365
Alternative of #2366

This commit mitigates the recent performance regression of layer exports with containerd worker + overlayfs differ.

The following measures time to take for exporting layers of the following Dockerfile with changing the layer size from 50MB to 1GB (source).

FROM ghcr.io/stargz-containers/ubuntu:20.04-org
RUN head -c ${SIZE} </dev/urandom > /sample

Measured on GitHub Actions ubuntu-20.04 runner.

containerd worker

The regression is mitigated by this patch.

master version

https://github.com/ktock/buildkit/actions/runs/1295331304

The overlay differ + containerd worker shows about 2x slower exports.

${SIZE} overlay differ(sec) walking differ(sec) rate(overlay/walking)
1GB 89.7 43.0 2.08
500MB 43.5 22.7 1.92
100MB 9.1 4.7 1.94
50MB 4.6 2.5 1.84

(avg. of 3 samples)

This patch

https://github.com/ktock/buildkit/actions/runs/1301685570

Mitigates the performance regression to about 10%.

${SIZE} overlay differ(sec) walking differ(sec) rate(overlay/walking)
1GB 47.7 42.7 1.12
500MB 25.5 23.0 1.10
100MB 5.2 4.7 1.11
50MB 2.6 2.6 1.0

(avg. of 3 samples)

OCI worker

No large regression is observed.

master

https://github.com/ktock/buildkit/actions/runs/1295331304

${SIZE} overlay differ(sec) walking differ(sec) rate(overlay/walking)
1GB 42.8 43.9 0.97
500MB 22.6 23.2 0.97
100MB 4.6 4.9 0.94
50MB 2.3 2.5 0.92

This patch

https://github.com/ktock/buildkit/actions/runs/1301685570

${SIZE} overlay differ(sec) walking differ(sec) rate(overlay/walking)
1GB 41.7 41.0 1.02
500MB 21.5 22.0 0.97
100MB 4.3 4.5 0.95
50MB 2.2 2.4 0.91

Comment thread cache/blobs_linux.go Outdated
}
}()

bufW := bufio.NewWriterSize(cw, 131072)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Any suggestions for the buffer size? Tried 64KiB but the it made the export slower in +20-30% range.
https://github.com/ktock/buildkit/actions/runs/1301780687

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: write it as 128 * 1024

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the review. Fixed.

@ktock ktock requested a review from tonistiigi October 4, 2021 02:14
Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Could you post results with oci worker as well for comparison (just with the patch)?

Comment thread cache/blobs_linux.go Outdated
}
}()

bufW := bufio.NewWriterSize(cw, 131072)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: write it as 128 * 1024

@ktock ktock force-pushed the containerd-overlaydiff-bufcopy branch from c4e1a97 to 2bfd729 Compare October 4, 2021 02:39
@ktock
Copy link
Copy Markdown
Collaborator Author

ktock commented Oct 4, 2021

Could you post results with oci worker as well for comparison (just with the patch)?

Added the results with OCI worker.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
@ktock ktock force-pushed the containerd-overlaydiff-bufcopy branch from 2bfd729 to 4f3e74c Compare October 4, 2021 02:43
@AkihiroSuda AkihiroSuda merged commit 10947b0 into moby:master Oct 4, 2021
@ktock ktock deleted the containerd-overlaydiff-bufcopy branch October 4, 2021 08:10
@crazy-max crazy-max added this to the v0.10.0 milestone Feb 4, 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.

[master] Large performance regression exporting layers with containerd worker

4 participants