From 2f7272d1ed335302bf3610fcd7c17decea1cf4b9 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Thu, 14 Oct 2021 11:00:26 +0100 Subject: [PATCH] QL: Add a query that finds missing noinline or nomagic annotations. --- ql/src/queries/performance/MissingNoinline.ql | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ql/src/queries/performance/MissingNoinline.ql diff --git a/ql/src/queries/performance/MissingNoinline.ql b/ql/src/queries/performance/MissingNoinline.ql new file mode 100644 index 00000000000..bd20ee9e459 --- /dev/null +++ b/ql/src/queries/performance/MissingNoinline.ql @@ -0,0 +1,23 @@ +/** + * @name Missing `noinline` or `nomagic` annotation + * @description When a predicate is factored out to improve join-ordering, it should be marked as `noinline` or `nomagic`. + * @kind problem + * @problem.severity error + * @id ql/missing-noinline + * @tags performance + * @precision high + */ + +import ql + +from QLDoc doc, Predicate decl +where + doc.getContents().matches(["%join order%", "%join-order%"]) and + decl.getQLDoc() = doc and + not decl.getAnAnnotation() instanceof NoInline and + not decl.getAnAnnotation() instanceof NoMagic and + not decl.getAnAnnotation() instanceof NoOpt and + // If it's marked as inline it's probably because the QLDoc says something like + // "this predicate is inlined because it gives a better join-order". + not decl.getAnAnnotation() instanceof Inline +select decl, "This predicate might be inlined."