From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
Cc: | 謝東霖 <douenergy(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Improve join_search_one_level readibilty (one line change) |
Date: | 2023-08-04 02:36:15 |
Message-ID: | CAApHDvrDPvj51Te76fOV+Yu6MvYKzFVmx4hZ0wZ0TmDqZ+R3+Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 1 Aug 2023 at 01:48, Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
> Apart from that +1 from me for the patch, I think it helps focusing the
> attention on what actually matters here.
I think it's worth doing something to improve this code. However, I
think we should go a bit further than what the proposed patch does.
In 1cff1b95a, Tom changed the signature of make_rels_by_clause_joins
to pass the List that the given ListCell belongs to. This was done
because lnext(), as of that commit, requires the owning List to be
passed to the function, where previously when Lists were linked lists,
that wasn't required.
The whole lnext() stuff all feels a bit old now that Lists are arrays.
I think we'd be better adjusting the code to pass the List index where
we start from rather than the ListCell to start from. That way we can
use for_each_from() to iterate rather than for_each_cell(). What's
there today feels a bit crufty and there's some element of danger that
the given ListCell does not even belong to the given List.
Doing this seems to shrink down the assembly a bit:
$ wc -l joinrels*
3344 joinrels_tidyup.s
3363 joinrels_unpatched.s
I also see a cmovne in joinrels_tidyup.s, which means that there are
fewer jumps which makes things a little better for the branch
predictor as there's fewer jumps. I doubt this is going to be
performance critical, but it's a nice extra bonus to go along with the
cleanup.
old:
cmpl $2, 24(%rsp)
je .L616
new:
cmpl $2, 16(%rsp)
cmovne %edx, %eax
David
Attachment | Content-Type | Size |
---|---|---|
join_search_one_level_tidyup.patch | application/octet-stream | 2.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2023-08-04 02:56:00 | Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication |
Previous Message | Tom Lane | 2023-08-04 02:23:51 | Re: Fix incorrect start up costs for WindowAgg paths (bug #17862) |