-
Notifications
You must be signed in to change notification settings - Fork 80
Allocation performance is *terrible* under JRuby when UUID.state_file = false #19
Comments
When I profile this, all of the time was in systemu which is a dependency for macaddr. |
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. |
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? |
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. |
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. |
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. |
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? |
Use Avoid generating many UUID objects. You're going to run into all sorts of issues, including duplicate UUIDs. |
Generated by code:
The text was updated successfully, but these errors were encountered: