Skip to content

use proper buffer size for content get#4664

Merged
mxpv merged 1 commit intocontainerd:masterfrom
deitch:ctr-client-optimize
Oct 27, 2020
Merged

use proper buffer size for content get#4664
mxpv merged 1 commit intocontainerd:masterfrom
deitch:ctr-client-optimize

Conversation

@deitch
Copy link
Copy Markdown
Contributor

@deitch deitch commented Oct 27, 2020

The command-line ctr content get uses io.Copy(), with the default buffer size of 32KB. This creates significant slow-downs on large files, as the grpc overhead must be incurred with each 32KB chunk.

This PR changes it to 1MB (1<<20), which is what we use for ingesting content, using io.CopyBuffer() instead.

I ran 10 tests on a 1.0GB file, ctr content get each with and without the change (yeah, I probably should do a proper go benchmark with hundreds of iterations; if people insist, I can, but it seems unnecessary for such a small change). In all cases I sent the results to /dev/null, to avoid any potential issues with disk writes.

  • Average before: 13.752s
  • Average after: 2.678s

I was rather blown away by the results.
Obviously, little difference on blobs not much bigger than 32KB, no difference at all on blobs 32KB or smaller.

Discussed with @dmcgowan and @estesp on Slack.

@k8s-ci-robot
Copy link
Copy Markdown

Hi @deitch. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Oct 27, 2020

Build succeeded.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM

@mxpv mxpv merged commit 619f96c into containerd:master Oct 27, 2020
@deitch deitch deleted the ctr-client-optimize branch October 27, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants