You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BackingStore tries to keep the "dirty" state up to date on every call to read a property value. Because of the way the logic to track changes on collections was implemented, this has a detrimental impact on both CPU and memory consumption.
Currently, reading a property from a model is an operation of potentially exponential complexity that allocates memory on the heap.
Whether paying this cost on every property read in order to prevent sending additional data on the network is worth it or not is debatable, but it definitely isn't if we have no intention of performing any update call.
From my understanding of the implementation, the idea is to always return every values except when ReturnOnlyChangedValues is set to true. This seems to mostly be activated right before serialization, and deactivated immediately after.
If that is the case, I would suggest checking the value of ReturnOnlyChangedValues before calling EnsureCollectionPropertyIsConsistent when reading a property value. There is no rush to keep the dirty state synchronized until we are actually using it. On that note, it might also be a good idea to call it within EnumerateKeysForValuesChangedToNull, although I haven't exactly explored every intended usage of this function.
A local test with this modification applied produced large improvements on speed and removed any memory allocation when reading properties.
Is my understanding of the intent of InMemoryBackingStore correct? Would my suggested fix make sense?
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
The BackingStore tries to keep the "dirty" state up to date on every call to read a property value. Because of the way the logic to track changes on collections was implemented, this has a detrimental impact on both CPU and memory consumption.
Currently, reading a property from a model is an operation of potentially exponential complexity that allocates memory on the heap.
Whether paying this cost on every property read in order to prevent sending additional data on the network is worth it or not is debatable, but it definitely isn't if we have no intention of performing any update call.
From my understanding of the implementation, the idea is to always return every values except when
ReturnOnlyChangedValues
is set to true. This seems to mostly be activated right before serialization, and deactivated immediately after.If that is the case, I would suggest checking the value of
ReturnOnlyChangedValues
before callingEnsureCollectionPropertyIsConsistent
when reading a property value. There is no rush to keep the dirty state synchronized until we are actually using it. On that note, it might also be a good idea to call it withinEnumerateKeysForValuesChangedToNull
, although I haven't exactly explored every intended usage of this function.A local test with this modification applied produced large improvements on speed and removed any memory allocation when reading properties.
Is my understanding of the intent of InMemoryBackingStore correct? Would my suggested fix make sense?
The text was updated successfully, but these errors were encountered: