Sling
  1. Sling
  2. SLING-913

Add a cache for pre-compiled scripts

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: Scripting Core 2.0.2
    • Fix Version/s: None
    • Component/s: Scripting
    • Labels:
      None

      Description

      The Java Scripting API provides support for scripting langugages which may precompile script source and reuse the precompiled scripts:

      javax.script.Compilable: May be implemented by a ScriptEngine if precompilation is
      supported
      javax.script.CompiledScript: Result of calling the Compilable.compile method.

      The CompiledScript can be called to repeatedly execute the script without the need for recompilation and thus for improved performance.

      The Sling Core Scripting support should make use of this functionality by maintaining a cache compiled scripts with the following properties

      • indexed by script path
      • size limited (using LinkedHashMap overwriting the removeEldestEntry method)
      • entries are weak or soft references ot cache entries

      A cache entry consists of the following information:

      • The CompiledScript instance
      • The time of last compilation. this is compared to the last modification time of the script to decide on whether to recompile

      We might probaly also try to add a reference to the script engine implementation bundle to only use the cache entry if the bundle has not been stopped since adding the cache entry

      Executing the script would then consist of the following steps:

      1 Check the cache of precompiled scripts. if an entry exists and can be used, use it
      2. if the ScriptEngine is Compilable:
      2a. Compile the script and add it to the cache and use it
      2b. Otherwise have the script engine execute the script

      1. Implement Compilable Sub-task Open Unassigned
       
      2. Implement Compilable Sub-task Open Unassigned
       

        Activity

        Felix Meschberger created issue -
        Felix Meschberger made changes -
        Field Original Value New Value
        Description The Java Scripting API provides support for scripting langugages which may precompile script source and reuse the precompiled scripts:

          javax.script.Compilable: May be implemented by a ScriptEngine if precompilation is
                  supported
          javax.script.CompiledScript: Result of calling the Compilable.compile method.

        The CompiledScript can be called to repeatedly execute the script without the need for recompilation and thus for improved performance.

        The Sling Core Scripting support should make use of this functionality by maintaining a cache compiled scripts with the following properties

          * indexed by script path
          * size limited (using LinkedHashMap overwriting the removeEldestEntry method)
          * entries are weak or soft references ot cache entries

        A cache entry consists of the following information:

          * The CompiledScript instance
          * The time of last compilation. this is compared to the last modification time of the script to decide on whether to recompile

        We might probaly also try to add a reference to the script engine implementation bundle to only use the cache entry if the bundle has not been stopped since adding the cache entry
        The Java Scripting API provides support for scripting langugages which may precompile script source and reuse the precompiled scripts:

          javax.script.Compilable: May be implemented by a ScriptEngine if precompilation is
                  supported
          javax.script.CompiledScript: Result of calling the Compilable.compile method.

        The CompiledScript can be called to repeatedly execute the script without the need for recompilation and thus for improved performance.

        The Sling Core Scripting support should make use of this functionality by maintaining a cache compiled scripts with the following properties

          * indexed by script path
          * size limited (using LinkedHashMap overwriting the removeEldestEntry method)
          * entries are weak or soft references ot cache entries

        A cache entry consists of the following information:

          * The CompiledScript instance
          * The time of last compilation. this is compared to the last modification time of the script to decide on whether to recompile

        We might probaly also try to add a reference to the script engine implementation bundle to only use the cache entry if the bundle has not been stopped since adding the cache entry


        Executing the script would then consist of the following steps:

          1 Check the cache of precompiled scripts. if an entry exists and can be used, use it
          2. if the ScriptEngine is Compilable:
              2a. Compile the script and add it to the cache and use it
              2b. Otherwise have the script engine execute the script
        Felix Meschberger made changes -
        Workflow jira [ 12459998 ] no-reopen-closed,doc-test-required [ 12475957 ]
        Gavin made changes -
        Workflow no-reopen-closed,doc-test-required [ 12475957 ] Copy of no-reopen-closed,doc-test-required [ 12763086 ]
        Gavin made changes -
        Workflow Copy of no-reopen-closed,doc-test-required [ 12763086 ] no-reopen-closed,doc-test-required [ 12766797 ]
        Gavin made changes -
        Workflow no-reopen-closed,doc-test-required [ 12766797 ] re-open possible,doc-test-required [ 12788645 ]
        Gavin made changes -
        Workflow re-open possible,doc-test-required [ 12788645 ] no-reopen-closed,doc-test-required [ 12792611 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Felix Meschberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development