Comments (8)
When I profile this, all of the time was in systemu which is a dependency for macaddr.
from uuid.
This gem is designed to generate UUID as fast as possible. It is not designed to generate UUID generators very fast. The common case application only uses one UUID generator.
from uuid.
Would you accept a patch that adds a class method (UUID.mac_address) that cached the system's MAC so new instantiations of the class didn't have to query the system interfaces for that (unchanging) information?
from uuid.
Since an application is not supposed to generate many (most common, exactly one) classes, the performance difference would be unmeasurable. No amount of code is worth an unmeasurable gain.
from uuid.
Pull request has been sent. The amount of code hasn't increased and all tests still pass. The performance is 100x better on JRuby.
I would appreciate it if you accepted the patch so I don't have to maintain my own fork.
from uuid.
Performance has not improved for the case where one UUID object is necessary, and the case where you'll need to create 100 UUID objects still need to be explained.
from uuid.
Performance for the singular case has not worsened either. With the current release version of the uuid gem (2.3.4), it takes approximately 1200 milliseconds for JRuby to allocate a single UUID instance with UUID.state_file=nil. That is entirely due to macaddr and its dependent gem systemu calling out to the system to retrieve the MAC address. Even for a single UUID object, that is ridiculous. My patch solves it.
Anyway, my use-case is as follows.
I have a distributed application comprised of hundreds of classes (it's a very big app). Many of these classes use UUID for a globally unique identifier to identify themselves as they pass messages around the network.
It is not reasonable for me to change method signatures so that a global "parent" object can allocate a singular UUID generator and then pass it around to all objects. Some objects are rather deeply nested in the system, so this would require intermediate objects (that have no use for a UUID generator) to save a reference to pass it along to the children objects.
I suppose I could use a global variable or a constant high in the namespace to hold it.
What do you suggest? My simple fix? Do you suggest that I move to a global or constant to satisfy the restrictions of your gem? Should I just fork it?
from uuid.
Use UUID.generate
. It guarantees you won't get duplicate UUIDs.
Avoid generating many UUID objects. You're going to run into all sorts of issues, including duplicate UUIDs.
from uuid.
Related Issues (20)
- UUID.generate collisions when called too often HOT 5
- Cant Convert Class to String - Jruby Rake HOT 2
- Executable name conflict
- nil.unpack issue HOT 17
- How random / predictable are the results? HOT 3
- uuid should not make hardcoded assumptions about temporary directories HOT 1
- Version of UUID generated HOT 3
- FakeFS interference
- You checked in the bundler binstub of bin/uuid HOT 1
- Errno::EACCES: Permission denied - /root/.ruby-uuid HOT 3
- Add License information to Gemspec HOT 2
- Sort method (or cmp) should be implemented for time based UUID's
- "Gemfile not found" when using rbenv HOT 4
- add development dependency on mocha
- clarify license statement HOT 1
- use /tmp for state dir HOT 12
- Unique and random uuid HOT 5
- Version 2.3.7 or 2.3.8 HOT 5
- How does this compare to SecureRandom.uuid? HOT 2
- Add generate method usage to readme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uuid.