Re: [EXTERNAL] Re: Support load balancing in libpq
Andrey Borodin <amborodin86@gmail.com>
From: Andrey Borodin <amborodin86@gmail.com>
To: Jelte Fennema <postgres@jeltef.nl>
Cc: Greg S <stark.cfm@gmail.com>, Jacob Champion <jchampion@timescale.com>, Maxim Orlov <orlovmg@gmail.com>, Jelte Fennema <Jelte.Fennema@microsoft.com>, Michael Banck <mbanck@gmx.net>,
Aleksander Alekseev <aleksander@timescale.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Andres Freund <andres@anarazel.de>
Date: 2023-03-03T04:52:49Z
Lists: pgsql-hackers
On Wed, Mar 1, 2023 at 12:03 PM Jelte Fennema <postgres@jeltef.nl> wrote: > > done and updated cf entry > Hi Jelte! I've looked into the patch. Although so many improvements can be suggested, It definitely makes sense as-is too. These improvements might be, for example, sorting hosts according to ping latency or something like that. Or, perhaps, some other balancing policies. Anyway, randomizing is a good start too. I want to note that the Fisher-Yates algorithm is implemented in a difficult to understand manner. +if (j < i) /* avoid fetching undefined data if j=i */ This stuff does not make sense in case of shuffling arrays inplace. It is important only for making a new copy of an array and only in languages that cannot access uninitialized values. I'd suggest just removing this line (in both cases). Best regards, Andrey Borodin.
Commits
-
Fix pointer cast for seed calculation on 32-bit systems
- 2fe7a6df94e6 16.0 landed
-
Copy and store addrinfo in libpq-owned private memory
- 44d85ba5a336 16.0 landed
-
libpq: Use modern socket flags, if available.
- bfc9497ece01 16.0 cited