Navigation tree view performance problem

I have a test instance of XWiki and I see a relatively irritating problem with rendering navigation tree. It takes more than 1:30 min to render the navigation tree for imported pages.

These pages were imported through XAR input filter stream but I didn’t use package.xml file to describe the structure. Could it have some impact on this tree rendering macro?

If not what else could cause a problem?

Hi Dominik. What version of XWiki are you using? What DB too?

FYI here are some perf results:
https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HNavigationTree

Thanks for the reply. Here are my specs:

  • XWiki 10.5, almost clean install
  • Postgres 9.5
  • running in Docker container as in XWiki manual on CentOS
  • host unfortunately running on 1 Core at 2.0 GHz with 8GB RAM

I’m working on getting access to more powerful machine, but even with this specs 1.5 minute of rendering time is really high. Pages are nested to 4-5th level sometimes.

I created some test pages by myself and there is no such problem with rendering. The problem occurs only with imported pages.

I don’t understand how this could make a difference. An imported page is just a normal page. @mflorea any idea?

There’s definitely something wrong somewhere. See https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HNavigationTree for perfs you should get.

Thanks, I’m going to go through logs later today.

To make my situation more clear I prepared two gifs comparing the load time.

Firstly, the imported pages (more than 30 sec. load time, it is real time gif):
2018-07-03_13-47-33

And created manually by me (almost instant load time):
2018-07-03_13-47-54

To be clear: you’re referring to the Navigation Panel http://extensions.xwiki.org/xwiki/bin/view/Extension/Panels+Application#HNavigationPanel right? The Navigation Panel queries the pages from the database so it doesn’t really matter where those pages come from (created by hand or imported by XAR). Once the pages end up in the database they are all the same. So whether you’ve used {{package.xml}} or not doesn’t have any impact on the Navigation Panel.

But maybe you’re referring to the tree that lists the pages from the XAR before they are actually imported. That’s a different tree than the one from the Navigation Panel though. A screenshot would help clarify things.

I have problem with the navigation panel used to show tree structure of the pages (the one you linked to). Not related to XAR import.

Thanks, I thought the same. As you can see there is a clear difference in behavior when going through imported pages.

The issue seems to be when the “Administracja” node is expanded. Go to the wiki home page, where the tree should load fast, open the browser developer tools (Right Click > Inspect), look for the Network tab, filter the XHR (AJAX) requests, clear the logged requests and then expand the “Administracja” node. You should see the AJAX request made to fetch the child nodes. How long does this request take? Do you know home many pages you have under “Administracja” (included nested pages)?

Thanks again for the guidance.

It took 40.72 s. There are 774 pages below ‘Administracja’ node.
image

Please find below more details about this request:

Headers:

Request URL: http://xxx.xxx.xxx.x:8080/bin/get/Administracja/WebHome?outputSyntax=plain&sheet=XWiki.DocumentTree&showAttachments=false&showTranslations=false&exclusions=document%3Axwiki%3ASandbox.WebHome&exclusions=document%3Axwiki%3AHelp.WebHome&exclusions=document%3Axwiki%3AXWiki.WebHome&exclusions=document%3Axwiki%3AMenu.WebHome&data=children&id=document%3Axwiki%3AAdministracja.WebHome
Request Method: GET
Status Code: 200 

Response headers:

Cache-Control: no-cache
Content-Language: en
Content-Length: 3322
Content-Location: /bin/view/Administracja/
Content-Script-Type: text/javascript
Content-Type: application/json;charset=UTF-8
Date: Tue, 03 Jul 2018 12:06:07 GMT
Expires: Wed, 31 Dec 1969 23:59:59 GMT
Pragma: no-cache

Timing:
image

I’m trying to see something in logs, but cannot figure out which module should I set up to DEBUG level. Could you please navigate me towards the right one?
image

One of my colleagues just did a test on XWiki 10.5 with Postgres 10:

  • 4k pages under a top level page “Test”
  • 5 nesting levels under the “Test” top level page
  • the mean time over 25 requests to expand the tree is 65ms

This is on his laptop which has SSD storage and i7 CPU.

Based on this I think there is a problem with the pages you imported. Can you try the following script in a separate page:

{{velocity}}
#set ($start = $datetool.date)
$services.tree.nestedPages.getChildren('document:xwiki:Administracja.WebHome', 0, 15)
#set ($end = $datetool.date)
#set ($delta = $end.time - $start.time)
$delta
{{/velocity}}

This will give you the time in ms to fetch the children of the Administracja page without doing any rendering. It should be very fast. On my colleague’s laptop we get 4ms for the “Test” top level page (that has 4k nested child pages).

If it’s fast for you too then it means the problem is not at the database level but at the rendering level. And on the rendering side the problem could be the title of the imported pages. In order to display the pages in the tree we need to render their title. If the title contains scripting (Velocity) then this can slow down the tree.

1 Like

Very useful thanks! I see you’ve updated https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HNavigationTree :slight_smile:

Yes, thanks @ilie.andriuta

Hi, I moved the wiki instance to much faster machine (16GB RAM, SSD, 4 cores CPU) and installed as war package in Tomcat. Postgres is installed side-by-side on the same machine. Unfortunately the problem still persists. I did perform the velocity test and this is a sample result of the @mflorea script :

[document:xwiki:Administracja.1 Spis treści pełny.WebHome, document:xwiki:Administracja.1 Spis treści skrótowy.WebHome, document:xwiki:Administracja.Administracja serwerem MindTouch.WebHome, document:xwiki:Administracja.Archiwum.WebHome, document:xwiki:Administracja.Statystyki.WebHome, document:xwiki:Administracja.TWiki.WebHome]

1

However, the rendering is still extremely slow and the CPU utilization of java process reaches 200% in top tool.

2018-07-20_11-44-54

So it takes 1ms (0.001 of a second) to get the child nodes from the database. This proves that there is no issue with the database queries. The problem must be when rendering / displaying the tree nodes.

Let’s try this: edit the Panels.Navigation page, look for the {{documentTree ... macro call and add the parameter showDocumentTitle="false". Save and check the navigation tree. Is it still slow?

Thanks for the advice. I tried and edited content of the Panels.Navigation as proposed. Later I imported these pages again.

It seems to help a lot! The navigation is almost instant.

Could you please explain what is the difference after using showDocumentTitle="false"?

A wiki page can have a name and a title. Most of the time they are the same, but they can be different. The name appears in the page URL while the title is displayed in the XWiki UI (in the navigation tree, in the breadcrumb, before the page content, etc.). The page name is static while the page title can be dynamic because it supports scripting (Velocity). Moreover, the title displayer can be configured to extract the title from the page content (if the title field is left empty) in which case it needs to parse the page content. See the algorithm here https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-10.5/xwiki-platform-core/xwiki-platform-display/xwiki-platform-display-api/src/main/java/org/xwiki/display/internal/AbstractDocumentTitleDisplayer.java#L155 .

Showing the page name is obviously instant while showing the rendered title can take time. showDocumentTitle="false" tells the navigation tree to show the page name instead of the page title, which is faster but less nice for the end user.

I would check the title of these pages

[document:xwiki:Administracja.1 Spis treści pełny.WebHome, document:xwiki:Administracja.1 Spis treści skrótowy.WebHome, document:xwiki:Administracja.Administracja serwerem MindTouch.WebHome, document:xwiki:Administracja.Archiwum.WebHome, document:xwiki:Administracja.Statystyki.WebHome, document:xwiki:Administracja.TWiki.WebHome]
2 Likes