kubernetes/pkg/controller
Kubernetes Submit Queue f1d9962fec Merge pull request #53720 from shyamjvs/test-kubemark
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Optimize random string generator to avoid multiple locks & use bit-masking

Ref https://github.com/kubernetes/kubernetes/issues/53327

We recently started seeing a 50% decrease in scheduling throughput (for e.g in kubemark-500 scale job) and turns out https://github.com/kubernetes/kubernetes/pull/53135 introduced it.
The reason is [this call](2caae38d32/plugin/pkg/scheduler/algorithm/predicates/predicates.go (L272)) to create a random 32-length string.
From the code of the `rand` utility (which is being heavily used throughout the system for randomizing object names), I noticed following performance issues:
- to create an n-length string, we are making n calls to `rand.Intn()` each of which does a lock+unlock operation on the RNG.. while just 1 lock+unlock operation is enough for all
- we're choosing one character (from an alphabet of 27 chars) per each random integer.. while we can select 10 characters using a single int63 (by masking and bit-shifting) as 1 character uses just 5 bits of randomness
- the character set is defined as a global slice (mutable), so the compiler needs to fetch length of the slice on each invocation to `len()` (we're making n of those).. while we can just use a const string (immutable) which will make len directly available as a cached constant (yes, go does it!)

This PR is making the above fixes. I'll try to add some benchmarking to measure the difference (as @wojtek-t suggested).

/cc @kubernetes/sig-scalability-misc @kubernetes/sig-scheduling-bugs @kubernetes/sig-api-machinery-misc @wojtek-t @smarterclayton
2017-10-13 06:11:09 -07:00
..
bootstrap Using assertions 2017-10-10 22:44:12 -05:00
certificates controllers: simplify deepcopy calls 2017-08-29 19:21:24 +02:00
cloud Merge pull request #53517 from andrewsykim/improve-ccm-logging 2017-10-11 10:43:58 -07:00
cronjob Refactor cronjob test case with sets.String 2017-09-04 22:02:27 +08:00
daemon Merge pull request #51754 from huzhengchuan/fix/event_name 2017-10-04 13:13:15 -07:00
deployment Merge pull request #53589 from sttts/sttts-pkg-api-testing 2017-10-11 15:14:45 -07:00
disruption controllers: simplify deepcopy calls 2017-08-29 19:21:24 +02:00
endpoint controllers: simplify deepcopy calls 2017-08-29 19:21:24 +02:00
garbagecollector Remove GC rate limiter metrics 2017-09-21 19:23:27 -04:00
history Remove kargakis from OWNERS, add tnozicka 2017-09-19 11:05:23 +02:00
job Improve how JobController use queue for backoff 2017-09-07 17:14:47 +02:00
namespace add an starting info log of namespace controller. 2017-08-26 00:25:37 +08:00
node Merge pull request #52402 from yastij/nodecontroller-clean-backwards 2017-10-11 06:10:54 -07:00
podautoscaler Fix hpa scaling above max replicas w/ scaleUpLimit 2017-10-11 08:35:31 -04:00
podgc Make metav1.(Micro)?Time functions take pointers 2017-08-17 11:24:28 +02:00
replicaset remove replicaset unit tests that are converted to integration tests 2017-10-06 18:03:19 -07:00
replication Remove kargakis from OWNERS, add tnozicka 2017-09-19 11:05:23 +02:00
resourcequota Ignore pods for quota that exceed deletion grace period 2017-09-11 13:31:52 -04:00
route rename the name of eventsource in controller-manager 2017-09-04 23:30:59 +08:00
service Merge pull request #53487 from oracle/for/upstream/master/service-event-logging 2017-10-06 09:56:19 -07:00
serviceaccount Optimize random string generator to avoid multiple locks & use bitmasking 2017-10-12 19:13:17 +02:00
statefulset Merge pull request #51754 from huzhengchuan/fix/event_name 2017-10-04 13:13:15 -07:00
testutil Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
ttl controllers: simplify deepcopy calls 2017-08-29 19:21:24 +02:00
volume Make sure we use rwlocks not just RLock 2017-10-10 17:52:55 -04:00
.import-restrictions add import restrictions 2016-10-13 16:10:24 -07:00
BUILD Using assertions 2017-10-10 22:44:12 -05:00
client_builder.go Scripted migration from clientset_generated to client-go. 2017-07-17 15:05:37 -07:00
controller_ref_manager_test.go Merge pull request #50353 from zhangxiaoyu-zidif/Delete-redundant-expectError-for-controller-ref-test 2017-08-12 00:00:55 -07:00
controller_ref_manager.go Migrate to GetControllerOf from meta/v1 package 2017-08-06 22:41:58 +10:00
controller_utils_test.go Using assertions 2017-10-10 22:44:12 -05:00
controller_utils.go Slow-start batch pod creation of rs, rc, ds, jobs 2017-09-01 09:23:43 -06:00
doc.go
lookup_cache.go Use fnv.New32a() in hash instead adler32 2017-02-15 14:03:54 +08:00
OWNERS remove some people from OWNERS so they don't get reviews anymore 2017-07-13 10:02:21 -07:00