My patch changes some uses of rand() to the faster mt_rand().
Attachment:mt_rand.patch
lgtm (looks good to me)
(In [7627]) Fixes #3491, applying pebosi's patch to use mt_rand instead of rand.