Saving a moderately big page performance problem
Describe the Bug
Creating a moderately big page can hog up all of the server's CPU resources.
The document saving process itself hangs somewhere in /BookStack/app/Util/HtmlDocument.php
As the page is hung up saving, there are background PUT requests that make it worse because they hang as well.
The issue might be mitigated by not allowing more than one draft saving request on page at a time. Stopping draft saving requests after clicking "Save page" might help as well.
Steps to Reproduce
- Create a new page
- Go to source code editor
- Copy the attached file contents there. It's ~4Mb worth of HTML with lots of tables which is a database structure scheme1 - Copy.zip
- Try to save the page
Expected Behaviour
The page is saved after a while
Screenshots or Additional Context
Instead I get PHP Fatal error: Maximum execution time of 1200 seconds exceeded in {path}\BookStack\app\Util\HtmlDocument.php on line 62 for the main saving process and the background draft saving processes. The CPU gets loaded up to 100%.
Browser Details
Firefox 127 on Windows 11
Exact BookStack Version
v24.05.1
4MB is really quite large. There's over 68k table cells in that document. At some point content will come across limits, and that may very depending on specific content and system resources. We can look into where bottlenecks may be for this kind of content, and look to improve that where possible/reasonable, but ultimately this is a large amount of content that may be better suited to be split up.
I understand. But please mind that if one saving process is busy, it's better not to launch new ones. What I saw was one working POST and multiple PUT requests in Network tab.