Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed issues in CMS #40

Open
RVXD opened this issue Nov 12, 2020 · 10 comments
Open

Speed issues in CMS #40

RVXD opened this issue Nov 12, 2020 · 10 comments

Comments

@RVXD
Copy link

RVXD commented Nov 12, 2020

We used this module in a lot of our sites and noticed a major decrease in speed of the CMS. Especially if used in combination with more complex pages with many elemental blocks, the CMS can become unusable. Each time a page is opened in the CMS, the frontend is completely rendered (templates and image resizing). This takes up a lot of resources and slows everything down. Removing the module increased CMS speeds from 20 seconds to 2 seconds loading time on heavy pages.
It would be better if the module only calculates the scores on request and not always.

@hubertusanton
Copy link
Owner

hubertusanton commented Nov 12, 2020 via email

@RVXD
Copy link
Author

RVXD commented Nov 12, 2020

Hi Bart,

if you create a page with 10 blocks and another with only one block. You notice the speed difference between the two.
Also making Page.ss empty and reloading the page in the CMS, makes the difference clear.
In my case I have a page with multiple gallery blocks, a form and some basic content. Each block has approx. 6 large images.

Probably the larger the HTML source, the larger the images, the slower it gets.

Of course one could argue, to make the frontend faster, but this is not always easy.

Each time a user loads the page in the CMS the function getPageContent is called to render the entire HTML content and parse the DOM, but most of the time the module results are not needed, because user is only editing basic content:

public function getPageContent()
    {
        $response = Director::test($this->owner->Link());
        if (!$response->isError()) {
            return $response->getBody();
        }
        return '';
}

The server I use has 4 cores and 8GB memory. PHP memory_limit set to 512MB.

Regards,
Remy

@hubertusanton
Copy link
Owner

Hi remy,

What about creating a setting to let a page type not reindex score always but do this reindexing score with a button/action in the cms?

@OldStarchy
Copy link
Contributor

In my testing, I've worked out that loading the edit page in the cms CMS causes the frontend page to render 7 times.

This is likely causing huge slowdowns considering that each call to getPageContent will also run any database queries invoked by the templates. Caching the return value of that function should speed up the score calculation.

I'll make a PR for this, but I'm going to target v2.2.1 first as that's what we're currently using and upgrading isn't an option for us at the moment.

@OldStarchy
Copy link
Contributor

In my tests just now, for a page with 2 blocks, caching the page content took load times from 23s to 5s.

@OldStarchy
Copy link
Contributor

I can't create a PR for 2.2.1 since there's no branch pointing to that version 😢.

Here's the code that I would have put in a PR

	public function getPageContent() {
		static $cache = [];

		if (!isset($cache[$this->owner->ID])) {
			Config::inst()->update('SSViewer', 'theme_enabled', true);
			$rendered_layout = $this->RenderLayout();
			Config::inst()->update('SSViewer', 'theme_enabled', false);

			$cache[$this->owner->ID] = $rendered_layout;
		}

		return $cache[$this->owner->ID];
	}

@hubertusanton
Copy link
Owner

hi @OldStarchy

That's a great load time improvement! Why are you using 2.2.1?
I create tags (versions) from the master branch when i think it is 'releasable' as a version, not sure thats the way to go though. If you'd like I can create a branch for 2.2.1 if this helps? Or you can add this to master and then we create a new release/ tag from this ?

@OldStarchy
Copy link
Contributor

OldStarchy commented Sep 30, 2021

Why are you using 2.2.1?

Unfortunately upgrading to SS4 isn't an option for this project at the moment.

If you could create a 2 branch that would be great, I'll submit a PR for 2.2.2

not sure thats the way to go though

So long as it makes sense, its probably good enough

Or you can add this to master

I'll make 2 PRs, one for the 2 branch and one for master, which should get you a 2.2.2 tag as well as a 4.1.2 .

OldStarchy added a commit to OldStarchy/silverstripe-seo that referenced this issue Sep 30, 2021
@hubertusanton
Copy link
Owner

@OldStarchy Thanks a lot, i created the 2 branch! Hope this helps

@OldStarchy
Copy link
Contributor

During my testing on SS4 I've encountered an issue: silverstripe/silverstripe-framework#10106

OldStarchy added a commit to OldStarchy/silverstripe-seo that referenced this issue Oct 1, 2021
This was referenced Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants