-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Bin optimize #10718
base: master
Are you sure you want to change the base?
Bin optimize #10718
Conversation
00a0ea4
to
8c1df69
Compare
This pull request introduces 1 alert when merging 8c1df69b4b2748909ee6734a8491182b95e5ebf9 into 53e5fe6 - view on LGTM.com new alerts:
|
Makefile.cache
Outdated
$(SONIC_VERSION_CONTROL_COMPONENTS) \ | ||
$(SONIC_VERSION_CACHE) \ |
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.
Please fix the TAB/SPACE alignment issue.
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.
Fixed
Makefile.work
Outdated
scripts/generate_buildinfo_config.sh) | ||
|
||
# Generate the slave Dockerfile, and prepare build info for it | ||
$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) DOCKER_EXTRA_OPTS=$(DOCKER_EXTRA_OPTS) DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) j2 $(SLAVE_DIR)/Dockerfile.j2 > $(SLAVE_DIR)/Dockerfile) | ||
$(shell CONFIGURED_ARCH=$(CONFIGURED_ARCH) MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) j2 $(SLAVE_DIR)/Dockerfile.user.j2 > $(SLAVE_DIR)/Dockerfile.user) | ||
$(shell BUILD_SLAVE=y DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY) scripts/prepare_docker_buildinfo.sh $(SLAVE_BASE_IMAGE) $(SLAVE_DIR)/Dockerfile $(CONFIGURED_ARCH) "" $(BLDENV)) |
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.
It has impact on the value of SLAVE_BASE_TAG, we may need to run it before line 160.
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.
Fixed
@@ -0,0 +1,25 @@ | |||
libhiredis-dev==0.14.0-3~bpo9+1 |
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.
Are the files in files/build/versions checked in by mistake? We will not enable reproducible build on master branch.
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.
Removed
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.
I mean to remove all the files in files/build/versions.
@@ -668,8 +673,10 @@ sudo LANG=C DOCKER_HOST="$DOCKER_HOST" chroot $FILESYSTEM_ROOT docker info | |||
{% set imagefilepath = image.split(':')|first -%} | |||
{% set imagefilename = imagefilepath.split('/')|last -%} | |||
{% set imagename = imagefilename.split('.')|first -%} | |||
function {{imagename}}() |
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.
Why dynamic function name? Can we use static function name and pass parameter instead?
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.
done
if [ ! -z "${USE_TMPFS}" ]; then | ||
NPROC=$(nproc) | ||
if [ ${NPROC} -gt 16 ]; then NPROC=16; fi | ||
printf '%s\n' "${DLIST[@]}" | xargs -I{} -P ${NPROC} bash -c " SONIC_IMAGE_VERSION=${SONIC_IMAGE_VERSION} {}" | ||
else | ||
printf '%s\n' "${DLIST[@]}" | xargs -I{} -P 1 bash -c "SONIC_IMAGE_VERSION=${SONIC_IMAGE_VERSION} {}" | ||
fi | ||
|
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.
Could you please improve the logic? The line 703 and 705 can be called only once.
Why there is a space chareacter in the command line before SONIC_IMAGE_VERSION in line 703, comparing to line 705?
NPROC=$(nproc)
[ $NPROC > 16 ] && NPROC=16
[ In some conditions ] && NPROC=1
printf '%s\n' "${DLIST[@]}" | xargs -I{} -P ${NPROC} bash -c " SONIC_IMAGE_VERSION=${SONIC_IMAGE_VERSION} {}"
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.
done
8c1df69
to
d33da70
Compare
This pull request introduces 1 alert when merging d33da70678d70e9e095792d0c6ed289d91fd13f0 into 7c4ee43 - view on LGTM.com new alerts:
|
d33da70
to
5a9bb22
Compare
This pull request introduces 1 alert when merging 5a9bb2222fc70ca54f6fcd29092cc54a025b8c36 into db94886 - view on LGTM.com new alerts:
|
Makefile.work
Outdated
|
||
PREPARE_DOCKER=BUILD_SLAVE=y DBGOPT='$(DBGOPT)' SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \ |
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.
Missing one of the options of command scripts/prepare_docker_buildinfo.sh as below:
DEFAULT_CONTAINER_REGISTRY=$(DEFAULT_CONTAINER_REGISTRY)
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.
Done as part of #10613
@Kalimuthu-Velappan , can we split the PR into several small ones? |
5a9bb22
to
6182b36
Compare
It is already split into separate PR for version cache. |
fb0038b
to
513313d
Compare
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
The current SONIC build infrastructure always prepares the rootfs for final image generation. Because of rootfs preparation, final image generation takes long regardless of SONiC changes. The rootfs preparation consists of two parts. Debian packages installation Bootstrap preparation General packages installation, such as curl, vim, sudo, python3, etc Sonic packages installation Packages that are built and installed from the sonic repo. Docker images that are built and installed from the sonic repo The build time can be optimized by generating the Debian packages as a base image and it can be run in parallel with the other targets, before the final image. Benefits: - High hit rate, for fewer dependencies. - Reduce the cache size. - Improve the concurrency when the cache is not hit, the step has small dependencies and can be run with any other steps. Other enhancements: - The docker load is also optimized by running in parallel. - Added support for gipz compression - Added tmpfs support for rootfs and final image generation.
513313d
to
0e5c319
Compare
if $( unzip -l $ONIE_INSTALLER_PAYLOAD 2>/dev/null 1>/dev/null ); then | ||
unzip -o $ONIE_INSTALLER_PAYLOAD -d $demo_mnt/$image_dir | ||
else | ||
tar -C $demo_mnt/$image_dir -xvf $ONIE_INSTALLER_PAYLOAD |
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.
Do you add the new ONIE_INSTALLER_PAYLOAD format? Why need to handle the tar case? It is relative to new feature SONIC_FS_IMAGE_COMPRESSION_TYPE? If yes, suggest to send a new PR for the different feature.
umount_allfs | ||
delete_rootfs_image | ||
if [[ -e ${FSROOT_IMAGE_FILE} ]]; then | ||
return | ||
fi | ||
|
||
if [[ "${SONIC_USE_TMPFS_BUILD}" == "y" ]] ; then | ||
sudo mount -t tmpfs -o size=${BUILD_TMP_ROOTFS_SIZE} tmpfs ${FSROOT_IMAGE_DIR} | ||
fi |
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 SONIC_USE_TMPFS_BUILD != y, all the options can be skipped, right? Do we need to check if SONIC_USE_TMPFS_BUILD == y before running the lines from 47~51?
umount_allfs | ||
delete_rootfs_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.
Looks likes mount_imagefs does some additional cleanup operations? Can we remove them? Better to have another command to do the cleanup explicitly.
|
||
|
||
|
||
|
||
|
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.
Please remove the empty lines at the end of the script file, thanks.
rootfs) | ||
rootfs_fun $1 $2 | ||
;; | ||
overlayfs) |
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.
Do not find any reference to overlayfs, can we remove it?
#sudo mount -o rw,loop ${FSROOT_IMAGE_FILENAME} ${FILESYSTEM_BASE}/${FSROOT_IMAGE_FILENAME} || true | ||
#sudo mkdir -p ${FILESYSTEM_BASE}/fsroot ${FILESYSTEM_BASE}/upper ${FILESYSTEM_BASE}/work | ||
#sudo chmod 777 ${FILESYSTEM_BASE} | ||
#sudo mount -t overlay overlay -o lowerdir=${FILESYSTEM_BASE}/${FSROOT_IMAGE_FILENAME},upperdir=${FILESYSTEM_BASE}/upper,workdir=${FILESYSTEM_BASE}/work ${FILESYSTEM_BASE}/fsroot |
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.
Remove the no use lines?
## the ONIE installer image generation to speed up the processing. | ||
## | ||
## USAGE: | ||
## ./tmpfs <storage> <operation> |
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.
The description looks like out of date, right? Change ./tmpfs to fsutil.sh? And the script does not only handle the tmpfs for different mount point, right?
@Kalimuthu-Velappan Could you resolve the conflicts? |
Sonic image build optimization
The current SONIC build infrastructure always prepares the rootfs for final image generation.
Because of rootfs preparation, final image generation takes long regardless of SONiC changes.
The rootfs preparation consists of two parts.
Debian packages installation
Bootstrap preparation
General packages installation, such as curl, vim, sudo, python3, etc
Sonic packages installation
Packages that are built and installed from the sonic repo.
Docker images that are built and installed from the sonic repo
The build time can be optimized by generating the Debian packages as a base image and
it can be run in parallel with the other targets, before the final image.
Benefits:
- High hit rate, for fewer dependencies.
- Reduce the cache size.
- Improve the concurrency when the cache is not hit, the step has small dependencies and can be run with any other steps.
The docker load is also optimized by running in parallel.
Added support for gipz compression
Added tmpfs support for rootfs and final image generation.
Why I did it
How I did it
How to verify it
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)