k3s/pkg/util
Kubernetes Submit Queue 3456d4d239 Merge pull request #46033 from wojtek-t/reduce_memory_allocations_in_kube_proxy
Automatic merge from submit-queue

Reduce memory allocations in kube proxy

Memory allocation (and Go GarbageCollection) seems to be one of the most expensive operations in kube-proxy (I've seen profiles where it was more than 50%).

The commits are mostly independent from each other and all of them are mostly about reusing already allocated memory.

This PR is reducing memory allocation by ~5x (results below from 100-node load test):

before:
```
(pprof) top
38.64GB of 39.11GB total (98.79%)
Dropped 249 nodes (cum <= 0.20GB)
Showing top 10 nodes out of 61 (cum >= 0.20GB)
      flat  flat%   sum%        cum   cum%
   15.10GB 38.62% 38.62%    15.10GB 38.62%  bytes.makeSlice
    9.48GB 24.25% 62.87%     9.48GB 24.25%  runtime.rawstringtmp
    8.30GB 21.21% 84.07%    32.47GB 83.02%  k8s.io/kubernetes/pkg/proxy/iptables.(*Proxier).syncProxyRules
    2.08GB  5.31% 89.38%     2.08GB  5.31%  fmt.(*fmt).padString
    1.90GB  4.86% 94.24%     3.82GB  9.77%  strings.Join
    0.67GB  1.72% 95.96%     0.67GB  1.72%  runtime.hashGrow
    0.36GB  0.92% 96.88%     0.36GB  0.92%  runtime.stringtoslicebyte
    0.31GB  0.79% 97.67%     0.62GB  1.58%  encoding/base32.(*Encoding).EncodeToString
    0.24GB  0.62% 98.29%     0.24GB  0.62%  strings.genSplit
    0.20GB   0.5% 98.79%     0.20GB   0.5%  runtime.convT2E
```

after:
```
7.94GB of 8.13GB total (97.75%)
Dropped 311 nodes (cum <= 0.04GB)
Showing top 10 nodes out of 65 (cum >= 0.11GB)
      flat  flat%   sum%        cum   cum%
    3.32GB 40.87% 40.87%     8.05GB 99.05%  k8s.io/kubernetes/pkg/proxy/iptables.(*Proxier).syncProxyRules
    2.85GB 35.09% 75.95%     2.85GB 35.09%  runtime.rawstringtmp
    0.60GB  7.41% 83.37%     0.60GB  7.41%  runtime.hashGrow
    0.31GB  3.76% 87.13%     0.31GB  3.76%  runtime.stringtoslicebyte
    0.28GB  3.43% 90.56%     0.55GB  6.80%  encoding/base32.(*Encoding).EncodeToString
    0.19GB  2.29% 92.85%     0.19GB  2.29%  strings.genSplit
    0.18GB  2.17% 95.03%     0.18GB  2.17%  runtime.convT2E
    0.10GB  1.28% 96.31%     0.71GB  8.71%  runtime.mapassign
    0.10GB  1.21% 97.51%     0.10GB  1.21%  syscall.ByteSliceFromString
    0.02GB  0.23% 97.75%     0.11GB  1.38%  syscall.SlicePtrFromStrings
```
2017-05-19 23:21:49 -07:00
..
async
bandwidth IPv6 support for hexCIDR() 2017-05-17 20:35:37 +00:00
config autogenerated 2017-04-14 10:40:57 -07:00
configz
crlf
dbus autogenerated 2017-04-14 10:40:57 -07:00
ebtables
env fix various bad tests 2017-04-25 11:23:33 -07:00
errors
exec Extend Iptables interface with SaveInto 2017-05-19 20:44:25 +02:00
flock pkg/util/flock: Fix the flock so it actually locks. 2017-03-13 14:24:59 -07:00
framer
goroutinemap Make timeouts in the Kubelet slightly offset to aid debugging 2017-04-28 12:00:28 -04:00
hash Merge pull request #42085 from cblecker/gofmt-fix 2017-04-17 15:39:07 -07:00
i18n autogenerated 2017-04-14 10:40:57 -07:00
initsystem
interrupt
intstr
io autogenerated 2017-04-14 10:40:57 -07:00
ipconfig autogenerated 2017-04-14 10:40:57 -07:00
iptables Fix naming and comments in kube-proxy. 2017-05-19 21:34:05 +02:00
json
keymutex autogenerated 2017-04-14 10:40:57 -07:00
labels autogenerated 2017-04-14 10:40:57 -07:00
limitwriter
logs autogenerated 2017-04-14 10:40:57 -07:00
maps
metrics autogenerated 2017-04-14 10:40:57 -07:00
mount autogenerated 2017-04-14 10:40:57 -07:00
net
netsh autogenerated 2017-04-14 10:40:57 -07:00
node remove deprecated NodeLegacyHostIP 2017-04-24 11:01:25 +08:00
oom autogenerated 2017-04-14 10:40:57 -07:00
parsers autogenerated 2017-04-14 10:40:57 -07:00
procfs Merge pull request #44024 from zhangxiaoyu-zidif/egnew 2017-05-05 23:41:33 -07:00
rand
removeall autogenerated 2017-04-14 10:40:57 -07:00
resourcecontainer autogenerated 2017-04-14 10:40:57 -07:00
rlimit
runtime
selinux autogenerated 2017-04-14 10:40:57 -07:00
sets
slice Smarter describer for generic resources 2017-04-17 15:42:47 -03:00
strings
sysctl
system autogenerated 2017-04-14 10:40:57 -07:00
tail
taints autogenerated 2017-04-14 10:40:57 -07:00
term Fix golint and godeps verification 2017-05-15 16:28:56 +03:00
threading autogenerated 2017-04-14 10:40:57 -07:00
tolerations Auto-generated stuff. 2017-04-06 16:15:34 -04:00
uuid
validation
version
wait
workqueue/prometheus autogenerated 2017-04-14 10:40:57 -07:00
yaml
BUILD Remove unused chmod/chown abstractions 2017-04-23 20:25:23 -03:00
doc.go
template.go
template_test.go
umask.go
umask_windows.go
util.go
util_test.go