Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell random numbers suddenly start to "converge" after months of running

Tags:

random

haskell

I have a server program that randomly selects 10 from a group of network peers to accomplish a task. The code that generates the random indices of the peers is as follows:

indices = let index = getStdRandom $ randomR (0, number_of_peers - 1)           in sequence $ replicate 10 index 

The program has been running for months, generating thousands of `indices' each day, and has been working fine until yesterday, when I noticed that something has gone wrong: the random numbers generated seem to "converge" to a few repeating values (the result is that the corresponding network peers are heavily loaded).

To see the change, below is from the server log a few days ago:

peers selected: [55,47,80,74,183,85,04,33,72,58]  

and the log from today's (as you can see, peer 53, 37 and 195 are repeatedly selected):

peers selected: [53,53,37,37,37,37,195,195,195,21]  

The program is running on an x86_64 version of Ubuntu 10.10.

like image 934
Aufheben Avatar asked Aug 13 '13 03:08

Aufheben


Video Answer


1 Answers

After investigation this turns out to be an embarrassing bug of my own: the root user on this server has a limit of maximum open files of 1024, which is unexpectedly low (but I heard that this is the default on Ubuntu). When the server program has too many open sockets, some part of the system starts to reject the peers, making their status 'inactive'. The actual 'indices' is:

indices = let index = getStdRandom $ randomR (0, M.size active - 1) in               sequence $ replicate (n * 2) index 

I'm sorry if this question is causing any trouble or confusion. I'll try to post more prudently next time.

like image 198
Aufheben Avatar answered Nov 11 '22 13:11

Aufheben