[Glass] UUID new is pretty slow ...

itlists@schrievkrom.de via Glass glass at lists.gemtalksystems.com
Tue Jun 30 07:53:09 PDT 2015


... 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


More information about the Glass mailing list