Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8199443

Nashorn multithread bottleneck with "use strict"

XMLWordPrintable

    • b05
    • x86_64
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_152"
      Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      MacOs Sierra 10.12.6

      A DESCRIPTION OF THE PROBLEM :
      server setting: there are multiple Nashorn script engine, and each has a bindings pool

      we notice that there's a lot of time spent on `ScriptFunction#initUserAccessors`, which adds a property to `ScriptFunction`'s static `map$` and `PropertyMap#addProperty` is synchronized.

      this causes by `ScriptFunction#isStrict` check returning true, then leads to any parallel script parsing with "use script" block on waiting for addProperty to be finished even though it's adding the same properties over and over again (the map itself wouldn't change after first call)

      this could cause a very serious lock when trying to parse code across engine / bindings

      more thoughts:
      `ScriptFunction#initUserAccessors` has a do-while logic that will try to add regardless of it being the same or not, if this is changed to a while-do then we wont be trying to add property when not necessary and there won't be a block




      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      remove "use strict"

            hannesw Hannes Wallnoefer
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: