Problem/Motivation

Each instance method that changes a layout, such as attachToRoot(), setSource() or setThirdPartySettings(), already saves the new revision through Instance::setNewPresent().
The API controllers then save the instance again, in nine places of ApiController and ApiActionsController.
The second save changes nothing, but it costs a full entity save, and it drops the instance from the entity cache once more, so the next load rewrites it.

Measured on a 2690-node layout, the extra save costs 44 to 60 ms per change, plus the cache rewrite; on an article display, 3 to 36 ms.

Proposed resolution

Remove the controller saves that follow an instance method which already saves. Add a kernel test that a change through the API saves the instance once.

Remaining tasks

  • Remove the nine redundant saves.
  • Kernel test: one save per change, for a library drop, a move, a settings update and a paste.

User interface changes

None.

API changes

None.

Data model changes

None.

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

mogtofu33 created an issue. See original summary.

  • mogtofu33 committed 0f3f96af on 1.0.x
    task: #3630609 API controllers save the instance a second time after...
mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs work » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

pdureau’s picture

Status: Fixed » Closed (fixed)