Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c0ed73a1
Commit
c0ed73a1
authored
Apr 02, 2015
by
Zach Loafman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only build in parallel if the build machine is >8G
parent
e159c02a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
18 deletions
+68
-18
golang.sh
hack/lib/golang.sh
+68
-18
No files found.
hack/lib/golang.sh
View file @
c0ed73a1
...
@@ -72,6 +72,11 @@ readonly KUBE_CLIENT_PLATFORMS=(
...
@@ -72,6 +72,11 @@ readonly KUBE_CLIENT_PLATFORMS=(
windows/amd64
windows/amd64
)
)
# Gigabytes desired for parallel platform builds. 8 is fairly
# arbitrary, but is a reasonable splitting point for 2015
# laptops-versus-not.
readonly
KUBE_PARALLEL_BUILD_MEMORY
=
8
readonly
KUBE_ALL_TARGETS
=(
readonly
KUBE_ALL_TARGETS
=(
"
${
KUBE_SERVER_TARGETS
[@]
}
"
"
${
KUBE_SERVER_TARGETS
[@]
}
"
"
${
KUBE_CLIENT_TARGETS
[@]
}
"
"
${
KUBE_CLIENT_TARGETS
[@]
}
"
...
@@ -321,6 +326,29 @@ kube::golang::build_binaries_for_platform() {
...
@@ -321,6 +326,29 @@ kube::golang::build_binaries_for_platform() {
}
}
# Return approximate physical memory in gigabytes.
kube::golang::get_physmem
()
{
local
mem
# Linux, in kb
if
mem
=
$(
grep
MemTotal /proc/meminfo |
awk
'{ print $2 }'
)
;
then
echo
$((
${
mem
}
/
1048576
))
return
fi
# OS X, in bytes. Note that get_physmem, as used, should only ever
# run in a Linux container (because it's only used in the multiple
# platform case, which is a Dockerized build), but this is provided
# for completeness.
if
mem
=
$(
sysctl
-n
hw.memsize 2>/dev/null
)
;
then
echo
$((
${
mem
}
/
1073741824
))
return
fi
# If we can't infer it, just give up and assume a low memory system
echo
1
}
# Build binaries targets specified
# Build binaries targets specified
#
#
# Input:
# Input:
...
@@ -371,25 +399,47 @@ kube::golang::build_binaries() {
...
@@ -371,25 +399,47 @@ kube::golang::build_binaries() {
local
binaries
local
binaries
binaries
=(
$(
kube::golang::binaries_from_targets
"
${
targets
[@]
}
"
)
)
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
parallel
=
false
local
platform
if
[[
${#
platforms
[@]
}
-gt
1
]]
;
then
for
platform
in
"
${
platforms
[@]
}
"
;
do
(
local
gigs
kube::golang::set_platform_envs
"
${
platform
}
"
gigs
=
$(
kube::golang::get_physmem
)
kube::log::status
"
${
platform
}
: Parallel go build started"
kube::golang::build_binaries_for_platform
${
platform
}
${
use_go_build
:-}
kube::log::status
"
${
platform
}
: Parallel go build finished"
)
&>
"/tmp//
${
platform
//\//_
}
.build"
&
done
local
fails
=
0
if
[[
${
gigs
}
-gt
${
KUBE_PARALLEL_BUILD_MEMORY
}
]]
;
then
for
job
in
$(
jobs
-p
)
;
do
kube::log::status
"Multiple platforms requested and available
${
gigs
}
G > threshold
${
KUBE_PARALLEL_BUILD_MEMORY
}
G, building platforms in parallel"
wait
${
job
}
||
let
"fails+=1"
parallel
=
true
don
e
els
e
kube::log::status
"Multiple platforms requested, but available
${
gigs
}
G < threshold
${
KUBE_PARALLEL_BUILD_MEMORY
}
G, building platforms in serial"
for
platform
in
"
${
platforms
[@]
}
"
;
do
parallel
=
false
cat
"/tmp//
${
platform
//\//_
}
.build"
fi
done
fi
exit
${
fails
}
if
[[
"
${
parallel
}
"
==
"true"
]]
;
then
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
(
kube::golang::set_platform_envs
"
${
platform
}
"
kube::log::status
"
${
platform
}
: go build started"
kube::golang::build_binaries_for_platform
${
platform
}
${
use_go_build
:-}
kube::log::status
"
${
platform
}
: 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
}
else
for
platform
in
"
${
platforms
[@]
}
"
;
do
kube::log::status
"Building go targets for
${
platform
}
:"
"
${
targets
[@]
}
"
kube::golang::set_platform_envs
"
${
platform
}
"
kube::golang::build_binaries_for_platform
${
platform
}
${
use_go_build
:-}
done
fi
)
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment