Commit Graph

2 Commits (8a8177f99e953fe842613b39029a15aa6491814a)

Author SHA1 Message Date
Tim St. Clair 40e90886e6 Add micro- and nano- suffixes 2016-01-04 14:08:24 -08:00
Xiang Li cf82d6b004 resource: optimize scale function
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.
2015-12-03 17:00:13 -08:00