Re: Making JIT more granular - Mailing list pgsql-hackers

From Andy Fan
Subject Re: Making JIT more granular
Date
Msg-id CAKU4AWquQf1rYymcxCLB+npV1QinZJNm5Zdh5vmcArGh3DZxqA@mail.gmail.com
Whole thread Raw
In response to Re: Making JIT more granular  (Andy Fan <zhihui.fan1213@gmail.com>)
List pgsql-hackers

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.

There are two observers after thinking more about this.  a).  due to the 
rescan cost reason,  plan->total_cost * plan->est_loops might be greater
than the whole plan's total_cost.  This may cause users to be confused why 
this change can make the plan not JITed in the past,  but JITed now. 

explain analyze select * from t1, t2 where t1.a  = t2.a;                                                  QUERY PLAN                                                  ------------------------------------------------------------------------------------------------------------  Nested Loop  (cost=0.00..154.25 rows=100 width=16) (actual time=0.036..2.618 rows=100 loops=1)    Join Filter: (t1.a = t2.a)    Rows Removed by Join Filter: 9900    ->  Seq Scan on t1  (cost=0.00..2.00 rows=100 width=8) (actual time=0.015..0.031 rows=100 loops=1)    ->  Materialize  (cost=0.00..2.50 rows=100 width=8) (actual time=0.000..0.010 rows=100 loops=100)          ->  Seq Scan on t2  (cost=0.00..2.00 rows=100 width=8) (actual time=0.007..0.023 rows=100 loops=1)  Planning Time: 0.299 ms  Execution Time: 2.694 ms (8 rows)

The overall plan's total_cost is 154.25, but the Materialize's JIT cost is 2.5 * 100 = 250.

b). Since the total_cost for a plan counts all the costs for its children, so if one
child plan is JITed, I think all its parents would JITed. Is this by design?

         QUERY PLAN
----------------------------
 Sort
   Sort Key: (count(*))
   ->  HashAggregate
         Group Key: a
         ->  Seq Scan on t1

(If Seq Scan is JITed, both HashAggregate & Sort will be JITed.)

--
Best Regards
Andy Fan

pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: gitmaster access
Next
From: "osumi.takamichi@fujitsu.com"
Date:
Subject: RE: First draft of the PG 15 release notes