Git Product home page Git Product logo

Comments (8)

chuckremes avatar chuckremes commented on June 19, 2024

When I profile this, all of the time was in systemu which is a dependency for macaddr.

from uuid.

assaf avatar assaf commented on June 19, 2024

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.

chuckremes avatar chuckremes commented on June 19, 2024

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.

assaf avatar assaf commented on June 19, 2024

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.

chuckremes avatar chuckremes commented on June 19, 2024

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.

assaf avatar assaf commented on June 19, 2024

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.

chuckremes avatar chuckremes commented on June 19, 2024

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.

assaf avatar assaf commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.