Treat `nil` Amount as 0 in `resource.Quantity.Add` and
`resource.Quantity.Sub`. Also, allow adding/subtracting resources with
different Formats (since Format has no effect on the underlying value).
The original scale function takes around 800ns/op with more
than 10 allocations. It significantly slow down scheduler
and other components that heavily relys on resource pkg.
For more information see #18126.
This pull request tries to optimize scale function. It takes
two approach:
1. when the value is small, only use normal math ops.
2. when the value is large, use math.Big with buffer pool.
The final result is:
BenchmarkScaledValueSmall-4 20000000 66.9 ns/op 0 B/op 0 allocs/op
BenchmarkScaledValueLarge-4 2000000 711 ns/op 48 B/op 1 allocs/op
I also run the scheduler benchmark again. It doubles the throughput of
scheduler for 1000 nodes case.
make etcd registry pass test
fix kubelet config for quantity
fix openstack for quantity
fix controller for quantity
fix last tests for quantity
wire into binaries
fix controller manager
fix build for 32 bit systems