Re: Add parameter jit_warn_above_fraction - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: Add parameter jit_warn_above_fraction
Date
Msg-id 20220225162304.GD9008@telsasoft.com
Whole thread Raw
In response to Add parameter jit_warn_above_fraction  (Magnus Hagander <magnus@hagander.net>)
Responses Re: Add parameter jit_warn_above_fraction  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
On Fri, Feb 25, 2022 at 04:16:01PM +0100, Magnus Hagander wrote:
> +    {
> +        {"jit_warn_above_fraction", PGC_SUSET, LOGGING_WHEN,
> +            gettext_noop("Sets the fraction of query time spent on JIT before writing"
> +                         "a warning to the log."),
> +            gettext_noop("Write a message tot he server log if more than this"
> +                         "fraction of the query runtime is spent on JIT."
> +                         "Zero turns off the warning.")
> +        },
> +        &jit_warn_above_fraction,
> +        0.0, 0.0, 1.0,
> +        NULL, NULL, NULL
> +    },

Should be PGC_USERSET ?

+                       gettext_noop("Write a message tot he server log if more than this"
                                                                                                          
 

to the

+       if (jit_enabled && jit_warn_above_fraction > 0)
                                                                                                          
 
+       {
                                                                                                          
 
+               int64 jit_time =
                                                                                                          
 
+                       INSTR_TIME_GET_MILLISEC(portal->queryDesc->estate->es_jit->instr.generation_counter) +
                                                                                                          
 
+                       INSTR_TIME_GET_MILLISEC(portal->queryDesc->estate->es_jit->instr.inlining_counter) +
                                                                                                          
 
+                       INSTR_TIME_GET_MILLISEC(portal->queryDesc->estate->es_jit->instr.optimization_counter) +
                                                                                                          
 
+                       INSTR_TIME_GET_MILLISEC(portal->queryDesc->estate->es_jit->instr.emission_counter);
                                                                                                          
 
+
                                                                                                          
 
+               if (jit_time > msecs * jit_warn_above_fraction)
                                                                                                          
 
+               {
                                                                                                          
 
+                       ereport(WARNING,
                                                                                                          
 
+                                       (errmsg("JIT time was %ld ms of %d ms",
                                                                                                          
 
+                                                       jit_time, msecs)));
                                                                                                          
 
+               }
                                                                                                          
 
+       }
                                                                                                          
 


I think it should be a NOTICE (or less?)

Is it more useful if this is applied combined with log_min_duration_statement ?

It's easy to imagine a query for which the planner computes a high cost, but
actually runs quickly.  You might get a bunch of WARNINGs that the query took
10 MS and JIT was 75% of that, even if you don't care about queries that take
less than 10 SEC.

I should say that this is already available by processing the output of
autoexplain.

-- 
Justin



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Add parameter jit_warn_above_fraction
Next
From: Andres Freund
Date:
Subject: Re: Readd use of TAP subtests