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

support generating new image with separate blob for prefetched files #1649

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

Maxing1997
Copy link

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:

  • New feature (non-breaking change which adds functionality)

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@Maxing1997 Maxing1997 requested a review from a team as a code owner November 29, 2024 09:19
@Maxing1997 Maxing1997 requested review from imeoer, jiangliu and gaius-qi and removed request for a team November 29, 2024 09:20
@Maxing1997 Maxing1997 changed the title Maxing mr/nydusify optimize support generating new image with separate blob for prefetched files Nov 29, 2024
@Maxing1997 Maxing1997 force-pushed the maxing_mr/nydusify_optimize branch from 08bff89 to 8437d8d Compare November 29, 2024 13:56
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

Attention: Patch coverage is 0% with 115 lines in your changes missing coverage. Please review.

Project coverage is 60.01%. Comparing base (bb4744c) to head (6b13369).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
builder/src/optimize_prefetch.rs 0.00% 52 Missing ⚠️
src/bin/nydus-image/main.rs 0.00% 31 Missing ⚠️
contrib/nydusify/cmd/nydusify.go 0.00% 27 Missing ⚠️
storage/src/device.rs 0.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1649      +/-   ##
==========================================
- Coverage   60.10%   60.01%   -0.10%     
==========================================
  Files         147      147              
  Lines       49513    49583      +70     
  Branches    46994    47037      +43     
==========================================
- Hits        29762    29756       -6     
- Misses      17970    18045      +75     
- Partials     1781     1782       +1     
Files with missing lines Coverage Δ
storage/src/device.rs 66.63% <0.00%> (-0.36%) ⬇️
contrib/nydusify/cmd/nydusify.go 13.52% <0.00%> (-0.54%) ⬇️
src/bin/nydus-image/main.rs 0.59% <0.00%> (-0.01%) ⬇️
builder/src/optimize_prefetch.rs 0.00% <0.00%> (ø)

... and 3 files with indirect coverage changes

src/bin/nydus-image/main.rs Outdated Show resolved Hide resolved
src/bin/nydus-image/main.rs Outdated Show resolved Hide resolved
storage/src/device.rs Outdated Show resolved Hide resolved
storage/src/device.rs Outdated Show resolved Hide resolved
storage/src/device.rs Outdated Show resolved Hide resolved
contrib/nydusify/pkg/optimizer/optimizer.go Outdated Show resolved Hide resolved
contrib/nydusify/pkg/optimizer/optimizer.go Outdated Show resolved Hide resolved
contrib/nydusify/pkg/optimizer/optimizer.go Outdated Show resolved Hide resolved
contrib/nydusify/pkg/optimizer/optimizer.go Outdated Show resolved Hide resolved
contrib/nydusify/pkg/optimizer/optimizer.go Show resolved Hide resolved
@imeoer
Copy link
Collaborator

imeoer commented Dec 4, 2024

Thanks!

@Maxing1997 Maxing1997 force-pushed the maxing_mr/nydusify_optimize branch 5 times, most recently from 78717fb to e43282e Compare December 5, 2024 06:58
contrib/nydusify/cmd/nydusify.go Outdated Show resolved Hide resolved
Blobs []string `json:"blobs"`
}

func Build(option BuildOption) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

func Optimize

Copy link
Author

Choose a reason for hiding this comment

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

this conflicts Optimize declaration in optimizer.go

contrib/nydusify/pkg/optimizer/builder.go Outdated Show resolved Hide resolved
storage/src/device.rs Outdated Show resolved Hide resolved
Xing Ma added 2 commits December 9, 2024 12:02
Major changes:
1. Added compatibility for rafs v5/v6 formats;
2. Set IS_SEPARATED_WITH_PREFETCH_FILES flag in BlobInfo for prefetchblob;
3. Add option output-json to store build output.

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]>
@Maxing1997 Maxing1997 force-pushed the maxing_mr/nydusify_optimize branch from e43282e to 6b13369 Compare December 9, 2024 04:36
Copy link
Collaborator

@imeoer imeoer left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@imeoer imeoer merged commit b175fc4 into dragonflyoss:master Dec 9, 2024
23 of 24 checks passed
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.

2 participants