Re: refactoring basebackup.c

From: Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>
Subject: Re: refactoring basebackup.c
Date: 2021-09-22 16:52:40
Message-ID: CAOgcT0M+RYf8+3Wjx_YVfZD99ZvzMZX7anMR7XKXR6VobApMEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 21, 2021 at 10:50 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

>
> + if (opt->compression == BACKUP_COMPRESSION_LZ4)
>
> else if
>
> + /* First of all write the frame header to destination buffer. */
> + Assert(CHUNK_SIZE >= LZ4F_HEADER_SIZE_MAX);
> + headerSize = LZ4F_compressBegin(mysink->ctx,
> + mysink->base.bbs_next->bbs_buffer,
> + CHUNK_SIZE,
> + prefs);
>
> I think this is wrong. I think you should be passing bbs_buffer_length
> instead of CHUNK_SIZE, and I think you can just delete CHUNK_SIZE. If
> you think otherwise, why?
>
> + * sink's bbs_buffer of length that can accomodate the compressed input
>
> Spelling.
>
> + * Make it next multiple of BLCKSZ since the buffer length is expected so.
>
> The buffer length is expected to be a multiple of BLCKSZ, so round up.
>
> + * If we are falling short of available bytes needed by
> + * LZ4F_compressUpdate() per the upper bound that is decided by
> + * LZ4F_compressBound(), send the archived contents to the next sink to
> + * process it further.
>
> If the number of available bytes has fallen below the value computed
> by LZ4F_compressBound(), ask the next sink to process the data so that
> we can empty the buffer.
>

Thanks for your comments, Robert.
Here is the patch addressing the comments, except the one regarding the
autoFlush flag setting.

Kindly have a look.

Regards,
Jeevan Ladhe

Attachment Content-Type Size
lz4_compress_v3.patch application/octet-stream 11.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2021-09-22 16:57:29 Re: logical replication restrictions
Previous Message Jeevan Ladhe 2021-09-22 16:40:32 Re: refactoring basebackup.c