Do not store non-document operation in batches #17678
Labels
domain:performance
This issue reports a problem or potential improvement regarding editor performance.
squad:collaboration
Issue to be handled by the Collaboration team.
type:improvement
This issue reports a possible enhancement of an existing feature.
type:performance
This issue reports a performance issue or a possible performance improvement.
📝 Provide a description of the improvement
Non-document operations are operations that are changing something outside of the main model tree, e.g. inside detached model document fragments.
We use
model.Writer
for all kinds of operations on model items, also for creating model nodes before they are actually added to the model tree. Such operations havebaseVersion
set tonull
andisDocumentOperation
set tofalse
.We want non-document operations to be transparent. We need them only for their
execute()
method, so that we apply the desired change. We filter non-document operations in most (all?) the logic that cares about the operations, because including them usually leads to bugs or unwanted behavior. For example, we filter them from undo mechanism, we don't send them in real-time collaboration as they are not needed on remote client etc.In short, these operations are useless after they are applied. But they are added to
Batch
es, like regular operations.And the problem is that batches retain them. And this is a memory performance problem for big documents. Why exactly? First, we create massive amount of operations during upcast to create a model fragment from the initial data. This model fragment is then inserted into real model tree. But all the non-document operations used to create the model fragment are retained in the batch.
As measured, for an editor instance which takes 100MB memory, this optimization can save around 20MBs (tested for
mixed
test from our performance tests cases suite).On a side note: I believe that for non-document circumstances, we might as well not use operations in the writer at all. It would be possible if "operation action" was declared as a static method of the operation. So we'd call
InsertOperation.execute( ... )
in non-document context, instead ofconst operation = new InsertOperation( ... ); operation.execute();
. This is a possible next step improvement that may have a positive impact on the editor performance.The text was updated successfully, but these errors were encountered: