Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converter: speed up conversion #352

Merged
merged 8 commits into from
Feb 24, 2023
Merged

Conversation

imeoer
Copy link
Collaborator

@imeoer imeoer commented Feb 13, 2023

Support the new option `--type tar-rafs` of builder for Pack method in converter
package, enables converting OCI tar blob stream into nydus blob directly,
eliminating the need to decompress it to a local directory first, thus
greatly accelerating the pack process.

Signed-off-by: Yan Song [email protected]

@imeoer imeoer force-pushed the converter-speedup branch 2 times, most recently from d9ec48f to 80ffde8 Compare February 13, 2023 04:15
@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2023

Codecov Report

Base: 29.28% // Head: 29.36% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (1bdade8) compared to base (d78c617).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   29.28%   29.36%   +0.07%     
==========================================
  Files          38       38              
  Lines        3811     3811              
==========================================
+ Hits         1116     1119       +3     
+ Misses       2563     2560       -3     
  Partials      132      132              
Impacted Files Coverage Δ
config/default.go 0.00% <ø> (ø)
pkg/blob/blob_manager.go 32.65% <0.00%> (+3.06%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@imeoer imeoer requested a review from changweige February 13, 2023 06:40
@imeoer imeoer force-pushed the converter-speedup branch 3 times, most recently from 16c151e to be925b2 Compare February 15, 2023 03:38
imeoer added a commit to imeoer/acceleration-service that referenced this pull request Feb 15, 2023
See containerd/nydus-snapshotter#352

It's a internal optimization, so just only bump nydus-snapshotter
package to latest version.

Signed-off-by: Yan Song <[email protected]>
imeoer added a commit to imeoer/image-service that referenced this pull request Feb 15, 2023
Default to enable --type tar-rafs option for nydus-image, which
converting OCI tar blob stream into nydus blob directly, eliminating
the need to decompress it to a local directory first, thus greatly
accelerating the pack process.

For compatibility, we still support env `NYDUS_DISABLE_TAR2RAFS=true`
variable to disable the optimization.

It's a internal feature, so we just only bump acceleration-service
and nydus-snapshotter packages to latest version.

Related PR: containerd/nydus-snapshotter#352

Signed-off-by: Yan Song <[email protected]>
imeoer added a commit to imeoer/image-service that referenced this pull request Feb 15, 2023
Default to enable `--type tar-rafs` option for nydus-image, which
converting OCI tar blob stream into nydus blob directly, eliminating
the need to decompress it to a local directory first, thus greatly
accelerating the pack process.

For compatibility, we still support env `NYDUS_DISABLE_TAR2RAFS=true`
variable to disable the optimization.

It's an internal feature, so we just only bump acceleration-service
and nydus-snapshotter packages to the latest version.

Related PR: containerd/nydus-snapshotter#352

Signed-off-by: Yan Song <[email protected]>
imeoer added a commit to imeoer/image-service that referenced this pull request Feb 15, 2023
Default to enable `--type tar-rafs` option for nydus-image, which
converting OCI tar blob stream into nydus blob directly, eliminating
the need to decompress it to a local directory first, thus greatly
accelerating the pack process.

For compatibility, we still support env `NYDUS_DISABLE_TAR2RAFS=true`
variable to disable the optimization.

It's an internal feature, so we just only bump acceleration-service
and nydus-snapshotter packages to the latest version.

Related PR: containerd/nydus-snapshotter#352

Signed-off-by: Yan Song <[email protected]>
@changweige
Copy link
Member

Does this PR depend on nydusd and nydus-image 2.2+ ?

// stream into nydus blob directly, the tar2rafs eliminates the
// need to decompress it to a local directory first, thus greatly
// accelerating the pack process.
FeatureTar2Rafs Feature = "--type tar-rafs"
Copy link
Member

Choose a reason for hiding this comment

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

As constat string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -392,61 +405,86 @@ func packRef(ctx context.Context, dest io.Writer, opt PackOption) (io.WriteClose
}
}()

blobMetaPath := filepath.Join(workDir, "blob.meta")
blobMetaFifo, err := fifo.OpenFifo(ctx, blobMetaPath, syscall.O_CREAT|syscall.O_RDONLY|syscall.O_NONBLOCK, 0644)
rafsBlobPath := filepath.Join(workDir, "blob.rafs")
Copy link
Member

Choose a reason for hiding this comment

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

Make "blob.rafs" as a constant string ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a temp file, just be used as a unique name.

if err != nil {
return nil, errors.Wrapf(err, "create fifo file")
}

sourcePath := filepath.Join(workDir, "blob.targz")
sourceFifo, err := fifo.OpenFifo(ctx, sourcePath, syscall.O_CREAT|syscall.O_WRONLY|syscall.O_NONBLOCK, 0644)
tarBlobPath := filepath.Join(workDir, "blob.targz")
Copy link
Member

Choose a reason for hiding this comment

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

Make "blob.targz" as a constant string ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member

@changweige changweige left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Only a few tiny comments left

Support the new option `--type tar-rafs` of builder for Pack method in converter
package, enables converting OCI tar blob stream into nydus blob directly,
eliminating the need to decompress it to a local directory first, thus
greatly accelerating the pack process.

Signed-off-by: Yan Song <[email protected]>
The Pack conversion workflow will hang on `io.Copy` once the
builder execution failed, this patch fixes it.

Signed-off-by: Yan Song <[email protected]>
The `Features` option enables feature collection for nydus-image builder.

Signed-off-by: Yan Song <[email protected]>
We should fallback some cli flags automatically for older versions of builder.

Signed-off-by: Yan Song <[email protected]>
The `PrefetchPatterns` option should be paased to the builder (nydus-image)
merge subcommand, otherwise the prefetch feature table will not work in
the final bootstrap (used in nydus image).

Signed-off-by: Yan Song <[email protected]>
@changweige changweige merged commit d1f5b25 into containerd:main Feb 24, 2023
@imeoer imeoer mentioned this pull request Mar 1, 2023
imeoer added a commit to imeoer/acceleration-service that referenced this pull request Mar 1, 2023
See containerd/nydus-snapshotter#352

It's a internal optimization, so just only bump nydus-snapshotter
package to latest version.

Signed-off-by: Yan Song <[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.

3 participants