Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-96891

Performance issues when saving a web content with hundreds of nested fields

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 7.0.X
    • Fix Version/s: None
    • Component/s: Dynamic Data Mapping
    • Labels:
    • Fix Priority:
      3

      Description

      Reproduction steps

      1. Add the property below in portal-ext.properties:
        com.liferay.portal.upload.LiferayFileItem.threshold.size=524288
        
      2. Start the server and login as Admin
      3. Go to Liferay DXP > Content > Web Content > top-right ellipsis icon > Structures > Add a new structure
      4. The structure should have a repeatable text field and 5 nested text fields.
        1. you can just add the following JSON code in the source tab
          {
              "availableLanguageIds": [
                  "en_US"
              ],
              "defaultLanguageId": "en_US",
              "fields": [
                  {
                      "label": {
                          "en_US": "Text"
                      },
                      "predefinedValue": {
                          "en_US": ""
                      },
                      "style": {
                          "en_US": ""
                      },
                      "tip": {
                          "en_US": ""
                      },
                      "dataType": "string",
                      "indexType": "keyword",
                      "localizable": true,
                      "name": "Texti9ex",
                      "readOnly": false,
                      "repeatable": true,
                      "required": false,
                      "showLabel": true,
                      "type": "text",
                      "nestedFields": [
                          {
                              "label": {
                                  "en_US": "Text"
                              },
                              "predefinedValue": {
                                  "en_US": ""
                              },
                              "style": {
                                  "en_US": ""
                              },
                              "tip": {
                                  "en_US": ""
                              },
                              "dataType": "string",
                              "indexType": "keyword",
                              "localizable": true,
                              "name": "Text9yqf",
                              "readOnly": false,
                              "repeatable": false,
                              "required": false,
                              "showLabel": true,
                              "type": "text"
                          },
                          {
                              "label": {
                                  "en_US": "Text"
                              },
                              "predefinedValue": {
                                  "en_US": ""
                              },
                              "style": {
                                  "en_US": ""
                              },
                              "tip": {
                                  "en_US": ""
                              },
                              "dataType": "string",
                              "indexType": "keyword",
                              "localizable": true,
                              "name": "Textdu6l",
                              "readOnly": false,
                              "repeatable": false,
                              "required": false,
                              "showLabel": true,
                              "type": "text"
                          },
                          {
                              "label": {
                                  "en_US": "Text"
                              },
                              "predefinedValue": {
                                  "en_US": ""
                              },
                              "style": {
                                  "en_US": ""
                              },
                              "tip": {
                                  "en_US": ""
                              },
                              "dataType": "string",
                              "indexType": "keyword",
                              "localizable": true,
                              "name": "Textg5mz",
                              "readOnly": false,
                              "repeatable": false,
                              "required": false,
                              "showLabel": true,
                              "type": "text"
                          },
                          {
                              "label": {
                                  "en_US": "Text"
                              },
                              "predefinedValue": {
                                  "en_US": ""
                              },
                              "style": {
                                  "en_US": ""
                              },
                              "tip": {
                                  "en_US": ""
                              },
                              "dataType": "string",
                              "indexType": "keyword",
                              "localizable": true,
                              "name": "Textadt6",
                              "readOnly": false,
                              "repeatable": false,
                              "required": false,
                              "showLabel": true,
                              "type": "text"
                          },
                          {
                              "label": {
                                  "en_US": "Text"
                              },
                              "predefinedValue": {
                                  "en_US": ""
                              },
                              "style": {
                                  "en_US": ""
                              },
                              "tip": {
                                  "en_US": ""
                              },
                              "dataType": "string",
                              "indexType": "keyword",
                              "localizable": true,
                              "name": "Text9uwz",
                              "readOnly": false,
                              "repeatable": false,
                              "required": false,
                              "showLabel": true,
                              "type": "text"
                          }
                      ]
                  }
              ]
          }
          
      5. Once added, add a dummy (empty) template to such structure
      6. Create a new Web Content from such structure
      7. Replicate the same field 460 times with this JS loop that can be executed from the browser's console
        for (var x = 0 ; x < 461; x++) {
         document.querySelector('.lfr-ddm-repeatable-add-button').click();
        }
        
        1. This will take about 10 seconds. if you set the Chrome's logging level to Verbose, there is a warning message that will be repeated each time the field is repeated, this is convenient as it will show you the progress of the 460 additions
      8. Save

      Actual result

      At this point, saving will take about 1.5 minutes with so empty fields but 5 minutes with the customer's structure, which is more complex. CPU usage will increase as well as the portal's memory usage. The process will eventually complete successfully.

      Expected result

      Web content not spending so much time and resources upon being saved

      Reproduced on 7.0.x @ cb85cbd7c9297372e5c7ad605f5487d93bc6af3e
      Not reproducible on 7.1.x @ 3bacfac64d004d67d833cdcab7f168b60031ca78

      Saving/Editing web content only takes about 5 seconds.

      The attached thread dumps are taken 10-15 seconds apart from each other, they all show the longest stack to be:

      "http-nio-8080-exec-7" #163 daemon prio=5 os_prio=0 tid=0x00007f0cfc0bb800 nid=0x4da3 runnable [0x00007f0ccf5e4000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap.putVal(HashMap.java:664)
      	at java.util.HashMap.putMapEntries(HashMap.java:515)
      	at java.util.LinkedHashMap.<init>(LinkedHashMap.java:384)
      	at com.liferay.dynamic.data.mapping.model.DDMFormField.<init>(DDMFormField.java:40)
      	at com.liferay.dynamic.data.mapping.model.DDMFormField.<init>(DDMFormField.java:68)
      	at com.liferay.dynamic.data.mapping.model.DDMForm.<init>(DDMForm.java:43)
      	at com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.getDDMForm(DDMStructureImpl.java:112)
      	at com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.createFullHierarchyDDMForm(DDMStructureImpl.java:62)
      	at com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.getFullHierarchyDDMForm(DDMStructureImpl.java:251)
      	at com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.getFullHierarchyDDMFormFieldsMap(DDMStructureImpl.java:266)
      	at com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.hasField(DDMStructureImpl.java:383)
      	at com.liferay.journal.util.impl.JournalConverterImpl.getDDMFieldsDisplayValues(JournalConverterImpl.java:451)
      	at com.liferay.journal.util.impl.JournalConverterImpl.countFieldRepetition(JournalConverterImpl.java:374)
      	at com.liferay.journal.util.impl.JournalConverterImpl.updateContentDynamicElement(JournalConverterImpl.java:777)
      	at com.liferay.journal.util.impl.JournalConverterImpl.getContent(JournalConverterImpl.java:157)
      	at com.liferay.journal.web.internal.portlet.JournalPortlet.updateArticle(JournalPortlet.java:633)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      ...
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cleydyr.albuquerque Cleydyr Albuquerque
                Reporter:
                cleydyr.albuquerque Cleydyr Albuquerque
                Participants of an Issue:
                Recent user:
                Cleydyr Albuquerque
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  31 weeks, 5 days ago

                  Packages

                  Version Package