Problem/Motivation

When an entity is inserted, updated or deleted, all operations related to links are performed inside the request. They can be expensive and there's no good reason the links generation should be performed while the client waits for the response. We don't need those links instantly. Moreover, creating entities inside the transaction (of node save, for instance) leads potentially to complications.

Proposed resolution

Move the operations in after the response has been sent to the client, in Kernel terminate phase.

Remaining tasks

None.

User interface changes

None.

API changes

Two services to implement DestructableInterface.

Data model changes

None.

CommentFileSizeAuthor
#4 benchmark.diff2.79 KBclaudiu.cristea
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Title: Move expensive operations after sending the response » Avoid expensive operations while client waits for response

claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Status: Active » Needs review
StatusFileSize
new2.79 KB

Benchmark

I've created the attached function test to run some benchmarks. The test simply outputs the time consumed with saving a node with a lot of links. I've exaggerated the number of links just to make my point but even with some decent numbers the gain is obvious. I've run the test 5 times against 2.1.x and against the MRs branch. Here are my results:

2.1.x MR
23.05 sec 0.20 sec
22.70 sec 0.24 sec
22.93 sec 0.18 sec
23.71 sec 0.19 sec
22.68 sec 0.19 sec
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
dimilias’s picture

Status: Needs review » Reviewed & tested by the community

Seems to be working nice. RTBC + 1