Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13421#discussion_r65273569
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala
 ---
    @@ -720,15 +721,23 @@ class CodegenContext {
       /**
        * Register a comment and return the corresponding place holder
        */
    -  def registerComment(text: String): String = {
    -    val name = freshName("c")
    -    val comment = if (text.contains("\n") || text.contains("\r")) {
    -      text.split("(\r\n)|\r|\n").mkString("/**\n * ", "\n * ", "\n */")
    +  def registerComment(text: => String): String = {
    +    // By default, disable comments in generated code because computing 
the comments themselves can
    +    // be extremely expensive in certain cases, such as deeply-nested 
expressions which operate over
    +    // inputs with wide schemas. For more details on the performance 
issues that motivated this
    +    // flat, see SPARK-15680.
    +    if (SparkEnv.get != null && 
SparkEnv.get.conf.getBoolean("spark.sql.codegen.comments", false)) {
    --- End diff --
    
    The problem with using a runtime `SQLConf` (actually a `CatalystConf` (to 
avoid a circular dependency)) is that we'd need to thread that configuration 
into the implementations of the `CodeGenerator.generate` method and that method 
has 60+ call sites, many of which do not have a readily-accessible 
configuration instance.
    
    If we had some thread-local mechanism for implicitly obtaining these 
configurations then this would be easy, but for now I don't see a simple way to 
thread this configuration without changing 20+ files.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to