Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-34573

SQLConf sqlConfEntries map has a global lock, should not lock on get

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.7, 3.0.2, 3.1.2, 3.2.0
    • 3.2.0
    • SQL
    • None

    Description

      SQLConf object has a sqlConfEntries map, which has a global lock (since it implements a Collections.synchronizedMap).
      Every operation (like get or set) blocks the full object.
      Concurrent threads may wait on lock.

      An example is the DatatType.sameType method, that queries SQLConf entries map:

      if (SQLConf.get.caseSensitiveAnalysis) 
       ...
      

      If this data type check is run in a custom piece of code on an executor with multiple cores (eg: 40), then a lot of time will be lost waiting on the lock.
      An easy fix is to use the a ConcurrentHashMap that does not lock on read SQLConf.get): " ... retrieval operations do not entail locking ..."

      NOTE: originally discovered by Benson Hon <benson.h@taboola.com> at Taboola while debugging strange slowdowns in production code

      Attachments

        Activity

          People

            gabrielenizzoli Gabriele Nizzoli
            gabrielelnizzoli Gabriele Nizzoli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: