Data-UUID-MT
view release on metacpan or search on metacpan
specific version. Note that Data::UUID::LibUUID incorrectly refers to
version 1 UUIDs as version 2 UUIDs. For example, to get a version 1
binary UUID explicitly, you would call
Data::UUID::LibUUID::new_uuid_binary(2).
In addition to differences mentioned below, there are additional slight
difference in how the modules (or "libuuid") treat the "clock sequence"
field and otherwise attempt to keep state between calls, but this is
generally immaterial.
Use of Ethernet MAC addresses
Version 1 UUID generators differ in whether they include the Ethernet
MAC address as a "node identifier" as specified in RFC 4122. Including
the MAC has security implications as Version 1 UUIDs can then be traced
to a particular machine at a particular time.
For "libuuid" based modules, Version 1 UUIDs will include the actual MAC
address, if available, or will substitute a random MAC (with multicast
bit set).
Data::UUID version 1 UUIDs do not contain the MAC address, but replace
it with an MD5 hash of data including the hostname and host id (possibly
just the IP address), modified with the multicast bit.
Both UUID::Tiny and Data::UUID::MT version 1 UUIDs do not contain the
actual MAC address, but replace it with a random multicast MAC address.
Source of random bits
All the modules differ in the source of random bits.
"libuuid" based modules get random bits from "/dev/random" or
"/dev/urandom" or fall back to a pseudo-random number generator.
Data::UUID only uses random data to see the clock sequence and gets bits
from the C "rand()" function.
UUID::Tiny uses Perl's "rand()" function.
Data::UUID::MT gets random bits from Math::Random::MT::Auto, which uses
the Mersenne Twister algorithm. Math::Random::MT::Auto seeds from system
sources (including Win32 specific ones on that platform) if available
and falls back to other less ideal sources if not.
Fork and thread safety
Pseudo-random number generators used in generating UUIDs should be
reseeded if the process forks or if threads are created.
Data::UUID::MT checks if the process ID has changed before generating a
UUID and reseeds if necessary. If Scalar::Util is installed and provides
"weaken()", Data::UUID::MT will also reseed its objects on thread
creation.
Data::UUID::LibUUID will reseed on fork on Mac OSX.
I have not explored further whether other UUID generators are
fork/thread safe.
Benchmarks
The examples/bench.pl program included with this module does some simple
benchmarking of UUID generation speeds. Here is the output from my
desktop system (AMD Phenom II X6 1045T CPU). Note that "v?" is used
where the choice is left to "libuuid" -- which will result in version 4
UUIDs on my system.
Benchmark on Perl v5.14.0 for x86_64-linux with 8 byte integers.
Key:
U => UUID 0.02
UT => UUID::Tiny 1.03
DG => Data::GUID 0.046
DU => Data::UUID 1.217
DULU => Data::UUID::LibUUID 0.05
DUMT => Data::UUID::MT 0.001
Benchmarks are marked as to which UUID version is generated.
Some modules offer method ('meth') and function ('func') interfaces.
UT|v1 85229/s
UT|v4 110652/s
DULU|v1 177495/s
DULU|v? 178629/s
DUMT|v4s|meth 274905/s
DUMT|v1|meth 281942/s
U|v? 288136/s
DULU|v4 295107/s
DUMT|v4s|func 307575/s
DUMT|v1|func 313538/s
DG|v1|func 335333/s
DG|v1|meth 373515/s
DUMT|v4|meth 450845/s
DUMT|v4|func 588573/s
DU|v1 1312946/s
SEE ALSO
* RFC 4122 A Universally Unique IDentifier (UUID) URN Namespace
<http://www.apps.ietf.org/rfc/rfc4122.html>
SUPPORT
Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker at
<https://github.com/dagolden/data-uuid-mt/issues>. You will be notified
automatically of any progress on your issue.
Source Code
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
<https://github.com/dagolden/data-uuid-mt>
git clone git://github.com/dagolden/data-uuid-mt.git
AUTHOR
David Golden <dagolden@cpan.org>
CONTRIBUTOR
Matt Koscica <matt.koscica@gmail.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by David Golden.
This is free software, licensed under:
( run in 2.370 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )