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

storage: add runtime support for batch chunk #1289

Merged
merged 6 commits into from
Jun 15, 2023

Conversation

hangvane
Copy link
Contributor

@hangvane hangvane commented May 18, 2023

Add the runtime support for small chunk mergence.

basic usage

Add the --batch-size arg to command to enable chunk mergence for supported conversion types:

nydus-image create --bootstrap ~/bootstrap --blob-dir ~/blobs ~/source --batch-size 0x100000

nydus-image create --type estargz-rafs --bootstrap ~/bootstrap --blob-dir ~/blobs ~/source.tar.gz --batch-size 0x100000

nydus-image create --type targz-rafs --bootstrap ~/bootstrap --blob-dir ~/blobs ~/source.tar.gz --batch-size 0x100000

nydus-image create --type tar-rafs --bootstrap ~/bootstrap --blob-dir ~/blobs ~/source.tar --batch-size 0x100000

nydusify convert --source node:latest --target node:latest-nydus-batch-256K --batch-size 0x40000

benchmarks

Tested on 4C4G VM, pulled from private harbor registry in the same Campus Network. Cleaned containerd images and nydus-snapshotter cache before each run. Each value is averaged over five runs.

repositories command tags prefetch startup e2e time (s) %
python python --version latest-rafs 2.746 -
python python --version latest-rafs (second run) 2.995 +9.08%
python python --version latest-rafs-batch-64K 2.202 -19.80%
python python --version latest-rafs-batch-128K 2.580 -6.05%
python python --version latest-rafs-batch-256K 2.272 -17.27%
python python --version latest-rafs-batch-512K 2.157 -21.44%
python python --version latest-rafs-batch-1M 1.628 -40.71%
python python --version latest-rafs 1.369 -
python python --version latest-rafs (second run) 1.174 -14.25%
python python --version latest-rafs-batch-64K 1.052 -23.15%
python python --version latest-rafs-batch-128K 1.081 -21.05%
python python --version latest-rafs-batch-256K 1.075 -21.48%
python python --version latest-rafs-batch-512K 1.100 -19.62%
python python --version latest-rafs-batch-1M 1.100 -19.60%
python python --version alpine3.17-rafs 0.784 -
python python --version alpine3.17-rafs (second run) 0.803 +2.42%
python python --version alpine3.17-rafs-batch-64K 0.811 +3.41%
python python --version alpine3.17-rafs-batch-128K 0.818 +4.30%
python python --version alpine3.17-rafs-batch-256K 0.764 -2.58%
python python --version alpine3.17-rafs-batch-512K 0.776 -0.96%
python python --version alpine3.17-rafs-batch-1M 0.750 -4.33%
python python --version alpine3.17-rafs 0.850 -
python python --version alpine3.17-rafs (second run) 0.911 +7.17%
python python --version alpine3.17-rafs-batch-64K 0.805 -5.22%
python python --version alpine3.17-rafs-batch-128K 0.834 -1.86%
python python --version alpine3.17-rafs-batch-256K 0.813 -4.35%
python python --version alpine3.17-rafs-batch-512K 0.829 -2.47%
python python --version alpine3.17-rafs-batch-1M 0.805 -5.21%
node npm -v latest-rafs 8.395 -
node npm -v latest-rafs (second run) 11.928 +42.08%
node npm -v latest-rafs-batch-64K 12.704 +51.32%
node npm -v latest-rafs-batch-128K 9.614 +14.51%
node npm -v latest-rafs-batch-256K 9.164 +9.15%
node npm -v latest-rafs-batch-512K 5.605 -33.24%
node npm -v latest-rafs-batch-1M 4.192 -50.07%
node npm -v latest-rafs 1.593 -
node npm -v latest-rafs (second run) 1.595 +0.11%
node npm -v latest-rafs-batch-64K 1.576 -1.07%
node npm -v latest-rafs-batch-128K 1.506 -5.48%
node npm -v latest-rafs-batch-256K 1.517 -4.78%
node npm -v latest-rafs-batch-512K 1.543 -3.14%
node npm -v latest-rafs-batch-1M 1.589 -0.22%
node npm -v 19-alpine-rafs 2.829 -
node npm -v 19-alpine-rafs (second run) 2.667 -5.72%
node npm -v 19-alpine-rafs-batch-64K 3.423 +21.01%
node npm -v 19-alpine-rafs-batch-128K 3.097 +9.50%
node npm -v 19-alpine-rafs-batch-256K 3.249 +14.85%
node npm -v 19-alpine-rafs-batch-512K 3.054 +7.95%
node npm -v 19-alpine-rafs-batch-1M 2.792 -1.32%
node npm -v 19-alpine-rafs 1.372 -
node npm -v 19-alpine-rafs (second run) 1.414 +3.06%
node npm -v 19-alpine-rafs-batch-64K 1.392 +1.46%
node npm -v 19-alpine-rafs-batch-128K 1.396 +1.73%
node npm -v 19-alpine-rafs-batch-256K 1.430 +4.19%
node npm -v 19-alpine-rafs-batch-512K 1.393 +1.50%
node npm -v 19-alpine-rafs-batch-1M 1.411 +2.86%

This PR is related to #1202, #884, #885, dragonflyoss/Dragonfly2#1858

@hangvane hangvane requested a review from a team as a code owner May 18, 2023 08:59
@hangvane hangvane requested review from jiangliu, changweige and adamqqqplay and removed request for a team May 18, 2023 08:59
@anolis-bot
Copy link
Collaborator

@hangvane , a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/74029

@anolis-bot
Copy link
Collaborator

@hangvane , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/74032

@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Merging #1289 (af879e0) into master (b4c76cf) will decrease coverage by 0.49%.
The diff coverage is 21.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1289      +/-   ##
==========================================
- Coverage   45.90%   45.42%   -0.49%     
==========================================
  Files         123      123              
  Lines       37033    37254     +221     
  Branches    37033    37254     +221     
==========================================
- Hits        16999    16921      -78     
- Misses      19139    19439     +300     
+ Partials      895      894       -1     
Impacted Files Coverage Δ
rafs/src/builder/core/node.rs 41.95% <0.00%> (-0.68%) ⬇️
storage/src/cache/fscache/mod.rs 0.00% <0.00%> (ø)
storage/src/meta/batch.rs 0.00% <0.00%> (ø)
storage/src/cache/mod.rs 51.52% <3.57%> (-9.65%) ⬇️
storage/src/cache/cachedfile.rs 31.96% <11.42%> (-0.15%) ⬇️
storage/src/meta/mod.rs 56.09% <29.65%> (-2.83%) ⬇️
storage/src/cache/filecache/mod.rs 67.76% <66.66%> (+0.23%) ⬆️
storage/src/meta/chunk_info_v2.rs 68.70% <81.81%> (-0.17%) ⬇️
storage/src/meta/chunk_info_v1.rs 95.14% <100.00%> (+0.57%) ⬆️

... and 8 files with indirect coverage changes

@anolis-bot
Copy link
Collaborator

@hangvane , the title has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/74033

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
nydus_ci❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@imeoer
Copy link
Collaborator

imeoer commented May 19, 2023

Good work! This seems to be valuable in most use cases.

  1. Can we also give the perf result for wordpress image?
  2. What's the network bandwidth limitation in the tests? It seems that the startup time is slowed down when prefetch all is enabled.
  3. Can we use 1MB as the default --batch-size value?

@hangvane
Copy link
Contributor Author

hangvane commented May 20, 2023

Good work! This seems to be valuable in most use cases.

  1. Can we also give the perf result for wordpress image?
  2. What's the network bandwidth limitation in the tests? It seems that the startup time is slowed down when prefetch all is enabled.
  3. Can we use 1MB as the default --batch-size value?

2.The images are pulled from a private harbor registry in the same Campus Network with 100Mbps bandwidth. The benchmark is just a rough estimation for container startup time beacuse: (1) The startup time difference between the same image latest-rafs and latest-rafs (second run) shows that it is volatile; (2) The benchmark does not utilize the containers to run workloads, but only checks the versions of python and npm, which may amplify the shortcomings of prefetching, which could occupy network and I/O resources to preload useless data and slow down on-demand requests; (3) The benchmark config follows the default config settings, and the default setting of 8 prefetching threads may be too many for the 4C4G VM and network bandwidth. Anyway, the benchmark is just a rough estimation for presentation. We should precisely evaluate the performance later. Maybe it should be assigned to guangyuan.

1.Wordpress depends on an external database and does not have a short inspection command to exit the container after execution, like python --version. We should precisely evaluate the performance of Wordpress later.

3.It is said that the best practice of the size of read amplification is 128K in datacenter scenarios. Just from a performance point of view, I guess 256K-512K would be good as default value. With good prefetch list assisted at build time, maybe 1M is the best.

@anolis-bot
Copy link
Collaborator

@hangvane , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/74301

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@imeoer
Copy link
Collaborator

imeoer commented May 22, 2023

@hangvane

Ok, thanks, we can set the default value of --batch-size to 128k/256k/512k/1MB in nydusify to compare the wordpress image with the master branch.

Please also add some tests to passing the codecov test (>=25%).

cc @jiangliu

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
nydus_ci❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
nydus_ci❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
nydus_ci❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@hangvane
Copy link
Contributor Author

/retest

@anolis-bot
Copy link
Collaborator

@hangvane , the test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/76212

@anolis-bot
Copy link
Collaborator

@hangvane , The CI test is completed, please check result:

Test CaseTest Result
nydus_ci❌ FAIL

Sorry, your test job failed. Please get the details in the link.

@yqleng1987
Copy link
Contributor

/retest

@anolis-bot
Copy link
Collaborator

@yqleng1987 , the test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/77009

@anolis-bot
Copy link
Collaborator

@yqleng1987 , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

@anolis-bot
Copy link
Collaborator

@jiangliu , the code has been updated, so a new test job has been submitted. Please wait in patience. The test job url: https://tone.openanolis.cn/ws/nrh4nnio/test_result/78487

@anolis-bot
Copy link
Collaborator

@jiangliu , The CI test is completed, please check result:

Test CaseTest Result
build rust golang image✅ SUCCESS
compile nydusd✅ SUCCESS
compile ctr remote✅ SUCCESS
compile nydus snapshotter✅ SUCCESS
run container with rafs✅ SUCCESS
run container with zran✅ SUCCESS
run container with rafs and compile linux✅ SUCCESS

Congratulations, your test job passed!

} else if first_entry.is_batch() {
// Assert each entry in chunks is Batch chunk.

let first_batch_idx = first_entry.get_batch_index();
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should ensure that a chunk is batch chunk before calling get_batch_index(), otherwise it may trigger the assertion in BlobChunkInfoV2Ondisk::get_batch_index().

@jiangliu jiangliu merged commit 3ab3a75 into dragonflyoss:master Jun 15, 2023
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.

6 participants