-
Notifications
You must be signed in to change notification settings - Fork 206
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
support generating new image with separate blob for prefetched files #1649
base: master
Are you sure you want to change the base?
support generating new image with separate blob for prefetched files #1649
Conversation
Major changes: 1. Added compatibility for rafs v5/v6 formats. 2. Set IS_PREFETCHBLOB flag in BlobInfo for prefetchblob. 3. Introduced two new options for storing prefetchblobID path and the optimized bootstrap path. Signed-off-by: Xing Ma <[email protected]>
We can statically analyze the image entrypoint dependency, or use runtime dynamic analysis technologies such as ebpf, fanotify, metric, etc. to obtain the container file access pattern, and then build this part of data into an independent image layer: * preferentially fetch blob during the image startup phase to reduce network and disk IO. * avoid frequent image builds, allows for better local cache utilization. Implement optimize subcommand of nydusify to generate a new image, which references a new blob included prefetch file chunks. ``` nydusify optimize --policy separated-prefetch-blob \ --source $existed-nydus-image \ --target $new-nydus-image \ --prefetch-files /path/to/prefetch-files ``` More detailed process is as follows: 1. nydusify first downloads the source image and bootstrap, utilize nydus-image to output a new bootstrap along with an independent prefetchblob; 2. nydusify generate&push new meta layer including new bootstrap and the prefetch-files , also generates&push new manifest/config/prefetchblob, completing the incremental image build. Signed-off-by: Xing Ma <[email protected]>
08bff89
to
8437d8d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1649 +/- ##
==========================================
- Coverage 60.10% 59.98% -0.13%
==========================================
Files 147 147
Lines 49513 49603 +90
Branches 46994 47057 +63
==========================================
- Hits 29762 29756 -6
- Misses 17970 18065 +95
- Partials 1781 1782 +1
|
.help("Output path of the new bootstrap"), | ||
) | ||
.arg( | ||
Arg::new("output-path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name it output-json
and reuse the BuildOutput
struct in builder/src/core/context.rs
?
Arg::new("output-path") | ||
.long("output-path") | ||
.short('o') | ||
.help("Output path of for save hot blob id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File path to save optimization information in JSON format
@@ -79,6 +79,8 @@ bitflags! { | |||
const _V5_NO_EXT_BLOB_TABLE = 0x8000_0000; | |||
/// Blob is generated with chunkdict. | |||
const IS_CHUNKDICT_GENERATED = 0x0000_0200; | |||
/// Blob is a hot blob | |||
const IS_PREFETCHBLOB = 0x0001_0000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about IS_SEPARATED_WITH_PREFETCH_FILES
?
@@ -79,6 +79,8 @@ bitflags! { | |||
const _V5_NO_EXT_BLOB_TABLE = 0x8000_0000; | |||
/// Blob is generated with chunkdict. | |||
const IS_CHUNKDICT_GENERATED = 0x0000_0200; | |||
/// Blob is a hot blob |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about Blob is generated with separated prefetch files.
.
@@ -508,6 +510,12 @@ impl BlobInfo { | |||
} | |||
} | |||
|
|||
pub fn set_hot_blob_feature(&mut self, is_prefetchblob: bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_separated_with_prefetch_files_feature
@@ -0,0 +1,536 @@ | |||
// Copyright 2023 Nydus Developers. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2024
return nil | ||
} | ||
|
||
// Optimize covert and push a new optimized nydus image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
covert
-> converts
return errors.Wrap(err, "Init source image parser") | ||
} | ||
sourceParser, err := parser.New(sourceRemote, runtime.GOARCH) | ||
if sourceParser == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil {
return &blobDesc, nil | ||
} | ||
|
||
func pushCompoundBootstrap(ctx context.Context, opt Opt, buildInfo BuildInfo) (*bootstrapInfo, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushCompoundBootstrap
-> pushNewBootstrap
?
bootstrapTarRa, err := os.Open(bootstrapTarPath) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "open bootstrap tar file") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer bootstrapTarRa.Close()
Thanks! |
Relevant Issue #1589
The objective is to generate a new image, which references a new blob included prefetch file chunks. This will accelerate an startup performance due to high-priority pulling of prefetch blob.
Details
Implement optimize subcommand of nydusify to generate a new image, which references a new blob included prefetch file chunks.
Types of changes
What types of changes does your PullRequest introduce? Put an
x
in all the boxes that apply:Checklist
Go over all the following points, and put an
x
in all the boxes that apply.