Merge pull request #11140 from govargo/add-cpu-benchmark

Add cpu usage benchmark command `make cpu-benchmark` and website docs
pull/11232/head
Medya Ghazizadeh 2021-04-29 15:16:01 -07:00 committed by GitHub
commit fe0a1774a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 1322 additions and 0 deletions

View File

@ -924,6 +924,14 @@ endif
stress: ## run the stress tests
go test -test.v -test.timeout=2h ./test/stress -loops=10 | tee "./out/testout_$(COMMIT_SHORT).txt"
.PHONY: cpu-benchmark-idle
cpu-benchmark-idle: ## run the cpu usage 5 minutes idle benchmark
./hack/benchmark/cpu_usage/idle_only/benchmark_local_k8s.sh
.PHONY: cpu-benchmark-autopause
cpu-benchmark-autopause: ## run the cpu usage auto-pause benchmark
./hack/benchmark/cpu_usage/auto_pause/benchmark_local_k8s.sh
.PHONY: update-gopogh-version
update-gopogh-version: ## update gopogh version
(cd hack/update/gopogh_version && \

1
go.mod
View File

@ -87,6 +87,7 @@ require (
golang.org/x/sys v0.0.0-20210412220455-f1c623a9e750
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72
golang.org/x/text v0.3.6
gonum.org/v1/plot v0.9.0
google.golang.org/api v0.45.0
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/yaml.v2 v2.4.0

33
go.sum
View File

@ -48,6 +48,7 @@ contrib.go.opencensus.io/exporter/stackdriver v0.12.1 h1:Dll2uFfOVI3fa8UzsHyP6z0
contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw=
contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v43.0.0+incompatible h1:/wSNCu0e6EsHFR4Qa3vBEBbicaprEHMyyga9g8RTULI=
github.com/Azure/azure-sdk-for-go v43.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
@ -112,6 +113,7 @@ github.com/afbjorklund/go-containerregistry v0.4.1-0.20210321165649-761f6f9626b1
github.com/afbjorklund/moby v0.0.0-20210308214533-2fa72faf0e8b h1:wmyy8gOOzYzMD6SfMs44yCPoOWAAHcjxCio/zQjOlDU=
github.com/afbjorklund/moby v0.0.0-20210308214533-2fa72faf0e8b/go.mod h1:qXUBi22bjTfxOV8XyOI/W1PklPSinepyWoJ6eYSLwwo=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af h1:wVe6/Ea46ZMeNkQjjBW6xcqyQA/j5e0D6GytH95g0gQ=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@ -152,6 +154,7 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
@ -335,6 +338,8 @@ github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
@ -349,12 +354,20 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/go-acme/lego v2.5.0+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M=
github.com/go-bindata/go-bindata v3.1.1+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
github.com/go-fonts/dejavu v0.1.0 h1:JSajPXURYqpr+Cu8U9bt8K+XcACIHWqWrvWCKyeFmVQ=
github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g=
github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks=
github.com/go-fonts/liberation v0.1.1 h1:wBrPaMkrXFBW3qXpXAjiKljdVUMxn9bX2ia3XjPHoik=
github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY=
github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07 h1:OTlfMvwR1rLyf9goVmXfuS5AJn80+Vmj4rTf4n46SOs=
github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
@ -418,6 +431,7 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 h1:zN2lZNZRflqFyxVaTIU61KNKQ9C0055u9CAfpmqUvo4=
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3/go.mod h1:nPpo7qLxd6XL3hWJG/O60sR8ZKfMCiIoNap5GvD12KU=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@ -635,6 +649,7 @@ github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d/go.mod h1:6/KLg8Wz/y2KV
github.com/juju/version v0.0.0-20180108022336-b64dbd566305 h1:lQxPJ1URr2fjsKnJRt/BxiIxjLt9IKGvS+0injMHbag=
github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
@ -827,6 +842,9 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
github.com/phpdave11/gofpdf v1.4.2 h1:KPKiIbfwbvC/wOncwhrpRdXVj2CZTCFlw4wnoyjtHfQ=
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/pkg/browser v0.0.0-20160118053552-9302be274faa h1:od00Tr1U7+cLVtc+RNFmR53spHUF98Ziu33S8UIQnt0=
github.com/pkg/browser v0.0.0-20160118053552-9302be274faa/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@ -890,6 +908,7 @@ github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6 h1:tlXG832s
github.com/russross/blackfriday v1.5.3-0.20200218234912-41c5fccfd6f6/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
@ -1073,6 +1092,7 @@ golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
@ -1083,6 +1103,13 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210216034530-4410531fe030 h1:lP9pYkih3DUSC641giIXa2XqfTIbbbRr0w2EOTA7wHA=
golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -1269,6 +1296,7 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -1318,6 +1346,7 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@ -1369,9 +1398,13 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
gonum.org/v1/gonum v0.6.2/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
gonum.org/v1/gonum v0.8.2 h1:CCXrcPKiGGotvnN6jfUsKk4rRqm7q09/YbKb5xCEvtM=
gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ=
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
gonum.org/v1/plot v0.9.0 h1:3sEo36Uopv1/SA/dMFFaxXoL5XyikJ9Sf2Vll/k6+2E=
gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY=
google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=

View File

@ -0,0 +1,39 @@
# What is these scripts
These scripts are for the benchmark of cpu usage, minikube vs kind vs k3d.
* `benchmark_local_k8s.sh`: take benchmark for cpu usage. This will take long to take place
* `update_summary.sh`: create one summary csv file of each drivers and products
* `chart.go`: create bar chart graph as a png file
In `benchmark_local_k8s.sh`, we compare minikube drivers(hyperkit, virtualbox, docker with auto-pause addon) and kind, k3d, Docker for Mac Kubernetes in case of macOS.
In `benchmark_local_k8s.sh`, we compare minikube drivers(kvm2, virtualbox, docker with auto-pause addon) and kind, k3d in case of Linux.
`benchmark_local_k8s.sh` take these steps to measure `auto-pause` vs. `non auto-pause`.
1. start each local kubernetes tool
2. deploy sample application(nginx deployment) to each tool
3. wait 1 minute without anything
4. measure No.3 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
5. if tool is minikube, enable auto-pause addon which pause control plane
6. if tool is minikube, wait 1 minute so that control plane will become Paused status(It takes 1 minute to become Pause status from Stopped status)
7. if tool is minikube, verify if minikube control plane is paused
8. if tool is minikube, wait 3 minute without anything
9. if tool is minikube, measure No.8 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
No.1-4: Initial start CPU usage with sample(nginx) deployment
No.5-9: Auto Paused CPU usage with sample(nginx) deployment
# How to use these scripts
```
cd <Top of minikube directory>
make cpu-benchmark-benchmark-autopause
```
After running `make cpu-benchmark-autopause`, the png file of the bar chart graph will be generated.
If you update the benchmark results to [our website](https://minikube.sigs.k8s.io/docs/benchmarks/), please commit this change.
```
git status
git add <Changed png file>
git commit
```

View File

@ -0,0 +1,310 @@
#!/bin/bash
# Copyright 2021 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Gather data comparing the overhead of multiple local Kubernetes (macOS and linux)
readonly TESTS=$1
# How many iterations to cycle through
readonly TEST_ITERATIONS=10
# How long to poll CPU usage for (each point is an average over this period)
readonly POLL_DURATION=5s
# How long to measure background usage for. 5 minutes too short, 10 minutes too long
readonly TOTAL_DURATION=5m
# How all tests will be identified
readonly SESSION_ID="$(date +%Y%m%d-%H%M%S)-$$"
# OS Type
readonly OS=$(uname)
measure() {
local name=$1
local iteration=$2
local totalduration=$3
local filename="benchmark-results/${SESSION_ID}/cstat.${name}.$$-${iteration}"
echo ""
echo " >> Current top processes by CPU:"
if [[ "${OS}" == "Darwin" ]]; then
top -n 3 -l 2 -s 2 -o cpu | tail -n4 | awk '{ print $1 " " $2 " " $3 " " $4 }'
elif [[ "${OS}" == "Linux" ]]; then
top -b -n 3 -o %CPU | head -n 9
fi
if [[ "${iteration}" == 0 ]]; then
echo "NOTE: dry-run iteration: will not record measurements"
cstat --poll "${POLL_DURATION}" --for "${POLL_DURATION}" --busy
return
fi
echo ""
echo " >> Measuring ${name} and saving to out/${filename} ..."
if [[ "${totalduration}" != "" ]]; then
cstat --poll "${POLL_DURATION}" --for "${totalduration}" --busy --header=false | tee "$(pwd)/out/${filename}"
else
cstat --poll "${POLL_DURATION}" --for "${TOTAL_DURATION}" --busy --header=false | tee "$(pwd)/out/${filename}"
fi
}
cleanup() {
echo " >> Deleting local clusters and Docker containers ..."
out/minikube delete --all 2>/dev/null >/dev/null
k3d cluster delete 2>/dev/null >/dev/null
kind delete cluster 2>/dev/null >/dev/null
docker stop $(docker ps -q) 2>/dev/null
docker kill $(docker ps -q) 2>/dev/null
docker rm $(docker ps -a -q) 2>/dev/null
sleep 2
}
pause_if_running_apps() {
while true; do
local apps=$(osascript -e 'tell application "System Events" to get name of (processes where background only is false)' | tr ',' '\n' | sed s/"^ "//g)
local quiet=0
for app in $apps; do
quiet=1
if [[ "${app}" != "Terminal" && "${app}" != "Finder" ]]; then
echo "Unexpected application running: \"${app}\" - will sleep"
quiet=0
fi
done
pmset -g batt | grep 'AC Power'
if [[ "$?" != 0 ]]; then
echo "waiting to be plugged in ..."
sleep 5
continue
fi
if [[ "${quiet}" == 1 ]]; then
break
else
echo "waiting for apps to be closed ..."
sleep 5
fi
done
}
fail() {
local name=$1
local iteration=$2
echo '***********************************************************************'
echo "${name} failed on iteration ${iteration} - will not record measurement"
echo '***********************************************************************'
if [[ "${iteration}" == 0 ]]; then
echo "test environment appears invalid, exiting"
exit 90
fi
}
start_docker() {
local docker_up=0
local started=0
while [[ "${docker_up}" == 0 ]]; do
docker info >/dev/null && docker_up=1 || docker_up=0
if [[ "${docker_up}" == 0 && "${started}" == 0 ]]; then
if [[ "${OS}" == "Darwin" ]]; then
echo ""
echo " >> Starting Docker for Desktop ..."
open -a Docker
started=1
elif [[ "${OS}" == "Linux" ]]; then
echo ""
echo " >> Starting Docker Engine ..."
sudo systemctl start docker
started=1
fi
fi
sleep 1
done
# Give time for d4d Kubernetes to begin, if it's around
if [[ "${started}" == 1 ]]; then
sleep 60
fi
}
main() {
# check if cstat is installed
CSTAT=$(which cstat)
if [[ "$?" != 0 ]]; then
echo "cstat in not installed. Install cstat at https://github.com/tstromberg/cstat"
exit 1
fi
echo "----[ versions ]------------------------------------"
k3d version || { echo "k3d version failed. Please install latest k3d"; exit 1; }
kind version || { echo "kind version failed. Please install latest kind"; exit 1; }
out/minikube version || { echo "minikube version failed"; exit 1; }
docker version
echo "----------------------------------------------------"
echo ""
echo "Session ID: ${SESSION_ID}"
mkdir -p "out/benchmark-results/${SESSION_ID}"
echo ""
if [[ "${OS}" == "Darwin" ]]; then
echo "Turning on Wi-Fi for initial downloads"
networksetup -setairportpower Wi-Fi on
fi
for i in $(seq 0 ${TEST_ITERATIONS}); do
echo ""
echo "==> session ${SESSION_ID}, iteration $i"
cleanup
if [[ "$i" = 0 ]]; then
echo "NOTE: The 0 iteration is an unmeasured dry run!"
else
if [[ "${OS}" == "Darwin" ]]; then
pause_if_running_apps
echo "Turning off Wi-Fi to remove background noise"
networksetup -setairportpower Wi-Fi off
echo " >> Killing Docker for Desktop ..."
osascript -e 'quit app "Docker"'
elif [[ "${OS}" == "Linux" ]]; then
echo " >> Killing Docker Engine ..."
sudo systemctl stop docker
fi
# Measure the background noise on this system
sleep 15
measure idle $i
fi
# Run cleanup once we can assert that Docker is up
start_docker
cleanup
docker_k8s=0
# depending on whether Docker for Mac Kubernetes is enabled
if [[ "${OS}" == "Darwin" ]]; then
# wait kubernetes system pods for Docker for Mac, if it is enabled
sleep 60
kubectl --context docker-desktop version
# measure Docker for Mac Kubernetes
if [[ $? == 0 ]]; then
echo "Kubernetes is running in Docker for Desktop - adjusting tests"
docker_k8s=1
kubectl create deployment nginx --image=nginx:1.20.0
measure docker_k8s $i
echo "end of measurement for Docker for Desktop"
kubectl delete deployment nginx
# measure Docker idle
else
kubectl create deployment nginx --image=nginx:1.20.0
measure docker $i
echo "end of measurement for Docker for Desktop Kubernetes"
kubectl delete deployment nginx
fi
# measure Docker idle only
elif [[ "${OS}" == "Linux" ]]; then
measure docker $i
fi
echo ""
echo "-> k3d"
time k3d cluster create
echo "-> deploy nginx deployment"
kubectl create deployment nginx --image=nginx:1.20.0
measure k3d $i || fail k3d $i
cleanup
echo ""
echo "-> kind"
time kind create cluster
echo "-> deploy nginx deployment"
kubectl create deployment nginx --image=nginx:1.20.0
measure kind $i || fail kind $i
cleanup
# test different drivers
if [[ "${OS}" == "Darwin" ]]; then
drivers=(docker hyperkit virtualbox)
elif [[ "${OS}" == "Linux" ]]; then
drivers=(docker kvm2 virtualbox)
fi
for driver in "${drivers[@]}"; do
echo ""
# 1. start minikube cluster
echo "-> out/minikube --driver=${driver}"
time out/minikube start --driver "${driver}"
#2. deploy sample application(nginx deployment)
echo "-> deploy nginx deployment"
kubectl create deployment nginx --image=nginx:1.20.0
#3. wait 1 minute without anything and 4. measure No.3 idle CPU usage
measure "minikube.${driver}.nonautopause" $i "1m" || fail "minikube.${driver}.nonautopause" $i
# 5. enable auto-pause addons
echo "-> enable auto-pause to control plane"
out/minikube addons enable auto-pause
# 6. wait 1 minute so that control plane will become Paused status
pause=0
while [ "${pause}" = 0 ]
do
# It takes 1 minute to become Pause status from Stopped status. 70s is a number with a margin
sleep 70
# 7. verify if minikube control plane is paused
PAUSE=$(out/minikube status)
echo $PAUSE | grep "apiserver: Paused"
if [[ "$?" == 0 ]]; then
echo "kube-apiserver is paused"
pause=1
else
echo "...status is not Paused. wait for becoming Pause..."
fi
done
# 8. wait 3 minute without anything and 9. measure No.8 idle CPU usage
measure "minikube.${driver}.autopause" $i "3m" || fail "minikube.${driver}.autopause" $i
cleanup
# We won't be needing docker for the remaining tests this iteration
if [[ "${OS}" == "Darwin" && "${driver}" == "docker" ]]; then
echo " >> Quitting Docker for Desktop ..."
osascript -e 'quit app "Docker"'
elif [[ "${OS}" == "Linux" && ${driver} == "docker" ]]; then
echo " >> Quitting Docker Engine ..."
sudo systemctl stop docker
fi
done ## driver
done ## iteration
}
main "$@"
# update benchmark result into docs contents
./hack/benchmark/cpu_usage/auto_pause/update_summary.sh "${SESSION_ID}"
go run ./hack/benchmark/cpu_usage/auto_pause/chart.go "${SESSION_ID}"

View File

@ -0,0 +1,238 @@
/*
Copyright 2021 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"encoding/csv"
"fmt"
"image/color"
"log"
"math"
"os"
"runtime"
"strconv"
"github.com/pkg/errors"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
var FOLDER = "site/static/images/benchmarks/cpuUsage/autoPause"
type integerTicks struct{}
func (integerTicks) Ticks(min, max float64) []plot.Tick {
var t []plot.Tick
for i := math.Trunc(min); i <= max; i += 50 {
t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)})
}
return t
}
func main() {
if err := execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func execute() error {
// sessionID is generated and used at cpu usage benchmark
sessionID := os.Args[1]
if len(sessionID) == 0 {
return errors.New("Please identify sessionID")
}
// Create plot instance
p := plot.New()
// Set view options
if runtime.GOOS == "darwin" {
p.Title.Text = "CPU% Busy Overhead - With Auto Pause vs. Non Auto Pause (less is better)"
} else if runtime.GOOS == "linux" {
p.Title.Text = "CPU% Busy Overhead - With Auto Pause vs. Non Auto Pause (less is better)"
}
p.Y.Label.Text = "CPU overhead%"
// Open non-autopause csv file of benchmark summary
napResults := []float64{}
var napFn string = "./out/benchmark-results/" + sessionID + "/cstat.nonautopause.summary"
napFile, err := os.Open(napFn)
if err != nil {
return errors.Wrap(err, "Missing summary csv")
}
defer napFile.Close()
// Read result values from benchmark summary csv
napReader := csv.NewReader(napFile)
var napLine []string
for {
napLine, err = napReader.Read()
if err != nil {
break
}
s, err := strconv.ParseFloat(napLine[0], 64)
if err != nil {
return errors.Wrap(err, "Failed to convert to float64")
}
napResults = append(napResults, s)
}
// Open auto-pause csv file of benchmark summary
apResults := []float64{}
var apFn string = "./out/benchmark-results/" + sessionID + "/cstat.autopause.summary"
apFile, err := os.Open(apFn)
if err != nil {
return errors.Wrap(err, "Missing summary csv")
}
defer apFile.Close()
// Read result values from benchmark summary csv
apReader := csv.NewReader(apFile)
var apLine []string
for {
apLine, err = apReader.Read()
if err != nil {
break
}
s, err := strconv.ParseFloat(apLine[0], 64)
if err != nil {
return errors.Wrap(err, "Failed to convert to float64")
}
apResults = append(apResults, s)
}
// Set bar graph width
breadth := vg.Points(40)
// Create Bar instance with non-autopause benchmark results
barNAP, err := plotter.NewBarChart(plotter.Values(napResults), breadth)
if err != nil {
return errors.Wrap(err, "Failed to create bar chart")
}
// Set border of the bar graph. 0 is no border color
barNAP.LineStyle.Width = vg.Length(0)
// Add bar name
p.Legend.Add("Initial Start CPU usage Before Pause", barNAP)
// Set bar color to gray.
barNAP.Color = color.RGBA{184, 184, 184, 255}
// Create Bar instance with auto-pause benchmark results
barAP, err := plotter.NewBarChart(plotter.Values(apResults), breadth)
if err != nil {
return errors.Wrap(err, "Failed to create bar chart")
}
// Set border of the bar graph. 0 is no border color
barAP.LineStyle.Width = vg.Length(0)
// Add bar name
p.Legend.Add("Auto Paused CPU usage", barAP)
// Set bar color. 1 is green
barAP.Color = plotutil.Color(1)
hb := vg.Points(20)
barNAP.Offset = -hb
barAP.Offset = hb
p.Add(barNAP, barAP)
// Set legend position upper
p.Legend.Top = true
// Add x-lay names
if runtime.GOOS == "darwin" {
p.NominalX("OS idle", "minikube hyperkit", "minikube virtualbox", "minikube docker", "Docker for Mac Kubernetes", "k3d", "kind")
} else if runtime.GOOS == "linux" {
p.NominalX("OS idle", "minikube kvm2", "minikube virtualbox", "minikube docker", "Docker idle", "k3d", "kind")
}
// Set non-autopause data label to each bar
var napLabels []string
for i := range napResults {
nLabel := strconv.FormatFloat(napResults[i], 'f', -1, 64)
napLabels = append(napLabels, nLabel)
}
var napCPU []plotter.XY
for i := range napResults {
napXPos := float64(i) - 0.25
napYPos := napResults[i] + 0.1
napXY := plotter.XY{X: napXPos, Y: napYPos}
napCPU = append(napCPU, napXY)
}
// CPU Busy% non-autopause data label
napl, err := plotter.NewLabels(plotter.XYLabels{
XYs: napCPU,
Labels: napLabels,
},
)
if err != nil {
return err
}
// Set auto-pause data label to each bar
var apLabels []string
for i := range apResults {
if apResults[i] == 0 {
apLabels = append(apLabels, "N/A")
} else {
apLabel := strconv.FormatFloat(apResults[i], 'f', -1, 64)
apLabels = append(apLabels, apLabel)
}
}
var apCPU []plotter.XY
for i := range apResults {
apXPos := float64(i) + 0.05
apYPos := apResults[i] + 0.1
apXY := plotter.XY{X: apXPos, Y: apYPos}
apCPU = append(apCPU, apXY)
}
// CPU Busy% auto-pause data label
apl, err := plotter.NewLabels(plotter.XYLabels{
XYs: apCPU,
Labels: apLabels,
},
)
if err != nil {
return err
}
// define max cpu busy% to 20%
p.Y.Max = 20
p.Y.Tick.Marker = integerTicks{}
// Add CPU Busy% label to plot
p.Add(napl, apl)
// Output bar graph
if runtime.GOOS == "darwin" {
if err := p.Save(13*vg.Inch, 8*vg.Inch, FOLDER+"/mac.png"); err != nil {
return errors.Wrap(err, "Failed to create bar graph png")
}
log.Printf("Generated graph png to %s/mac.png", FOLDER)
} else if runtime.GOOS == "linux" {
if err := p.Save(13*vg.Inch, 10*vg.Inch, FOLDER+"/linux.png"); err != nil {
return errors.Wrap(err, "Failed to create bar graph png")
}
log.Printf("Generated graph png to %s/linux.png", FOLDER)
}
return nil
}

View File

@ -0,0 +1,92 @@
#!/bin/bash
# Copyright 2021 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SESSION_ID=$1
NONAUTOPAUSE_RESULTS=()
AUTOPAUSE_RESULTS=()
OS=$(uname)
if [[ ${OS} == "Darwin" ]]; then
TESTS_TARGETS=("idle" "minikube.hyperkit" "minikube.virtualbox" "minikube.docker" "docker" "k3d" "kind")
elif [[ ${OS} == "Linux" ]]; then
TESTS_TARGETS=("idle" "minikube.kvm2" "minikube.virtualbox" "minikube.docker" "docker" "k3d" "kind")
fi
# calc average each non-autopause test target
calcAvarageNonAutopause() {
for target in ${TESTS_TARGETS[@]}; do
nap_count=0;
nap_total=0;
if [[ "${target}" == "minikube."* ]]; then
FILES=$(ls out/benchmark-results/${SESSION_ID} | grep cstat.${target} | grep nonautopause)
else
FILES=$(ls out/benchmark-results/${SESSION_ID} | grep cstat.${target})
fi
# calc average per test target
for file in ${FILES[@]}; do
NAP_MEASURED=$(cat out/benchmark-results/${SESSION_ID}/${file} | tail -n 1)
nap_total=$(echo ${nap_total}+${NAP_MEASURED} | bc )
((nap_count++))
done
NONAUTOPAUSE_RESULT=$(echo "scale=4; ${nap_total} / ${nap_count}" | bc | awk '{printf "%.4f\n", $0}')
NONAUTOPAUSE_RESULTS=("${NONAUTOPAUSE_RESULTS[@]}" ${NONAUTOPAUSE_RESULT})
done
}
# calc average each autopause test target
calcAvarageAutopause() {
for target in ${TESTS_TARGETS[@]}; do
if [[ "${target}" == "minikube."* ]]; then
ap_count=0;
ap_total=0;
FILES=$(ls out/benchmark-results/${SESSION_ID} | grep cstat.${target} | grep autopause)
# calc average per test target
for file in ${FILES[@]}; do
AP_MEASURED=$(cat out/benchmark-results/${SESSION_ID}/${file} | tail -n 1)
ap_total=$(echo ${ap_total}+${AP_MEASURED} | bc )
((ap_count++))
done
AUTOPAUSE_RESULT=$(echo "scale=4; ${ap_total} / ${ap_count}" | bc | awk '{printf "%.4f\n", $0}')
AUTOPAUSE_RESULTS=("${AUTOPAUSE_RESULTS[@]}" ${AUTOPAUSE_RESULT})
else
AUTOPAUSE_RESULTS=("${AUTOPAUSE_RESULTS[@]}" 0)
fi
done
}
# create non-autopause summary csv
updateNonAutopauseSummary() {
for ((i = 0; i < ${#NONAUTOPAUSE_RESULTS[@]}; i++)) {
echo "${NONAUTOPAUSE_RESULTS[i]}" >> out/benchmark-results/${SESSION_ID}/cstat.nonautopause.summary
}
}
# create autopause summary csv
updateAutopauseSummary() {
for ((i = 0; i < ${#AUTOPAUSE_RESULTS[@]}; i++)) {
echo "${AUTOPAUSE_RESULTS[i]}" >> out/benchmark-results/${SESSION_ID}/cstat.autopause.summary
}
}
calcAvarageNonAutopause
updateNonAutopauseSummary
calcAvarageAutopause
updateAutopauseSummary

View File

@ -0,0 +1,29 @@
# What is these scripts
These scripts are for the benchmark of cpu usage, minikube vs kind vs k3d.
* `benchmark_local_k8s.sh`: take benchmark for cpu usage. This will take long to take place
* `update_summary.sh`: create one summary csv file of each drivers and products
* `chart.go`: create bar chart graph as a png file
In `benchmark_local_k8s.sh`, we compare minikube drivers(docker, hyperkit, virtualbox) and kind, k3d, Docker for Mac Kubernetes in case of macOS.
In `benchmark_local_k8s.sh`, we compare minikube drivers(docker, kvm2, virtualbox) and kind, k3d in case of Linux.
`benchmark_local_k8s.sh` take these steps to measure idle usage after start-up.
1. start each local kubernetes tool
2. measure its cpu usage with [cstat](https://github.com/tstromberg/cstat)
# How to use these scripts
```
cd <Top of minikube directory>
make cpu-benchmark-idle
```
After running `make cpu-benchmark-idle`, the png file of the bar chart graph will be generated.
If you update the benchmark results to [our website](https://minikube.sigs.k8s.io/docs/benchmarks/), please commit this change.
```
git status
git add <Changed png file>
git commit
```

View File

@ -0,0 +1,262 @@
#!/bin/bash
# Copyright 2021 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Gather data comparing the overhead of multiple local Kubernetes (macOS and linux)
readonly TESTS=$1
# How many iterations to cycle through
readonly TEST_ITERATIONS=10
# How long to poll CPU usage for (each point is an average over this period)
readonly POLL_DURATION=5s
# How long to measure background usage for. 5 minutes too short, 10 minutes too long
readonly TOTAL_DURATION=5m
# How all tests will be identified
readonly SESSION_ID="$(date +%Y%m%d-%H%M%S)-$$"
# OS Type
readonly OS=$(uname)
measure() {
local name=$1
local iteration=$2
local filename="benchmark-results/${SESSION_ID}/cstat.${name}.$$-${iteration}"
echo ""
echo " >> Current top processes by CPU:"
if [[ "${OS}" == "Darwin" ]]; then
top -n 3 -l 2 -s 2 -o cpu | tail -n4 | awk '{ print $1 " " $2 " " $3 " " $4 }'
elif [[ "${OS}" == "Linux" ]]; then
top -b -n 3 -o %CPU | head -n 9
fi
if [[ "${iteration}" == 0 ]]; then
echo "NOTE: dry-run iteration: will not record measurements"
cstat --poll "${POLL_DURATION}" --for "${POLL_DURATION}" --busy
return
fi
echo ""
echo " >> Measuring ${name} and saving to out/${filename} ..."
cstat --poll "${POLL_DURATION}" --for "${TOTAL_DURATION}" --busy --header=false | tee "$(pwd)/out/${filename}"
}
cleanup() {
echo " >> Deleting local clusters and Docker containers ..."
out/minikube delete --all 2>/dev/null >/dev/null
k3d cluster delete 2>/dev/null >/dev/null
kind delete cluster 2>/dev/null >/dev/null
docker stop $(docker ps -q) 2>/dev/null
docker kill $(docker ps -q) 2>/dev/null
docker rm $(docker ps -a -q) 2>/dev/null
sleep 2
}
pause_if_running_apps() {
while true; do
local apps=$(osascript -e 'tell application "System Events" to get name of (processes where background only is false)' | tr ',' '\n' | sed s/"^ "//g)
local quiet=0
for app in $apps; do
quiet=1
if [[ "${app}" != "Terminal" && "${app}" != "Finder" ]]; then
echo "Unexpected application running: \"${app}\" - will sleep"
quiet=0
fi
done
pmset -g batt | grep 'AC Power'
if [[ "$?" != 0 ]]; then
echo "waiting to be plugged in ..."
sleep 5
continue
fi
if [[ "${quiet}" == 1 ]]; then
break
else
echo "waiting for apps to be closed ..."
sleep 5
fi
done
}
fail() {
local name=$1
local iteration=$2
echo '***********************************************************************'
echo "${name} failed on iteration ${iteration} - will not record measurement"
echo '***********************************************************************'
if [[ "${iteration}" == 0 ]]; then
echo "test environment appears invalid, exiting"
exit 90
fi
}
start_docker() {
local docker_up=0
local started=0
while [[ "${docker_up}" == 0 ]]; do
docker info >/dev/null && docker_up=1 || docker_up=0
if [[ "${docker_up}" == 0 && "${started}" == 0 ]]; then
if [[ "${OS}" == "Darwin" ]]; then
echo ""
echo " >> Starting Docker for Desktop ..."
open -a Docker
started=1
elif [[ "${OS}" == "Linux" ]]; then
echo ""
echo " >> Starting Docker Engine ..."
sudo systemctl start docker
started=1
fi
fi
sleep 1
done
# Give time for d4d Kubernetes to begin, if it's around
if [[ "${started}" == 1 ]]; then
sleep 60
fi
}
main() {
# check if cstat is installed
CSTAT=$(which cstat)
if [[ "$?" != 0 ]]; then
echo "cstat in not installed. Install cstat at https://github.com/tstromberg/cstat"
exit 1
fi
echo "----[ versions ]------------------------------------"
k3d version || { echo "k3d version failed. Please install latest k3d"; exit 1; }
kind version || { echo "kind version failed. Please install latest kind"; exit 1; }
out/minikube version || { echo "minikube version failed"; exit 1; }
docker version
echo "----------------------------------------------------"
echo ""
echo "Session ID: ${SESSION_ID}"
mkdir -p "out/benchmark-results/${SESSION_ID}"
echo ""
if [[ "${OS}" == "Darwin" ]]; then
echo "Turning on Wi-Fi for initial downloads"
networksetup -setairportpower Wi-Fi on
fi
for i in $(seq 0 ${TEST_ITERATIONS}); do
echo ""
echo "==> session ${SESSION_ID}, iteration $i"
cleanup
if [[ "$i" = 0 ]]; then
echo "NOTE: The 0 iteration is an unmeasured dry run!"
else
if [[ "${OS}" == "Darwin" ]]; then
pause_if_running_apps
echo "Turning off Wi-Fi to remove background noise"
networksetup -setairportpower Wi-Fi off
echo " >> Killing Docker for Desktop ..."
osascript -e 'quit app "Docker"'
elif [[ "${OS}" == "Linux" ]]; then
echo " >> Killing Docker Engine ..."
sudo systemctl stop docker
fi
# Measure the background noise on this system
sleep 15
measure idle $i
fi
# Run cleanup once we can assert that Docker is up
start_docker
cleanup
docker_k8s=0
# depending on whether Docker for Mac Kubernetes is enabled
if [[ "${OS}" == "Darwin" ]]; then
# wait kubernetes system pods for Docker for Mac, if it is enabled
sleep 60
kubectl --context docker-desktop version
# measure Docker for Mac Kubernetes
if [[ $? == 0 ]]; then
echo "Kubernetes is running in Docker for Desktop - adjusting tests"
docker_k8s=1
measure docker_k8s $i
# measure Docker idle
else
measure docker $i
fi
# measure Docker idle only
elif [[ "${OS}" == "Linux" ]]; then
measure docker $i
fi
# measure k3d and kind
echo ""
echo "-> k3d"
time k3d cluster create && measure k3d $i || fail k3d $i
cleanup
echo ""
echo "-> kind"
time kind create cluster && measure kind $i || fail kind $i
cleanup
# test different drivers
if [[ "${OS}" == "Darwin" ]]; then
drivers=(docker hyperkit virtualbox)
elif [[ "${OS}" == "Linux" ]]; then
drivers=(docker kvm2 virtualbox)
fi
for driver in "${drivers[@]}"; do
echo ""
echo "-> out/minikube --driver=${driver}"
time out/minikube start --driver "${driver}" && measure "minikube.${driver}" $i || fail "minikube.${driver}" $i
cleanup
# We won't be needing docker for the remaining tests this iteration
if [[ "${OS}" == "Darwin" && "${driver}" == "docker" ]]; then
echo " >> Quitting Docker for Desktop ..."
osascript -e 'quit app "Docker"'
elif [[ "${OS}" == "Linux" && ${driver} == "docker" ]]; then
echo " >> Quitting Docker Engine ..."
sudo systemctl stop docker
fi
done ## driver
done ## iteration
}
main "$@"
# update benchmark result into docs contents
./hack/benchmark/cpu_usage/idle_only/update_summary.sh "${SESSION_ID}"
go run ./hack/benchmark/cpu_usage/idle_only/chart.go "${SESSION_ID}"

View File

@ -0,0 +1,166 @@
/*
Copyright 2021 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"encoding/csv"
"fmt"
"log"
"math"
"os"
"runtime"
"strconv"
"github.com/pkg/errors"
"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/plotutil"
"gonum.org/v1/plot/vg"
)
var FOLDER = "site/static/images/benchmarks/cpuUsage/idleOnly"
type integerTicks struct{}
func (integerTicks) Ticks(min, max float64) []plot.Tick {
var t []plot.Tick
for i := math.Trunc(min); i <= max; i += 50 {
t = append(t, plot.Tick{Value: i, Label: fmt.Sprint(i)})
}
return t
}
func main() {
if err := execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func execute() error {
// sessionID is generated and used at cpu usage benchmark
sessionID := os.Args[1]
if len(sessionID) == 0 {
return errors.New("Please identify sessionID")
}
// Create plot instance
p := plot.New()
// Set view options
if runtime.GOOS == "darwin" {
p.Title.Text = "CPU% Busy Overhead - Average first 5 minutes on macOS (less is better)"
} else if runtime.GOOS == "linux" {
p.Title.Text = "CPU% Busy Overhead - Average first 5 minutes on Linux (less is better)"
}
p.Y.Label.Text = "CPU overhead%"
// Open csv file of benchmark summary
results := []float64{}
var fn string = "./out/benchmark-results/" + sessionID + "/cstat.summary"
file, err := os.Open(fn)
if err != nil {
return errors.Wrap(err, "Missing summary csv")
}
defer file.Close()
// Read result values from benchmark summary csv
reader := csv.NewReader(file)
var line []string
for {
line, err = reader.Read()
if err != nil {
break
}
s, err := strconv.ParseFloat(line[0], 64)
if err != nil {
return errors.Wrap(err, "Failed to convert to float64")
}
results = append(results, s)
}
// Set bar graph width
breadth := vg.Points(40)
// Create Bar instance with benchmark results
bar, err := plotter.NewBarChart(plotter.Values(results), breadth)
if err != nil {
return errors.Wrap(err, "Failed to create bar chart")
}
// Set border of the bar graph. 0 is no border color
bar.LineStyle.Width = vg.Length(0)
// Add bar name
p.Legend.Add("CPU Busy%", bar)
// Set bar color. 2 is blue
bar.Color = plotutil.Color(2)
p.Add(bar)
// Set legend position upper
p.Legend.Top = true
// Add x-lay names
if runtime.GOOS == "darwin" {
p.NominalX("OS idle", "minikube hyperkit", "minikube virtualbox", "minikube docker", "Docker for Mac Kubernetes", "k3d", "kind")
} else if runtime.GOOS == "linux" {
p.NominalX("OS idle", "minikube kvm2", "minikube virtualbox", "minikube docker", "Docker idle", "k3d", "kind")
}
// Set data label to each bar
var cpuLabels []string
for i := range results {
cLabel := strconv.FormatFloat(results[i], 'f', -1, 64)
cpuLabels = append(cpuLabels, cLabel)
}
var xysCPU []plotter.XY
for i := range results {
rxPos := float64(i) - 0.13
ryPos := results[i] + 0.1
cXY := plotter.XY{X: rxPos, Y: ryPos}
xysCPU = append(xysCPU, cXY)
}
// CPU Busy% data label
cl, err := plotter.NewLabels(plotter.XYLabels{
XYs: xysCPU,
Labels: cpuLabels,
},
)
if err != nil {
return err
}
// define max cpu busy% to 20%
p.Y.Max = 20
p.Y.Tick.Marker = integerTicks{}
// Add CPU Busy% label to plot
p.Add(cl)
// Output bar graph
if runtime.GOOS == "darwin" {
if err := p.Save(13*vg.Inch, 8*vg.Inch, FOLDER+"/mac.png"); err != nil {
return errors.Wrap(err, "Failed to create bar graph png")
}
log.Printf("Generated graph png to %s/mac.png", FOLDER)
} else if runtime.GOOS == "linux" {
if err := p.Save(13*vg.Inch, 10*vg.Inch, FOLDER+"/linux.png"); err != nil {
return errors.Wrap(err, "Failed to create bar graph png")
}
log.Printf("Generated graph png to %s/linux.png", FOLDER)
}
return nil
}

View File

@ -0,0 +1,55 @@
#!/bin/bash
# Copyright 2021 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SESSION_ID=$1
RESULTS=()
OS=$(uname)
if [[ ${OS} == "Darwin" ]]; then
TESTS_TARGETS=("idle" "minikube.hyperkit" "minikube.virtualbox" "minikube.docker" "docker" "k3d" "kind")
elif [[ ${OS} == "Linux" ]]; then
TESTS_TARGETS=("idle" "minikube.kvm2" "minikube.virtualbox" "minikube.docker" "docker" "k3d" "kind")
fi
# calc average each test target
calcAvarage() {
for target in ${TESTS_TARGETS[@]}; do
count=0;
total=0;
FILES=$(ls out/benchmark-results/${SESSION_ID} | grep cstat.${target})
# calc average per test target
for file in ${FILES[@]}; do
MEASURED=$(cat out/benchmark-results/${SESSION_ID}/${file} | tail -n 1)
total=$(echo ${total}+${MEASURED} | bc )
((count++))
done
RESULT=$(echo "scale=4; ${total} / ${count}" | bc | awk '{printf "%.4f\n", $0}')
RESULTS=("${RESULTS[@]}" ${RESULT})
done
}
# create summary csv
updateSummary() {
for ((i = 0; i < ${#RESULTS[@]}; i++)) {
echo "${RESULTS[i]}" >> out/benchmark-results/${SESSION_ID}/cstat.summary
}
}
calcAvarage
updateSummary

View File

@ -0,0 +1,5 @@
---
title: "CPU Usage Benchmarks"
linkTitle: "CPU Usage Benchmarks"
weight: 1
---

View File

@ -0,0 +1,45 @@
---
title: "CPU Usage Benchmarks(Linux)"
linkTitle: "CPU Usage Benchmarks(Linux)"
weight: 1
---
## CPU% Busy Overhead - Avarage first 5 minutes only
This chart shows each tool's CPU busy overhead percentage.
After each tool's starting, we measured each tool's idle for 5 minutes.
This chart was measured only after the start without deploying any pods.
1. start each local kubernetes tool
2. measure its cpu usage with [cstat](https://github.com/tstromberg/cstat)
![idleOnly](/images/benchmarks/cpuUsage/idleOnly/linux.png)
NOTE: the benchmark environment uses GCE with nested virtualization. This may affect virtual machine's overhead.
https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances
## CPU% Busy Overhead - With Auto Pause vs. Non Auto Pause
This chart shows each tool's CPU busy overhead percentage with auto-pause addon.
The auto-pause is mechanism which reduce CPU busy usage by pausing kube-apiserver.
We compare CPU usage after deploying sample application(nginx deployment) to all tools(including minikube and other tools).
This chart was measured with the following steps.
By these steps, we compare CPU usage with auto-pause vs. non-auto-pause.
1. start each local kubernetes tool
2. deploy sample application(nginx deployment) to each tool
3. wait 1 minute without anything
4. measure No.3 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
5. if tool is minikube, enable auto-pause addon which pause control plane
6. if tool is minikube, wait 1 minute so that control plane will become Paused status(It takes 1 minute to become Pause status from Stopped status)
7. if tool is minikube, verify if minikube control plane is paused
8. if tool is minikube, wait 3 minute without anything
9. if tool is minikube, measure No.8 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
No.1-4: Initial start CPU usage with sample(nginx) deployment
No.5-9: Auto Paused CPU usage with sample(nginx) deployment
![autopause](/images/benchmarks/cpuUsage/autoPause/linux.png)
NOTE: the benchmark environment uses GCE with nested virtualization. This may affect virtual machine's overhead.
https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances

View File

@ -0,0 +1,39 @@
---
title: "CPU Usage Benchmarks(macOS)"
linkTitle: "CPU Usage Benchmarks(macOS)"
weight: 1
---
## CPU% Busy Overhead - Avarage first 5 minutes only
This chart shows each tool's CPU busy overhead percentage.
After each tool's starting, we measured each tool's idle for 5 minutes.
This chart was measured only after the start without deploying any pods.
1. start each local kubernetes tool
2. measure its cpu usage with [cstat](https://github.com/tstromberg/cstat)
![idleOnly](/images/benchmarks/cpuUsage/idleOnly/mac.png)
## CPU% Busy Overhead - With Auto Pause vs. Non Auto Pause
This chart shows each tool's CPU busy overhead percentage with auto-pause addon.
The auto-pause is mechanism which reduce CPU busy usage by pausing kube-apiserver.
We compare CPU usage after deploying sample application(nginx deployment) to all tools(including minikube and other tools).
This chart was measured with the following steps.
By these steps, we compare CPU usage with auto-pause vs. non-auto-pause.
1. start each local kubernetes tool
2. deploy sample application(nginx deployment) to each tool
3. wait 1 minute without anything
4. measure No.3 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
5. if tool is minikube, enable auto-pause addon which pause control plane
6. if tool is minikube, wait 1 minute so that control plane will become Paused status(It takes 1 minute to become Pause status from Stopped status)
7. if tool is minikube, verify if minikube control plane is paused
8. if tool is minikube, wait 3 minute without anything
9. if tool is minikube, measure No.8 idle CPU usage with [cstat](https://github.com/tstromberg/cstat)
No.1-4: Initial start CPU usage with sample(nginx) deployment
No.5-9: Auto Paused CPU usage with sample(nginx) deployment
![autopause](/images/benchmarks/cpuUsage/autoPause/mac.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB