Thread: Re: Some read stream improvements

Re: Some read stream improvements

From
Kirill Reshke
Date:
On Mon, 17 Feb 2025 at 09:55, Thomas Munro <thomas.munro@gmail.com> wrote:
>
> Hi,
>
> Here are some patches that address some of Andres's feedback since the
> AIO v2 rebase[1], anticipate out-of-order streams, and make some other
> minor improvements.  They are independent of the main AIO patch set
> and apply to master, hence separate thread.

Hi, great!

> 0001-Refactor-read_stream.c-s-circular-arithmetic.patch
>
> This just replaced open-coded arithmetic with inline functions.  They
> will be used a lot more in later work, and provide central places to
> put assertions that were not checked as uniformly as I would like.

Just out of curiosity, should we `Assert(*index + n <
stream->queue_size);` in `read_stream_index_advance_n`?


-- 
Best regards,
Kirill Reshke



Re: Some read stream improvements

From
Thomas Munro
Date:
On Mon, Feb 17, 2025 at 6:55 PM Kirill Reshke <reshkekirill@gmail.com> wrote:
> Just out of curiosity, should we `Assert(*index + n <
> stream->queue_size);` in `read_stream_index_advance_n`?

No: it is allowed to be >= queue_size temporarily, but if so we
subtract queue_size.  The result should be equal to (index + n) %
queue_size, assuming small values of n, except we don't want to use %
in hot code.  Perhaps we should assert that though!