Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use deltas to calculate current state deltas #3595

Merged
merged 7 commits into from
Jul 24, 2018
Merged

Conversation

erikjohnston
Copy link
Member

Most of the time when we're updating current state during persist_events loop its a simple transition from an old state group to a new one, where we already have the delta between the two (from an event context). If we have the delta then we may as well reuse it, rather than pulling out the old and new current state and comparing them in app.

If we have a delta from the existing to new current state, then we can
reuse that rather than manually working it out by fetching both lots of
state.
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, that looks like some code. I guess it might work?

if ev_id != current_state.get(key)
}
to_delete = [
key for key, ev_id in iteritems(existing_state)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do iterkeys if we're not using the values? Or just in existing_state

Deferred[tuple[dict[(str,str), str]|None, dict[(str,str), str]|None]]:
Returns a tuple of two state maps, the first being the full new current
state and the second being the delta to the existing current state.
If both are None then there has been no change.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we clarify when the second is None but the first is not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(done)

@richvdh richvdh assigned erikjohnston and unassigned richvdh Jul 24, 2018
@erikjohnston erikjohnston merged commit 60a1d14 into develop Jul 24, 2018
@erikjohnston erikjohnston deleted the erikj/use_deltas branch September 20, 2018 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants