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

[vm] Introducing a delta write #2057

Merged
merged 5 commits into from
Jul 21, 2022
Merged

Conversation

georgemitenkov
Copy link
Contributor

@georgemitenkov georgemitenkov commented Jul 18, 2022

Description

This PR introduces a new WriteOp - Delta. Delta is parametrised by a serialised value, operation used to apply this value, and a limit (basically a postcondition that ensures the result of delta application does not overflow).

Currently, deltas are not used and not produced anywhere. This PR allows aggregator from #1836 (once it is rebased and cleaned) to produce a change set containing deltas.

Test Plan

Subsequent PRs will add sequential and parallel execution support, with appropriate tests.


This change is Reviewable

@gelash
Copy link
Contributor

gelash commented Jul 18, 2022

Looks good to me,

Two notes:

  1. I believe WriteSetChange is used by indexer and other components and should never see the Delta (if Move-VM returns delta to executor but executor output never has delta) - but would love to confirm, e.g. w. @zekun000
  2. Some tests are failing, looks like we may have to add something for DeltaOperation and DeltaLimit to testsuite/generate-format/src/aptos.rs? Again someone more knowledgeable than me can probably help.

@lightmark
Copy link
Contributor

fyi: We call this Merge in RocksDB.
https://github.com/facebook/rocksdb/wiki/Merge-Operator

pub enum WriteOp {
Deletion,
Delta(DeltaOperation, DeltaLimit, Vec<u8>),
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the last Vec<u8>? is it the actual delta value? I thought it's something like u128.

Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should also put it in the end, and having #[serde(skip)] since this is not expected to go into storage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is the value of the delta and actually having u128 makes sense since we don't go to storage indeed

testsuite/generate-format/src/aptos.rs Outdated Show resolved Hide resolved
@georgemitenkov georgemitenkov force-pushed the george/aggregator-delta-writes branch from 3ea1ed1 to 19a88fd Compare July 19, 2022 22:01
#[derive(Clone, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub enum WriteOp {
Deletion,
#[serde(skip)]
Delta(DeltaOperation, DeltaLimit, u128),
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason why you don't carry u128 in the DeltaOperation? like
enum DeltaOperation {
Addition(u128),
Subtraction(u128),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially, the idea was to have delta(op, bytes) so that any update in the future cam simply specify op and serialize value into bytes. So no particular reason of keeping u128 in Delta. If we move it to operation as you suggested, I think we should move the limit as well since it is a postcondition of DeltaOperation

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should merge the u128, I don't have strong opinion on DeltaLimit since it at least has a name 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, let's merge u128 only then for now :)

Copy link
Contributor

@zekun000 zekun000 left a comment

Choose a reason for hiding this comment

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

lgtm, please squash all commits before merge it

@msmouse
Copy link
Contributor

msmouse commented Jul 20, 2022

It feels bad we have to leak the delta concept to outside of the VM adaptor. I advocate changing the ChangeSet, TransactionOutput (used internally by the VM adaptor) etc concepts to carry the set of delta directly, and output the final WriteSet / TransactionOutput in their original format.

The fact we are now doing all the panics in all the matches all the way to the Rest API indicates it's not right.

@gelash and I talked offline and agreed it's probably the best to land this first and follow up really soon to correct it.

@georgemitenkov georgemitenkov enabled auto-merge (squash) July 21, 2022 14:03
@github-actions
Copy link
Contributor

❌ Forge test failure

Forge is land-blocking

Forge test runner terminated

@github-actions
Copy link
Contributor

❌ Forge test failure

Forge is land-blocking

Forge test runner terminated

@github-actions
Copy link
Contributor

✅ Forge test success

Forge is land-blocking

all up : 5562 TPS, 3069 ms latency, 4700 ms p99 latency,no expired txns

@georgemitenkov georgemitenkov merged commit d28db3d into main Jul 21, 2022
@georgemitenkov georgemitenkov deleted the george/aggregator-delta-writes branch July 21, 2022 18:10
georgemitenkov added a commit that referenced this pull request Jul 29, 2022
Fixes #2057. Now deltas do not escape from executor, and are stored in
`TransactionOutputExt` and `ChangeSetExt` wrappers.
bowenyang007 pushed a commit to bowenyang007/aptos-core that referenced this pull request Jul 29, 2022
…#2222)

Fixes aptos-labs#2057. Now deltas do not escape from executor, and are stored in
`TransactionOutputExt` and `ChangeSetExt` wrappers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants