UUID new is pretty slow ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

UUID new is pretty slow ...

GLASS mailing list
... I was not aware of it. I created 11000 objects from a CSV file and
to get IDs within these objects I use the UUID class of Gemstone.

 It took very long and I found out, that the creation of the 11000
objects took pretty long ... until I found, that "UUID new" was the
reason for that. It is very expensive. Calling this method 11000 times
took 5.1s (average).

 I now use native libraries from Linux and now creating 11000 UUIDs
takes around 0.3 to 0.5 seconds.

 Solution goes via the external library "libuuid.so.1". With

fnUUIDGenerate
        "^<String> "

        ^CCallout
                library: 'libuuid.so.1'
                name: 'uuid_generate'
                result: #void args: #(#ptr)

and

uuidGenerate
        "Prints a UUID value to base 62 (to get a short string)"

        | temp num |

        temp := CByteArray gcMalloc: (1 * 16).
        self fnUUIDGenerate callWith: (Array with: temp ).

        num := 0.
        0 to: 15 do: [:i |
          num := num + ((256 raisedTo: i) * (temp int8At: i))
        ].

        ^num pumPrintStringRadix: 62 showRadix: false

--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

Paul DeBruicker
Hi Marten,

A few years ago I made a library that does just that:


MCHttpRepository
        location: 'http://smalltalkhub.com/mc/pdebruic/UUIDFFI/main'
        user: ''
        password: ''


I wish the search capabilities of Smalltalkhub were better.


Paul

GLASS mailing list wrote
... I was not aware of it. I created 11000 objects from a CSV file and
to get IDs within these objects I use the UUID class of Gemstone.

 It took very long and I found out, that the creation of the 11000
objects took pretty long ... until I found, that "UUID new" was the
reason for that. It is very expensive. Calling this method 11000 times
took 5.1s (average).

 I now use native libraries from Linux and now creating 11000 UUIDs
takes around 0.3 to 0.5 seconds.

 Solution goes via the external library "libuuid.so.1". With

fnUUIDGenerate
        "^<String> "

        ^CCallout
                library: 'libuuid.so.1'
                name: 'uuid_generate'
                result: #void args: #(#ptr)

and

uuidGenerate
        "Prints a UUID value to base 62 (to get a short string)"

        | temp num |

        temp := CByteArray gcMalloc: (1 * 16).
        self fnUUIDGenerate callWith: (Array with: temp ).

        num := 0.
        0 to: 15 do: [:i |
          num := num + ((256 raisedTo: i) * (temp int8At: i))
        ].

        ^num pumPrintStringRadix: 62 showRadix: false

--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

GLASS mailing list
Same problem ... same solution .-)

Marten



--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

GLASS mailing list
In reply to this post by GLASS mailing list
On 06/30/2015 07:53 AM, [hidden email] via Glass wrote:

> ... I was not aware of it. I created 11000 objects from a CSV file and
> to get IDs within these objects I use the UUID class of Gemstone.
>
>  It took very long and I found out, that the creation of the 11000
> objects took pretty long ... until I found, that "UUID new" was the
> reason for that. It is very expensive. Calling this method 11000 times
> took 5.1s (average).
>
>  I now use native libraries from Linux and now creating 11000 UUIDs
> takes around 0.3 to 0.5 seconds.
>
I think the current GemStone implementation of UUID generation was taken
from Squeak a number of years ago. I took a look at how it's
implemented, and it's done just about the slowest way imaginable. So I
made a simpler, faster implementation. I believe it's compatible with
the existing implementation, just faster. Attached is a replacement for
the class UUIDGenerator that is almost 100x faster -- I can generate
11000 UUIDs in about 0.02 seconds with pure Smalltalk, so it might be
even faster than using native libraries.

This was done on the latest unreleased GemStone, but will probably work
in any 3.x version. If you try it, let me know what results you get.

Regards,

-Martin

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass

UUIDGenerator.gs (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

GLASS mailing list
Pretty cool ... thanks !

Marten


--
Marten Feldtmann
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

GLASS mailing list
In reply to this post by GLASS mailing list
Martin,

Great! ... I've started looking into incorporating your implementation into the standard GsDevKit/GLASS code base.

Dale

On 06/30/2015 01:12 PM, Martin McClure via Glass wrote:
On 06/30/2015 07:53 AM, [hidden email] via Glass wrote:
... I was not aware of it. I created 11000 objects from a CSV file and
to get IDs within these objects I use the UUID class of Gemstone.

 It took very long and I found out, that the creation of the 11000
objects took pretty long ... until I found, that "UUID new" was the
reason for that. It is very expensive. Calling this method 11000 times
took 5.1s (average).

 I now use native libraries from Linux and now creating 11000 UUIDs
takes around 0.3 to 0.5 seconds.

I think the current GemStone implementation of UUID generation was taken
from Squeak a number of years ago. I took a look at how it's
implemented, and it's done just about the slowest way imaginable. So I
made a simpler, faster implementation. I believe it's compatible with
the existing implementation, just faster. Attached is a replacement for
the class UUIDGenerator that is almost 100x faster -- I can generate
11000 UUIDs in about 0.02 seconds with pure Smalltalk, so it might be
even faster than using native libraries.

This was done on the latest unreleased GemStone, but will probably work
in any 3.x version. If you try it, let me know what results you get.

Regards,

-Martin


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: UUID new is pretty slow ...

GLASS mailing list
Pushed Martin's FastUUIDGenerator class to glassdb/glass, so if you use GsUpgrade class>>upgradeGLASS1, you'll get the latest release.

With this release, FastUUIDGenerator becomes the default UUIDGenerator class for UUID for GemStone 3.x.

Dale

[1] https://github.com/GsDevKit/GsDevKit/issues/69

On 07/01/2015 09:18 AM, Dale Henrichs wrote:
Martin,

Great! ... I've started looking into incorporating your implementation into the standard GsDevKit/GLASS code base.

Dale

On 06/30/2015 01:12 PM, Martin McClure via Glass wrote:
On 06/30/2015 07:53 AM, [hidden email] via Glass wrote:
... I was not aware of it. I created 11000 objects from a CSV file and
to get IDs within these objects I use the UUID class of Gemstone.

 It took very long and I found out, that the creation of the 11000
objects took pretty long ... until I found, that "UUID new" was the
reason for that. It is very expensive. Calling this method 11000 times
took 5.1s (average).

 I now use native libraries from Linux and now creating 11000 UUIDs
takes around 0.3 to 0.5 seconds.

I think the current GemStone implementation of UUID generation was taken
from Squeak a number of years ago. I took a look at how it's
implemented, and it's done just about the slowest way imaginable. So I
made a simpler, faster implementation. I believe it's compatible with
the existing implementation, just faster. Attached is a replacement for
the class UUIDGenerator that is almost 100x faster -- I can generate
11000 UUIDs in about 0.02 seconds with pure Smalltalk, so it might be
even faster than using native libraries.

This was done on the latest unreleased GemStone, but will probably work
in any 3.x version. If you try it, let me know what results you get.

Regards,

-Martin


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass



_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass