Skip to content

Commit

Permalink
Parallelize architectures in "make release"
Browse files Browse the repository at this point in the history
On my desktop, this took the KUBE_RELEASE_RUN_TESTS=n
"make release" down from 172s to 115s
  • Loading branch information
zmerlynn committed Apr 2, 2015
1 parent 412a836 commit 44b4c9f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
39 changes: 22 additions & 17 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -511,30 +511,35 @@ function kube::release::package_client_tarballs() {
# Find all of the built client binaries
local platform platforms
platforms=($(cd "${LOCAL_OUTPUT_BINPATH}" ; echo */*))
for platform in "${platforms[@]}" ; do
for platform in "${platforms[@]}"; do
local platform_tag=${platform/\//-} # Replace a "/" for a "-"
kube::log::status "Building tarball: client $platform_tag"
kube::log::status "Starting tarball: client $platform_tag"

local release_stage="${RELEASE_STAGE}/client/${platform_tag}/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/client/bin"
(
local release_stage="${RELEASE_STAGE}/client/${platform_tag}/kubernetes"
rm -rf "${release_stage}"
mkdir -p "${release_stage}/client/bin"

local client_bins=("${KUBE_CLIENT_BINARIES[@]}")
if [[ "${platform%/*}" == "windows" ]]; then
client_bins=("${KUBE_CLIENT_BINARIES_WIN[@]}")
fi
local client_bins=("${KUBE_CLIENT_BINARIES[@]}")
if [[ "${platform%/*}" == "windows" ]]; then
client_bins=("${KUBE_CLIENT_BINARIES_WIN[@]}")
fi

# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# KUBE_CLIENT_BINARIES array.
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/client/bin/"
# This fancy expression will expand to prepend a path
# (${LOCAL_OUTPUT_BINPATH}/${platform}/) to every item in the
# KUBE_CLIENT_BINARIES array.
cp "${client_bins[@]/#/${LOCAL_OUTPUT_BINPATH}/${platform}/}" \
"${release_stage}/client/bin/"

kube::release::clean_cruft
kube::release::clean_cruft

local package_name="${RELEASE_DIR}/kubernetes-client-${platform_tag}.tar.gz"
kube::release::create_tarball "${package_name}" "${release_stage}/.."
local package_name="${RELEASE_DIR}/kubernetes-client-${platform_tag}.tar.gz"
kube::release::create_tarball "${package_name}" "${release_stage}/.."
) &
done

kube::log::status "Waiting on tarballs"
wait || { kube::log::error "client tarball creation failed"; exit 1; }
}

# Package up all of the server binaries
Expand Down
18 changes: 16 additions & 2 deletions hack/lib/golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ kube::golang::build_binaries() {
local binaries
binaries=($(kube::golang::binaries_from_targets "${targets[@]}"))

kube::log::status "Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):" "${targets[@]}"
local platform
for platform in "${platforms[@]}"; do
for platform in "${platforms[@]}"; do (
kube::golang::set_platform_envs "${platform}"
kube::log::status "Building go targets for ${platform}:" "${targets[@]}"
kube::log::status "${platform}: Parallel go build started"

local -a statics=()
local -a nonstatics=()
Expand Down Expand Up @@ -369,6 +370,19 @@ kube::golang::build_binaries() {
"${statics[@]:+${statics[@]}}"
fi
fi
kube::log::status "${platform}: Parallel go build finished"
) &> "/tmp//${platform//\//_}.build" &
done

local fails=0
for job in $(jobs -p); do
wait ${job} || let "fails+=1"
done

for platform in "${platforms[@]}"; do
cat "/tmp//${platform//\//_}.build"
done

exit ${fails}
)
}

0 comments on commit 44b4c9f

Please sign in to comment.