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

Performance: save components are called for *every* block on *every* keystroke #10427

Closed
ellatrix opened this issue Oct 9, 2018 · 6 comments
Closed
Assignees
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Performance Related to performance efforts

Comments

@ellatrix
Copy link
Member

ellatrix commented Oct 9, 2018

Describe the bug

This happens after the initial autosave, from then on every keystroke (or any attribute change) will trigger serialisation of the whole post content. I would expect (partial) serialisation of the content to only happen once the post has to be saved, ideally only for the parts that have changed.

The issue seems to happen where we try to determine whether the post is auto saveable?

export function isEditedPostAutosaveable( state ) {
// A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
if ( ! isEditedPostSaveable( state ) ) {
return false;
}
// If we don't already have an autosave, the post is autosaveable.
if ( ! hasAutosave( state ) ) {
return true;
}
// If the title, excerpt or content has changed, the post is autosaveable.
const autosave = getAutosave( state );
return [ 'title', 'excerpt', 'content' ].some( ( field ) => (
autosave[ field ] !== getEditedPostAttribute( state, field )
) );
}

Looking further into this, but reporting now because it seems high priority.

@ellatrix ellatrix added [Priority] High Used to indicate top priority items that need quick attention [Type] Performance Related to performance efforts labels Oct 9, 2018
@ellatrix
Copy link
Member Author

ellatrix commented Oct 9, 2018

Seems to be introduced in #6257 with changes to AutosaveMonitor. Cc @adamsilverstein @danielbachhuber @aduth.

@ellatrix
Copy link
Member Author

ellatrix commented Oct 9, 2018

Issue seems to be generally with the check for saveable post content, which causes serialisation on every change. This check should be made more performant somehow, maybe shallowly comparing the raw state vs comparing the the serialised content.

@ktmn
Copy link

ktmn commented Oct 13, 2018

Relevant #9624

@aduth
Copy link
Member

aduth commented Oct 20, 2018

This could be potentially resolved in parallel with #7409, in splitting a simple hasDirtyContent boolean value which could be used in place of the content serialization in isEditedPostAutosaveable.

@aduth
Copy link
Member

aduth commented Oct 21, 2018

Alternative pull request (also closing #7409) at #10844

@mtias
Copy link
Member

mtias commented Nov 8, 2018

Nice work debugging and addressing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Performance Related to performance efforts
Projects
None yet
Development

No branches or pull requests

6 participants