Re: Making JIT more granular

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: Making JIT more granular
Date: 2022-05-14 00:35:53
Message-ID: CAKU4AWqqSAi+-1ZaFawY300WknH79J9dhx=pU5+byAbShjUjCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi David:

> Does anyone have any thoughts about this JIT costing? Is this an
> improvement? Is there a better way?
>
>
I think this is an improvement. However I'm not sure how much improvement
& effort we want pay for it. I just shared my thoughts to start this
discussion.

1. Ideally there is no GUC needed at all. For given a operation, like
Expression execution, tuple deform, if we can know the extra cost
of JIT in compile and the saved cost of JIT in execution, we
can choose JIT automatically. But as for now, it is hard to
say both. and we don't have a GUC to for DBA like jit_compile_cost
/ jit_compile_tuple_deform_cost as well. Looks we have some
long way to go for this and cost is always a headache.

2. You calculate the cost to compare with jit_above_cost as:

plan->total_cost * plan->est_loops.

An alternative way might be to consider the rescan cost like
cost_rescan. This should be closer for a final execution cost.
However since it is hard to set a reasonable jit_above_cost,
so I am feeling the current way is OK as well.

3. At implementation level, I think it would be terrible to add
another parameter like est_loops to every create_xxx_plan
in future, An alternative way may be:

typedef struct
{
int est_calls;
} ExtPlanInfo;

void
copyExtPlanInfo(Plan *targetPlan, ExtPlanInfo ext)
{
targetPlan->est_calls = ext.est_calls;
}

create_xxx_plan(..., ExtPlanInfo extinfo)
{
copyExtPlanInfo(plan, extinfo);
}

By this way, it would be easier to add another parameter
like est_calls easily. Not sure if this is over-engineered.

I have gone through the patches for a while, General it looks
good to me. If we have finalized the design, I can do a final
double check.

At last, I think the patched way should be better than
the current way.

--
Best Regards
Andy Fan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2022-05-14 01:37:54 Re: JSON Functions and Operators Docs for v15
Previous Message Thomas Munro 2022-05-14 00:07:05 Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes Reply-To: