Creating a page with "Save & View" is slow. Save is fast

Hello,

I have a strange issue with the performance of my xwiki instance.
First of all, I have about 12000 pages I created through the API.
Creating new pages through API or in the wiki with the save & view button seems to take a really long time (over 1 minute to complete). The page is already created, but the time it takes to render it is really long.
If I create the new page by clicking on “Save” or use “Save & View” and browse the page with the URL I manually enter, then I can see the page is already created.

I tried to log slow queries on the postgres instance, and the slowest queries takes a few milliseconds (all under 50).

The VM for xwiki has 4 x E5-2630 v3 @ 2.40GHz + 8GB of Ram.
the xwiki is set to use up to 3GB of ram. The shared buffer of postgres was set to 2GB. About 3GB of ram is free according to free -m.

I find it a bit weird that it is only when using “Save & view”, it takes a really long time to give me a page, while I can actually get a page out if I input the URL manually. I think the API also act like a “Save & View” so it takes ages to create all my pages ( I am importing content from another old trac wiki).

Any Idea on why I experience this weird behaviour?

Saving a page should take a few milliseconds.

Now when you save & view, it’s saving + rendering in view.

So it seems your issue is with the page rendering.

The time it takes to render a page depends on its content. You could try to debug this with the debug mode, see https://dev.xwiki.org/xwiki/bin/view/Community/Debugging#HDebugmode

That’s a lot, probably even too much :slight_smile: See https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HMemory

Hello,

Thanks for replying, I am not too sure how to get a debug when clicking on the “save & view” button. This is a post button and it does not carry on ?debug=true if set in the url.
I tried to enable debug of the DB calls by adding the suggested lines in the logback.xml file, but it did not output anything in catalina.out, so I logged request slower than 3 ms in postgres, which gave me some result, but nothing over a few milliseconds.
logging HTTP calls also did not produce logs into catalina.out.

I don’t think the viewer is to blame . I can actually do “click & save” then input the address manually on another tab, and it will generate the new page, while the one I did the “click & save” button needs 1.5 minute to finish.

I set the ram to 3GB as there was no indication what a large deployment was, and as I saw I had 12000 pages I did not know if it was beyond a large deployment or not. What I can say is even after restarting the tomcat server, it needs at least 1.5 minute for the “save & view” to fully complete the job.

I noticed the performance got worse when I created each pages in their own space. The first time I created the pages, it was still slow, but faster and I had everything under the space “Main”.

This is to do in view mode :slight_smile:

If the problem is the save then it could mean you have some custom Event Listeners doing a bad job. Do you know if you have installed some extensions or developed some custom Event Listener code?

Regarding perf, you need to read this page which contains everything to know on performances:

BTW 12K pages is not really large. When you reach several millions it’ll start to be large! :slight_smile:

Just make sure you adjust the doc cache as explained in that doc, depending on how may docs are frequently accessed. Thus you need enough memory to be able to contain all the cached docs. That will be the main way to size the memory you need.

But that’s not going to solve your problem.

I don’t have any more ideas except for Event Listeners.

The view mode is fine.
I am sorry if my description was hard to understand. I will try again:

I create a new page.
Put a title > Create.
put “test” as content.

Case1 :
If I click “Save”. -> The process is very fast.
I Input the link of the new page manually. Page is displayed fast.

Case2 :
If I click “Save & View”. -> There will be a loading icon in the browser for about 1.5 minute.
BUT. While if I input the link of the new page manually. The page is displayed fast too.
After 1.5 Minute, the page where I clicked “save & view” Loads.

In fact, :
-the page creation seems to be instant.
-The view (if URL inputed manually) is also instant. (right after I click on “save” or “save & view”, the page would be displayed right after if I put the URL manually in the browser).
-The API create page and “Save & View” take a long time to complete fully (although I can confirm the page is created, but we need 1.5 minute before anything is displayed after pressing that button).
-The wiki never take a long time to display a page unless I do “Save & View”, so regular view mode is not giving me the problem, and creating is not the problem either.

My guess is the “save & view” action is not just “Save” then redirect to “View” mode, it may be doing something else. Same with the API call?

What template are you choosing when creating the new page? Is it “Blank Page”? Check the Network tab from the browser’s developer tools to see what requests are made when you click on Save & View and if those requests take long.

I am creating the page from a blank page template.
I use xwiki 10.6.1 ( installed from debian packages, xwiki-tomcat8-postgres)
When I click on save and view, the request hanging says:
Waiting TTFB : 1.3 min

General:
Request URL: http://xwiki-prod:8080/xwiki/bin/preview/Main/KnowledgeBase/testxwikispd222sss/WebHome
Request Method: POST
Status Code: 302
Remote Address: 192.168.28.61:8080
Referrer Policy: no-referrer-when-downgrade

Response header :
Content-Language: en
Content-Length: 0
Content-Script-Type: text/javascript
Content-Type: text/html;charset=ISO-8859-1
Date: Thu, 30 Aug 2018 23:52:44 GMT
Location: /xwiki/bin/view/Main/KnowledgeBase/testxwikispd222sss/

Request Headers:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,fr;q=0.7
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 339
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=FA73D5FFE12FABDC9201D7CA2D744ADE; username=“yJf+qypSOl7lgVMAR+6yOA__”; password=“4SeJsn+Wb7svszxd5lol/A__”; rememberme=“false”; validation=“189fbc0955b7c8185ad5e47d78772ce7”; visitid=ZMEOX5UPS4NYHAJKBOTCQLU9JFD7QT9E
DNT: 1
Host: xwiki-prod:8080
Origin: http://xwiki-prod:8080
Pragma: no-cache
Referer: http://xwiki-prod:8080/xwiki/bin/edit/Main/KnowledgeBase/testxwikispd222sss/WebHome?template=&parent=Main.KnowledgeBase.WebHome&title=testxwikispd222sss
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Form data :
form_token: ggo8RwCk2pdcp5exhWvxOA
x-maximized:
parent: Main.KnowledgeBase.WebHome
title: testxwikispd222sss
template:
xcontinue: /xwiki/bin/edit/Main/KnowledgeBase/testxwikispd222sss/WebHome?editor=wiki
xredirect:
language: en
content: testing
action_save: Save & View
xeditaction: edit
comment:
syntaxId: xwiki/2.1
xhidden: 0

I have the following extensions installed:
XWiki Platform - Livetable - UI
bootstrap-3-typeahead
Tree Macro
Recently Modified Pages Application
CKEditor WebJar
Extension Manager Application
Search Application
CKEditor Integration
Activity Stream Application
Administration Application
User Profile Application
OpenSPML Toolkit
XWiki Platform - UI Extension - UI
Attachment Application
XWiki Platform - Sheet - UI
Solr Search Application
Document Tree Macro
XWiki Platform - Panels - UI
LDAP Class Libraries for Java (JLDAP)
Index Application
XClass Application 10.6.1
Icon Theme Application 10.6.1
Message Stream Application 10.6.1
CKEditor Plugins for XWiki 1.23
Menu Application 10.6.1
LDAP Authenticator 9.2.5
Font Awesome Icon Theme 10.6.1
App Within Minutes Application 10.6.1

I can’t find OpenSPML Toolkit on http://extensions.xwiki.org/ so I assume it’s an extension you built yourself. Does it have any save event listeners that could slow down the save?

Hello,

I have installed a new xwiki instance with zero extension and it looks like the wiki imported all pages super fast.
This may suggest one extension is causing the problem.

The OpenSPML is a dependency installed when I install the LDAP authenticator.
This is the list of extension I have after installing the LDAP authenticator extension:

OpenSPML Toolkit 0.5
Installed as dependency
An open source client code that supports the Service Provisioning Markup Language (SPML) developed by the OASIS Provisioning Services Technical Committee (PSTC).
Administration Application 10.7
Installed but not valid
by: XWiki Development Team

Application for administrating wiki features like users, groups, rights etc.
LDAP Class Libraries for Java (JLDAP) 4.3
Installed as dependency
The LDAP Class Libraries for Java (JLDAP) enable you to write applications to access, manage, update, and search for information stored in directories accessible using LDAPv3.
LDAP Authenticator 9.2.5
Installed
by: Denis Gervalle, Thomas Mortagne, XWiki Development Team

Authenticate using a LDAP server
Extension Manager Application 10.6.1
Installed
by: XWiki Development Team

Install/update/remove Extensions in/from the wiki

I will update this once I do a bit more test.

Unrelated to my issue, but I think the extension pages are broken . It is not possible to search for extensions and when we find extension page from google it does not work example:
https://extensions.xwiki.org/xwiki/bin/view/Extension/Tree%20Macro

I am trying to reinstall all the extensions and see if the xwiki does get slow when creating page with the API.

Yes we had some issues with xwiki.org, see There is some bug in "www.xwiki.org"

Hello,

I tried to uninstall all extensions from my older xwiki and it did not help. I was also not able to get another instance of xwiki 10.6.1 running so I just ditched everything and went for a clean 10.7 install.

After importing everything, I installed more or less the same extensions and so far, it is still fast.

Could not pinpoint the exact reason why I had poor performance on xwiki previously, but my current setup is working well.

Thanks for taking the time to help me on this.

ok too bad, the mystery remains :wink:

But good that you could progress on your side!