Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Preserve cache on reverting the snapshot #2488

Merged
merged 3 commits into from
Oct 6, 2016
Merged

Preserve cache on reverting the snapshot #2488

merged 3 commits into from
Oct 6, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Oct 6, 2016

No description provided.

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. B0-patch A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 6, 2016
@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Oct 6, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.001%) to 86.408% when pulling 3b60d68 on snapshot-opt into ecf098e on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 86.373% when pulling 3b60d68 on snapshot-opt into ecf098e on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 86.409% when pulling 3b60d68 on snapshot-opt into ecf098e on master.


// Replace data with another entry but preserve storage cache
fn merge_snapshot(&mut self, other: AccountEntry) {
self.state = other.state;
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the new storage is dirty but the other account is clean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its the other way round. other contains "new" changes that replace self. Everything in self is discarded except for the storage cache

Copy link
Contributor

@gavofyork gavofyork Oct 6, 2016

Choose a reason for hiding this comment

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

maybe rename other to newer, or override.

Copy link
Contributor

Choose a reason for hiding this comment

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

also it's not really merge - it's more like overlay or replace.

Copy link
Contributor

@rphmeier rphmeier Oct 6, 2016

Choose a reason for hiding this comment

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

Aren't the items in the cache dirtier than those in the snapshots? In revert_snapshot it merges the snapshotted account into the cached, overwriting the cached account with the (cleaner) snapshotted account while preserving the dirty storage (which revert_snapshot should be throwing away?)

The name is a bit confusing too, it seems like it would be used in clear_snapshot but is in fact only used when reverting. (edit: looks like Gav got to this point first)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rphmeier That's correct. Dirty storage is discarded, but the clean storage cache is preserved

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed into replace_with

Copy link
Contributor

Choose a reason for hiding this comment

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

just to clarify, the purpose is basically to completely replace the cached account with the snapshotted block, while also preserving any new cached storage values since the snapshotted version was put away?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 86.412% when pulling 3b60d68 on snapshot-opt into ecf098e on master.

@@ -394,7 +394,7 @@ impl Account {
/// Replace self with the data from other account merging storage cache.
/// Basic account data and all modifications are overwritten
/// with new values.
pub fn merge_with(&mut self, other: Account) {
pub fn replace_with(&mut self, other: Account) {
Copy link
Contributor

Choose a reason for hiding this comment

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

actually, having thought about it, i think overwrite_with is best.

fn replace_with(&mut self, other: AccountEntry) {
self.state = other.state;
match other.account {
None => self.account = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

more readable to keep Some and None in same order, at least locally?

@gavofyork gavofyork added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 6, 2016
@gavofyork
Copy link
Contributor

minor grumbles; generally fine.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0008%) to 86.409% when pulling 7855737 on snapshot-opt into ecf098e on master.

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Oct 6, 2016
@arkpar
Copy link
Collaborator Author

arkpar commented Oct 6, 2016

Renamed a few methods and added some documentation on snapshotting.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 86.426% when pulling 5a8bd93 on snapshot-opt into ecf098e on master.

@rphmeier rphmeier added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 6, 2016
@gavofyork gavofyork merged commit 6c1b2fb into master Oct 6, 2016
@gavofyork gavofyork deleted the snapshot-opt branch October 6, 2016 13:54
arkpar added a commit that referenced this pull request Oct 7, 2016
* Preserve cache on reverting the snapshot

* Renamed merge_with into replace_with

* Renamed and documented snapshotting methods
gavofyork pushed a commit that referenced this pull request Oct 7, 2016
* RocksDB version bump

* Preserve cache on reverting the snapshot (#2488)

* Preserve cache on reverting the snapshot

* Renamed merge_with into replace_with

* Renamed and documented snapshotting methods

* Track dirty accounts in the state (#2461)

* State to track dirty accounts

* Removed clone_for_snapshot

* Renaming stuff

* Documentation and other minor fixes

* Replaced MaybeAccount with Option

* Adjustable stack size for EVM (#2483)

* stack size for io workers & evm threshold

* rust way to remember stack size

* right value

* 24kb size

* some stack reduction

* Fixed overflow panic in handshake_panic (#2495)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants