| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Tristan Partin <tristan(at)partin(dot)io>, Dominique Devienne <ddevienne(at)gmail(dot)com> |
| Subject: | Re: Improve the granularity of PQsocketPoll's timeout parameter? |
| Date: | 2024-06-12 17:53:13 |
| Message-ID: | 1505329.1718214793@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I agree this is not great. I guess I didn't think about it very hard
> because, after all, we were just exposing an API that we'd already
> been using internally. But I think it's reasonable to adjust the API
> to allow for better resolution, as you propose. A second is a very
> long amount of time, and it's entirely reasonable for someone to want
> better granularity.
Here's a v2 responding to some of the comments.
* People pushed back against not using "int64", but the difficulty
with that is that we'd have to #include c.h or at least pg_config.h
in libpq-fe.h, and that would be a totally disastrous invasion of
application namespace. However, I'd forgotten that libpq-fe.h
does include postgres_ext.h, and there's just enough configure
infrastructure behind that to allow defining pg_int64, which indeed
libpq-fe.h is already relying on. So we can use that.
* I decided to invent a typedef
typedef pg_int64 PGusec_time_t;
instead of writing "pg_int64" explicitly everywhere. This is perhaps
not as useful as it was when I was thinking the definition would be
"long long int", but it still seems to add some readability. In my
eyes anyway ... anyone think differently?
* I also undid changes like s/end_time/end_time_us/. I'd done that
mostly to ensure I looked at/fixed every reference to those variables,
but on reflection I don't think it's doing anything for readability.
* I took Ranier's suggestion to make fast paths for end_time == 0.
I'm not sure this will make any visible performance difference, but
it's simple and shouldn't hurt. We do have some code paths that use
that behavior.
* Ranier also suggested using clock_gettime instead of gettimeofday,
but I see no reason to do that. libpq already relies on gettimeofday,
but not on clock_gettime, and anyway post-beta1 isn't a great time to
start experimenting with portability-relevant changes.
regards, tom lane
| Attachment | Content-Type | Size |
|---|---|---|
| pqsocketpoll-in-microseconds-v2.patch | text/x-diff | 13.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2024-06-12 17:53:22 | Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs |
| Previous Message | Daniele Varrazzo | 2024-06-12 17:38:54 | Re: RFC: adding pytest as a supported test framework |