From: | "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
Cc: | "Joel Jacobson" <joel(at)compiler(dot)org>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Optimize LISTEN/NOTIFY |
Date: | 2025-10-07 21:14:14 |
Message-ID: | DDCEFOY8EM1K.1J482Q68KES6U@gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue Oct 7, 2025 at 1:51 PM -03, Tom Lane wrote:
> Matheus Alcantara <matheusssilv97(at)gmail(dot)com> writes:
>> 7. I'm wondering if we could add some TAP tests for this?
>
> async.c seems already moderately well covered by existing tests
> src/test/regress/sql/async.sql
> src/test/isolation/specs/async-notify.spec
>
> Do we need more? If there's something not covered, can we extend
> those test cases instead of spinning up a whole new installation
> for a TAP test?
>
I've executed the test coverage on v9 and it seems that we still have a
good code coverage. I would imagine with the new branches that the code
coverage could be effected but it's not true. There is just some small
piece of new code added that is not being coveraged.
> Also, I don't think it's the job of this patch to provide test
> coverage for dshash. That should be quite well covered already.
>
When I was mentioning to test that we can grow the dshash correctly it's
because the v9 patch has a logic to grow the array stored on dshash
entry value that currently is not being cover by the tests. I'm not
saying to test the dshash internal logic which I agree that it's not the
job of this patch. Sorry for being confusing.
+ /* Need to add this listener */
+ if (entry->num_listeners >= entry->allocated_listeners)
+ {
+ /* Grow the array (double the size) */
+ int new_size = entry->allocated_listeners * 2;
+ dsa_pointer new_array = dsa_allocate(channel_dsa,
+ sizeof(ProcNumber) * new_size);
+ ProcNumber *new_listeners = (ProcNumber *) dsa_get_address(channel_dsa,
+ new_array);
+
+ /* Copy existing listeners */
+ memcpy(new_listeners, listeners,
+ sizeof(ProcNumber) * entry->num_listeners);
+
+ /* Free old array and update entry */
+ dsa_free(channel_dsa, entry->listeners_array);
+ entry->listeners_array = new_array;
+ entry->allocated_listeners = new_size;
+ listeners = new_listeners;
+ }
--
Matheus Alcantara
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-10-07 21:17:36 | Re: Optimize LISTEN/NOTIFY |
Previous Message | Melanie Plageman | 2025-10-07 21:10:02 | Re: Fix overflow of nbatch |