I'm not sure how big of a deal this is, but it bothers me that we're doing linear searches to "calculate" mcs labels, so I'd like to do it in constant time. One solution would be to cache the mapping; another would be to use some middle school algebra. I'm doing the latter.
Created attachment 768455 [details] Patch to calculate mcs labels
For a max uid of 7000, there's only about 0.1 second difference between the linear search and this patch (assuming the patch for https://bugzilla.redhat.com/show_bug.cgi?id=981022 is applied in both cases). The linear search takes about 0.1 extra seconds for each additional 10000 uids, though. Also, on busy machines, the "real" or "wall clock" time can be much longer, which affects the user experience for things like ssh logins.
Thanks! Patch looks good and gets the right numbers.
Commit pushed to master at https://github.com/openshift/origin-server https://github.com/openshift/origin-server/commit/2a56f7939a0501a646566a129bc10f1dc3c320cb Bug 981037 - Use an O(1) generator for the common use case.
Test on devenv_3471, the time of run oo-get-mcs-level reduced a lot than the stage_ami. For stage: [root@ip-10-147-131-70 ~]# time oo-get-mcs-level 523775 s0:c1021,c1023 real 0m3.426s user 0m3.270s sys 0m0.113s For patched devenv: [root@ip-10-152-170-195 ~]# time oo-get-mcs-level 523775 s0:c1021,c1023 real 0m0.309s user 0m0.206s sys 0m0.079s Move bug to verified.