Re: [PATCH] libuuid: avoid truncate clocks.txt to improve performance

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

 



Hi Karel,

with activated –cont-clock the clock.txt is not updated in most cases – there still can be a fallback to the clock.txt update - and the XFS regression would not be relevant, that’s correct. 
But as there have been discussions and concerns about avoiding the clock.txt update, I would be happy to have a solution for this code sequence as well. It will preserve the available logic without the XFS/ftruncate regression and customers still have the option to switch between both variants without a performance impact.

Could you please apply this patch to util-linux?
 

Michael

> On 7. Nov 2023, at 10:33, Karel Zak <kzak@xxxxxxxxxx> wrote:
> 
> 
> Michael, any objection or comment?
> 
> I have seen reports with XFS performance issues too, but I guess it's
> possible to solve the problem with uuidd and --cont-clock.
> 
>    Karel
> 
> On Tue, Oct 10, 2023 at 06:08:59PM -0500, Goldwyn Rodrigues wrote:
>> Instead of explicitly truncating clocks.txt file, pad with
>> whitespaces in the end of file.
>> This is done to improve performance of libuuid on xfs
>> filesystems. Instead of truncating the file, pad it with whitespaces.
>> This is anyways used as a failsafe method in case truncate fails.
>> 
>> The reason why this regression was introduced was because of:
>> 869ae85dae64 ("xfs: flush new eof page on truncate to avoid post-eof corruption")
>> 
>> An attempt to move the clocks.txt to /run (tmpfs) has been attempted before
>> [1] and with commit ab2e7dd17 ("libuuid: move clock state file from
>> /var/lib to /var/run"). The latter was reverted.
>> 
>> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
>> 
>> ---
>> libuuid/src/gen_uuid.c | 9 ++-------
>> 1 file changed, 2 insertions(+), 7 deletions(-)
>> 
>> diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
>> index 619ef0131..97e2dec4e 100644
>> --- a/libuuid/src/gen_uuid.c
>> +++ b/libuuid/src/gen_uuid.c
>> @@ -229,7 +229,6 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
>> struct timeval tv;
>> uint64_t clock_reg;
>> mode_t save_umask;
>> - int len;
>> int ret = 0;
>> 
>> if (state_fd == -1)
>> @@ -324,14 +323,10 @@ try_again:
>> 
>> if (state_fd >= 0) {
>> rewind(state_f);
>> - len = fprintf(state_f,
>> -      "clock: %04x tv: %016ld %08ld adj: %08d\n",
>> + fprintf(state_f,
>> +      "clock: %04x tv: %016ld %08ld adj: %08d                   \n",
>>      clock_seq, (long)last.tv_sec, (long)last.tv_usec, adjustment);
>> fflush(state_f);
>> - if (ftruncate(state_fd, len) < 0) {
>> - fprintf(state_f, "                   \n");
>> - fflush(state_f);
>> - }
>> rewind(state_f);
>> flock(state_fd, LOCK_UN);
>> }
>> -- 
>> 2.42.0
>> 
>> 
>> -- 
>> Goldwyn
>> 
> 
> -- 
> Karel Zak  <kzak@xxxxxxxxxx>
> 





[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