From: Andy (atompkins_at_[hidden])
Date: 2007-06-01 13:13:01
"Jos Hickson" <jos.hickson_at_[hidden]> wrote in
> On 01/06/07, Dave Jenkins <david_at_[hidden]> wrote:
>> You did a nice job speeding up the uuid::create(engine) function to
>> 0.4 seconds for 1 million UUIDs. But now the uuid::create() function
>> is extremely slow - 131 seconds for 1 million UUIDs (source code
>> below). Can you change it to use a static mt19937 engine?
There was opposition to using static objects because of threading
concerns. I do want a function that doesn't require the user to create
a random number generator themselves.
If I use a static engine, I need to protect it with a mutex. This is
not optimal because there is the overhead of locking and unlocking the
mutex. Some people would rather have a static engine per thread using
thread local storage. This still requires one to link with
Boost.Thread. I created the uuid::create(Engine) function (great advice
from this list) so that users could do whatever they want (static engine
per thread, use thread local storage,...).
The uuid::create() function should handle the common case and not be
best for all situations. So, I guess I need help to determine what the
common case is.
> On a related note: doesn't reseeding the random number generator every
> time uuid::create() is called reduce the quality of the random numbers
> from the mt19937 engine?
> Doesn't the randomness then come from the
> seeding mechanism which is used? So, on the whole it would indeed be
> better to use a static engine if possible.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk