Bulk content actions #12496
nikcio
started this conversation in
Features and ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bulk content actions
In Umbraco, we already have a content service interface that lets us create, save, publish and delete content but an area that still has room to grow is making changes in bulk. There's already quite a bit of overhead when manipulating content which makes content changes in bulk very expensive. Therefore, I propose making bulk actions for manipulating content where it's easier to optimize a process for editing content in bulk and thereby lowering the overhead needed. I've already made a bit of research on one of the ways the process for saving and publishing as well as deleting could be optimized.
I believe that there are more ways bulk actions could be optimzied which is why it's created here as a discussion.
Table of contents
- Table of contents
Bulk actions setup
So the bulk actions I created were the
Delete
andSaveAndPublish
methods on theContentService
. The optimizations I made were to limit the number of notifications that needed to be sent and the number of scopes that needed to be created.Delete
Original delete
Umbraco-CMS/src/Umbraco.Core/Services/ContentService.cs
Lines 2217 to 2275 in d0a7522
Bulk delete
The
BulkDelete
method uses a profiling logger for debug purposes. I wanted to know which part of the process was the most demanding and by how much. The conclusion was that theDeleting content
part was the most demanding by far.Example trace:
Save and publish
Original save and publish
Umbraco-CMS/src/Umbraco.Core/Services/ContentService.cs
Lines 1087 to 1149 in d0a7522
Bulk save and publish
The
BulkSaveAndPublish
method uses a profiling logger for debug purposes. I wanted to know which part of the process was the most demanding and by how much. The conclusion was that thePublish contentItem
part was the most demanding by far.Example trace:
Benchmarks setup
Note: I'm in no way an expert benchmarker
To figure out if my changes were any improvement I created a simple Benchmarking setup to test the creation process against the existing one.
The setup included a clean Umbraco install straight from source code hooked up to a Docker MSSQL server running on my local machine. In the Umbraco instance, I created one document type called
Test
with the aliastest
. This document type included no properties and was allowed as a root element. Besides that, I created a controllerContentController
:ContentController
This controller has actions for creating a single or creating multiple content nodes in the root as well as cleaning the root for content nodes.
Note: The
Lifecycle
naming was just bad naming on my part. The methods only create content nodesContent lifecycle test
The first test I ran was a lifecycle test where I first created several nodes before deleting all content nodes. Before and after a benchmark the content tree is cleaned to make sure that every test had a clean starting point even if one clean failed, which I did not experience.
Content lifecycle test code
Results
Thoughts
The results in this test show that the decrease in scopes and notifications does improve performance when working with bulk operations.
Note: This is the time to create and delete
Explanation
Content save and publish test
The second test was based on a more real-world use case where the content nodes were not deleted between every run. This means that the number of nodes was higher the more tests was run. The content tree was cleaned from all content nodes between benchmarks, meaning that every benchmark would start from a clean content tree.
Content save and publish test code
Results
Thoughts
The results in this test show that the decrease in scopes and notifications does improve performance when working with bulk operations. But the difference is not as noticeable as in the first test.
This might be due to the gradual increase in operation time that the test encountered. The test data showed that the more content nodes created in the content tree the longer it took to create new ones. See diagrams.
Explanation
Note: This is the time to only create a content node
Diagrams
https://docs.google.com/spreadsheets/d/1reKIUMoJMdI-f-WYLuUwXz6C28fsUAkhUkz4WjbrzDw/edit?usp=sharing
POC
The code used to create this can be found here: nikcio@95a8f5d
Discussion comments
Beta Was this translation helpful? Give feedback.
All reactions