Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

The basic one is that with any mechanism that has random numbers at its core, there is no guarantee of uniqueness, despite what Data::UUID POD says. (If you look up the RFC it uses the phrase: "is either guaranteed to be different from all other UUIDs/GUIDs generated until 3400 A.D. or extremely likely to be different".

The probability of collision might be very small, but it still exists. It would therefore be necessary to record enough information to disambiguate between chance collisions. And that means recording all the information that went into generating the number in the first place. As I wouldn't have access to all the information, that isn't possible.

A second reason is that the timestamping mechanisms used by Data::UUID are broken.

  1. On Windows: It uses QueryPerformanceCounter() api to get a timestamp to the required 100 nanosecond resolution.

    But this high resolution elapsed time counter is known to drift with respect to the system clock, but the module make no attempt at corrections.

    See Time::HiRes for its correction mechanism.

  2. On other systems: it uses GetSystemTime(2).

    But that api is limited to microsecond resolution, so it just multiplies by 10.

While the spec calls for a once-only randomly initialised, thereafter monotically increasing, sequence component, I can see no provision for storing/retrieving this on windows systems.

The output of the true_random() function is suspect on systems where rand()is limited to 15 bits.

As my needs are limited to a single system, using a deterministic value with a self-consistent, high resolution time component will suffice.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^2: Generate a unique ID by BrowserUk
in thread Generate a unique ID by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found