piranha.core: Slowness after updating to latest version
Hello
I have been experiencing some issues like the slow switching between pages, after updating Piranha.
Previously I was using the synchronous
API on version 5.4 and there was no problem. Now, a single page reload takes 12 seconds and going to another page takes half of this.
Do you have any suggestions on how can this be fixed?
Thank you in advance.
Best regards, Chris
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
And it all depends on how you’re using it. The official PiranhaCMS site runs 6.1 without any of these fixes without any negative impact, but in your case where you have a lot of referenced content from your page which causes a lot of operations there was a huge difference in performance!
The PageField was kept as is for backwards compatibility, but will be replaced in 7.0.
The cache implementation was a safety measure as users were destroying the cache instances by assuming they are new copies (which is a logical assumption).
In 7.0 there will be multiple instances of all cache services, one with clone and one without cloning.
So basically all the stuff you added will be out of the box functionality in 7.0, but is implemented the way it is in 6.0 for compatibility.
Best regards
Hi @aneff-official!
Here is the gist Håkan mentioned. https://gist.github.com/filipjansson/0f9db48874cc5427f65cf0461f0415bc
BR
PageFields
The main page will load from cache without any processing, however your 10 PageFields will each require loading the pages from database and then transforming them from normalized data to the model. This is not good for a page that will get a lot of hits. @filipjansson is working on a Gist with a PageField that uses
PageInfo
instead ofDynamicPage
. Please note thatPageInfo
does not contain regions & blocks, if you want full models your should change the code to usingPageBase
instead.Archive
Sounds good!
MemoryCache
Simply add a new class to your project using the provided code as reference, for example
MyMemoryCache.cs
. Then instead of callingservices.UsePiranhaMemoryCache()
you call:Hi there @aneff-official The main difference between version
6.x
and the versions before it isDynamic models
Pages containing a lot of references to other content using
PageField
and/orPostField
could experience a decrease in performance as the referenced entities will be loaded from database. The basicPageField
andPostField
will be updated in the upcoming release to load aPostInfo
/PageInfo
model which are cached. Until then if this is affecting you, you can register custom fields doing this.Archive pages operating on the standard
ArchivePage
could experience a decrease in performance as all posts will be loaded from database if they are dynamic. This can be fixed by specifying the type of the archive to load, please refer to http://piranhacms.org/docs/basics/how-to-setup-content/archive-page-typesMemory caching
After reported issues on cached data being corrupted (due to threads changing the models returned from the cache) we decided to clone the objects before returning them. This however takes a little bit of time, so if you know what you’re doing your can easily revert to the old behavior by adding your own cache implementation without the cloning. Use the default implementation as reference: https://github.com/PiranhaCMS/piranha.core/blob/version/v6.1/core/Piranha/Cache/MemoryCache.cs#L42 (The only change needed is to remove
DeepClone
).If you need more information or help I will probably need more detailed information about the pages that you have noticed performance drops in and how they are implemented.
Best regards
Håkan