Re: use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`
Дата
Msg-id 20210506190841.sqxci46qamoyb55u@alap3.anarazel.de
обсуждение исходный текст
Ответ на use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`  ("盏一" <w@hidva.com>)
Ответы Re: use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`
Re: use `proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`
Список pgsql-hackers
Hi,

On 2021-05-07 00:30:13 +0800, 盏一 wrote:
> Since we have introduced `pgxactoff` in
[941697c3c1ae5d6ee153065adb96e1e63ee11224](https://github.com/postgres/postgres/commit/941697c3c1ae5d6ee153065adb96e1e63ee11224),
and`pgxactoff` is always the index of `proc->pgprocno` in `procArray->pgprocnos`. So it seems that we could directly
use`proc->pgxactoff` as the value of `index` in `ProcArrayRemove()`? My thought is to replace
 
>
> ```c
> for (index = 0; index < arrayP->numProcs; index++)
> {
>   if (arrayP->pgprocnos[index] == proc->pgprocno)
>   {
>       /* ... */
>   }
> }
> ```
>
> with
>
> ```c
> index = proc->pgxactoff;
> /* ... */
> ```

Sounds like a plan! Do you want to write a patch?

If you do, I think it might be worthwhile to add an only-with-assertions
loop checking that there's no other entry with the same pgprocno in the
dense arrays.

Given that the code is new in 14, I wonder if we should cram this
simplification in before beta? I don't think this is likely to matter
performance wise, but it seems like it'll make maintenance easier to not
have it look different in 14 than it does both in 13 and 15.

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Printing backtrace of postgres processes
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Printing backtrace of postgres processes