You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/07/27 15:48:44 UTC

[GitHub] [calcite] zabetak opened a new pull request #2469: [CALCITE-4704] Log plan on rule application using explain formatting

zabetak opened a new pull request #2469:
URL: https://github.com/apache/calcite/pull/2469


   1. Add RuleEventLogger for logging events around rule execution.
   2. Centralize logs around rule application and production in RuleEventLogger and unify output for volcanoPlanner and HepPlanner
   3. Use only id and operator name for displaying rule arguments;remove redundant/not helpful information.
   4. Add explain/tree logging on produced expressions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] asolimando commented on a change in pull request #2469: [CALCITE-4704] Log plan on rule application using explain formatting

Posted by GitBox <gi...@apache.org>.
asolimando commented on a change in pull request #2469:
URL: https://github.com/apache/calcite/pull/2469#discussion_r766747416



##########
File path: core/src/main/java/org/apache/calcite/plan/RuleEventLogger.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.util.trace.CalciteTrace;
+
+import org.slf4j.Logger;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+/**
+ * Listener for logging useful debugging information on certain rule events.
+ */
+public class RuleEventLogger implements RelOptListener {
+  private static final Logger LOG = CalciteTrace.getPlannerTracer();
+  private static final Marker FULL = MarkerFactory.getMarker("FULL_PLAN");
+  @Override public void relEquivalenceFound(final RelEquivalenceEvent event) {
+
+  }
+
+  @Override public void ruleAttempted(final RuleAttemptedEvent event) {
+    if (event.isBefore() && LOG.isDebugEnabled()) {
+      RelOptRuleCall call = event.getRuleCall();
+      String ruleArgs = Arrays.stream(call.rels)
+          .map(rel -> "rel#" + rel.getId() + ":" + rel.getRelTypeName())
+          .collect(Collectors.joining(","));
+      LOG.debug("call#{}: Apply rule [{}] to [{}]", call.id, call.getRule(), ruleArgs);
+    }
+  }
+
+  @Override public void ruleProductionSucceeded(RuleProductionEvent event) {
+    if (event.isBefore() && LOG.isDebugEnabled()) {
+      RelOptRuleCall call = event.getRuleCall();
+      RelNode newRel = event.getRel();
+      String description =
+          newRel == null ? "null" : "rel#" + newRel.getId() + ":" + newRel.getRelTypeName();
+      LOG.debug("call#{}: Rule [{}] produced [{}]", call.id, call.getRule(), description);
+      if (newRel != null) {
+        LOG.debug(FULL, "call#{}: Full plan for [{}]:{}", call.id, description,

Review comment:
       This is a great improvement over the previous version, sometimes it's hard to tell what happened without looking at the full plan, but most of the times it's too noisy, +1 for enabling this conditionally.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] zabetak closed pull request #2469: [CALCITE-4704] Log plan on rule application using explain formatting

Posted by GitBox <gi...@apache.org>.
zabetak closed pull request #2469:
URL: https://github.com/apache/calcite/pull/2469


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org