Groovy
  1. Groovy
  2. GROOVY-5241

GroovyScriptEngineImpl could use ConcurrentHashMaps

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.5, 2.0-beta-2
    • Fix Version/s: 1.8.6, 2.0-beta-3
    • Component/s: None

      Description

      The Groovy implementation of JSR-223 (Scripting for the Java Platform), GroovyScriptEngineImpl, uses Collections.synchronizedMap(new HashMap()) for the caches of compiled scripts and closures. Since JSR-223 was first supported in Java 6, it's safe to instead use ConcurrentHashMap for those data structures. According to JCIP (Java Concurrency in Practice), ConcurrentHashMap performs substantially better than Hashtable or Collections.synchronizedMap(). In addition, once ConcurrentHashMaps are used, the code could take advantage of additional methods provided in the ConcurrentMap interface, such as putIfAbsent().

        Activity

        Matt Passell created issue -
        Hide
        Matt Passell added a comment -

        This file patches GroovyScriptEngineImpl to use ConcurrentHashMaps.

        Show
        Matt Passell added a comment - This file patches GroovyScriptEngineImpl to use ConcurrentHashMaps.
        Matt Passell made changes -
        Field Original Value New Value
        Attachment GROOVY-5241.patch [ 58418 ]
        Cédric Champeau made changes -
        Fix Version/s 1.8.6 [ 18245 ]
        Resolution Fixed [ 1 ]
        Assignee Cedric Champeau [ melix ]
        Fix Version/s 2.0-beta-3 [ 18244 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Hide
        James P. White added a comment -

        Please do not make this change until Groovy no longer supports JDK 1.5. JSR-223 is fully supported for JDK 1.5 which is why we use the LiveTribe JSR-223 implementation for building (and which users can deploy if their runtime is JDK 1.5 rather than JDK 1.6+).

        Show
        James P. White added a comment - Please do not make this change until Groovy no longer supports JDK 1.5. JSR-223 is fully supported for JDK 1.5 which is why we use the LiveTribe JSR-223 implementation for building (and which users can deploy if their runtime is JDK 1.5 rather than JDK 1.6+).
        Hide
        James P. White added a comment -

        This should not be done until Groovy no longer supports JDK 1.5.

        Show
        James P. White added a comment - This should not be done until Groovy no longer supports JDK 1.5.
        James P. White made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Hide
        Matt Passell added a comment -

        ConcurrentHashMap was introduced in Java 5 (aka JDK 1.5), so there's no issue - see http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html

        Show
        Matt Passell added a comment - ConcurrentHashMap was introduced in Java 5 (aka JDK 1.5), so there's no issue - see http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ConcurrentHashMap.html
        Hide
        James P. White added a comment -

        That's fine if that's the case. I was reacting to the justification you gave which was that JDK 1.6 would be in use if JSR-223 were.

        Show
        James P. White added a comment - That's fine if that's the case. I was reacting to the justification you gave which was that JDK 1.6 would be in use if JSR-223 were.
        Hide
        Cédric Champeau added a comment -

        Yes, ConcurrentHashMap is there since 1.5, there's no problem here.

        Show
        Cédric Champeau added a comment - Yes, ConcurrentHashMap is there since 1.5, there's no problem here.
        Cédric Champeau made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Resolved [ 5 ]
        Hide
        Matt Passell added a comment - - edited

        Sorry for the confusion, Jim. I had no idea that JSR-223 had been backported. When I wrote up the description, I should have just said something like, "since Groovy 1.8+ runs in a JDK 1.5+ environment, it's safe to use ConcurrentHashMap..."

        Show
        Matt Passell added a comment - - edited Sorry for the confusion, Jim. I had no idea that JSR-223 had been backported. When I wrote up the description, I should have just said something like, "since Groovy 1.8+ runs in a JDK 1.5+ environment, it's safe to use ConcurrentHashMap..."
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12734164 ] Default workflow, editable Closed status [ 12745966 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12971683 ] Default workflow, editable Closed status [ 12979490 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        26d 8h 46m 1 Cédric Champeau 02/Feb/12 01:18
        Resolved Resolved Reopened Reopened
        3d 17h 10m 1 James P. White 05/Feb/12 18:29
        Reopened Reopened Resolved Resolved
        8h 14m 1 Cédric Champeau 06/Feb/12 02:43
        Resolved Resolved Closed Closed
        6d 1h 19m 1 Paul King 12/Feb/12 04:03

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Matt Passell
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development