Re: [PATCH] libuuid, extend cache in uuid_generate_time_generic()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 24, 2022 at 11:46:51AM +0100, Michael Trapp wrote:
> In a high load scenario, where an application continiously reads time
> based version 1 uuids from uuidd, we have noticed the following
> behaviour.

It means that your application reads more than 1000 UUIDs per second
in one thread :-) The "cache" has 1 second live-time.

> The application reads more uuids as there are available in the
> corresponding timeframe and each bulk request results in an increment of
> the clock sequence because of the 'step back' in time. Due to the
> 14bit size of the clock sequence this also results in overflows of
> the clock sequence.

hmm ...

> 
> As uuidd calls
>     uuid_generate_time_safe()
>        uuid_generate_time_generic()
> the default value for the bulk request in the '#ifdef HAVE_TLS' section
> of uuid_generate_time_generic() is set to 1000.
> 
> Extending the 'cache' of uuid_generate_time_generic() by increasing
> the default of num to 1000000 doesn't solve the issue, but reduces
> the clock sequence increments by factor 1000 and it also improves
> the uuid throughput in our setup by factor 3-4.

Well, uu.time_low is uint32_t, so there should be enough bytes to
handle 1000000 UUIDs by the cache (and it also increments uu.time_mid
and uu.time_hi_and_version).

If I read the code correctly than in theory the cache size could
be UINT32_MAX.

> It might be possible to implement a cache for
>   UUIDD_OP_BULK_TIME_UUID
>   UUIDD_OP_TIME_UUID
> in the uuidd request handling, but it would not be as simple as this fix
> in uuid_generate_time_generic().

The question is, what is the bottleneck? From my point            

    rewind/flock/fscanf/rewind/fprintf/fflush/unlock             
                                    
seems like a pretty expensive solution for the sequence file. Maybe for
the next development we should think about something more elegant like
a memory shared between uuidd instances. The question is also if uuidd 
has to share the file with the library because for extreme use-case like
databases, it does not make sense.

>  src/gen_uuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

 Applied, thanks!

 https://github.com/util-linux/util-linux/commit/0f8de4902fe3f3512ee5043c5277d002a488a804


   Karel




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux