Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNdN9-0001Mw-RA for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Feb 2022 16:23:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNdN8-0005x3-Mb for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Feb 2022 16:23:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nNdN8-0005wu-9R for pgsql-hackers@lists.postgresql.org; Fri, 25 Feb 2022 16:23:10 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nNdN5-0004IB-88 for pgsql-hackers@lists.postgresql.org; Fri, 25 Feb 2022 16:23:09 +0000 Received: by mail-io1-xd2f.google.com with SMTP id t11so7053477ioi.7 for ; Fri, 25 Feb 2022 08:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LGb/95yU/bPLcwLHGb9jp1pjlhTdaKaMYoUNDk6c4mc=; b=ft3QpQiZUTsZncCm039z55TDrYuwA8M/BEwXxQA+v4jpVg4IHwh4Iq3E/TNwhN3Fg2 oC07EhqSf3MQSNHxU6G2YySjx8FNnDv2+9Jn7NtvzemkJ9Ix2EDUUPYHME6a2NWpCpq7 jv0Y6XGbJDVALiHlSsgErmjXwtAmzM8FCvcqLgwQD5IhR6ssnHqOtrq2Wxh3JH4F36sA f5f/QsnxHnMsGJm4nhTSaffZKrzY0BitQWv9t8Ej/dwPqxirldg/X/cjNif6DbUywGBH q+Ur0Zlw5Yd8CsXGmMvWnd0tcJEzrQ8NYRqavnJiN7xAq4cQcuePmivGdIZWehPhkFZ2 xu+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LGb/95yU/bPLcwLHGb9jp1pjlhTdaKaMYoUNDk6c4mc=; b=fdzr+7M5USO3cT+ubkCIy4ami8ha1OASjY14o6ZS6QjQARSlXW94IeyXUvm6ta7JZj NkfTs0SkMP5BWGu394O8Ldu8DiHFoVi8I+d90xFoFAIaw12q3KR8EAj8amO6W78V7XsC o4UR3dlcpOrm9mhdS/+MDnrngfZKlwhc3oJYOOMjciV5Hb24OkhFELZqa36ffTIcutgU MrnKN0YfuOK9xn6zXw16fwAkwH7IPvkTckj40jWgUfqD20LGx3SwxTM+DP1DF1mTEK9b 5+HlGuuEYX75A4zBve7WR/o7wH9cAy77LahtEhAEjf+AI2hAyPgp35GRYt64dOjdw8C1 93Aw== X-Gm-Message-State: AOAM532wMOjTNr2Y9NtqPp1xTcEQknH8KrFHi11/zN8IEHh8ubJ1fPxW Tbp+lf9OZYpN3+YwKWkW/fE7sw== X-Google-Smtp-Source: ABdhPJyA3BoDlSB/Z2p4UYvWIVwDuppm6Y3JMndevtODHPVl+WjhWljpDuFe+dNIBrDwCXpHzuv/6Q== X-Received: by 2002:a5e:dc41:0:b0:640:9372:fe18 with SMTP id s1-20020a5edc41000000b006409372fe18mr5821179iop.133.1645806186163; Fri, 25 Feb 2022 08:23:06 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r185-20020a6b2bc2000000b006449e0bf491sm92471ior.38.2022.02.25.08.23.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Feb 2022 08:23:05 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 81B70800BC8; Fri, 25 Feb 2022 10:23:04 -0600 (CST) Date: Fri, 25 Feb 2022 10:23:04 -0600 From: Justin Pryzby To: Magnus Hagander Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Add parameter jit_warn_above_fraction Message-ID: <20220225162304.GD9008@telsasoft.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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