Josh Rosen created SPARK-51396:
----------------------------------

             Summary: Avoid exceptions for control flow in 
RuntimeConfig.getOption
                 Key: SPARK-51396
                 URL: https://issues.apache.org/jira/browse/SPARK-51396
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 4.0.0
            Reporter: Josh Rosen
            Assignee: Josh Rosen


RuntimeConfig.getOption is defined as

 
{code:java}
  /** @inheritdoc */
  def getOption(key: String): Option[String] = {
    try Option(get(key)) catch {
      case _: NoSuchElementException => None
    }
  } {code}
which is bad because it uses exceptions for control flow.

 

This can be a performance problem in case `getOption` is called in a hot path.

It's usually not a good idea to perform configuration lookups at a high rate 
(e.g. in a hot loop). But occasionally there's code which _will_ do that and a 
small fix to not use exceptions here can help mitigate the perf. impact of such 
uses.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to