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

[move-stdlib] Implement bcs::constant_serialized_size<T>(): Option<u64> #14984

Open
wants to merge 1 commit into
base: igor/native_compare
Choose a base branch
from

Conversation

igor-aptos
Copy link
Contributor

Description

It is sometimes useful to know if type has constants serialized size, and for example perform some optimization based on it.

How Has This Been Tested?

provided unit tests

Key Areas to Review

Type of Change

  • New feature

Which Components or Systems Does This Change Impact?

  • Move/Aptos Virtual Machine

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Oct 16, 2024

⏱️ 1h 2m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-unit-coverage 15m 🟩
rust-move-tests 9m 🟥
rust-move-tests 9m 🟥
rust-move-unit-coverage 8m
rust-move-tests 8m
rust-cargo-deny 5m 🟩🟩🟩
check-dynamic-deps 3m 🟩🟩🟩
general-lints 1m 🟩🟩🟩
semgrep/ci 54s 🟩🟩🟩
file_change_determinator 40s 🟩🟩🟩
permission-check 8s 🟩🟩🟩
permission-check 7s 🟩🟩🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 1.81818% with 54 lines in your changes missing coverage. Please review.

Project coverage is 57.5%. Comparing base (a5af4dc) to head (a420b4c).

Files with missing lines Patch % Lines
third_party/move/move-vm/types/src/value_serde.rs 0.0% 34 Missing ⚠️
...ptos-move/framework/move-stdlib/src/natives/bcs.rs 4.7% 20 Missing ⚠️
Additional details and impacted files
@@                         Coverage Diff                          @@
##           igor/use_native_vector_move_range   #14984     +/-   ##
====================================================================
- Coverage                               60.1%    57.5%   -2.7%     
====================================================================
  Files                                    858      858             
  Lines                                 211455   211510     +55     
====================================================================
- Hits                                  127237   121651   -5586     
- Misses                                 84218    89859   +5641     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Ok(fields
.iter()
.map(|field| constant_serialized_size(&field.layout))
.collect::<Result<Option<Vec<_>>, _>>()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this potentially allocate too much? Shall we bother to write a loop or try_for_each()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is nice, but I agree - safer to not worry about it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@igor-aptos igor-aptos added the CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR label Nov 12, 2024

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on c268f4a86b05ae687941cba677591dd03cbb1629

two traffics test: inner traffic : committed: 14230.25 txn/s, latency: 2815.82 ms, (p50: 2700 ms, p70: 2700, p90: 3000 ms, p99: 12400 ms), latency samples: 5410640
two traffics test : committed: 99.98 txn/s, latency: 1683.97 ms, (p50: 1400 ms, p70: 1400, p90: 1500 ms, p99: 10600 ms), latency samples: 1680
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 2.040, avg: 1.582", "ConsensusProposalToOrdered: max: 0.320, avg: 0.290", "ConsensusOrderedToCommit: max: 0.356, avg: 0.345", "ConsensusProposalToCommit: max: 0.647, avg: 0.635"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.99s no progress at version 28107 (avg 0.20s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 8.46s no progress at version 5836169 (avg 8.39s) [limit 15].
Test Ok

Copy link
Contributor

✅ Forge suite compat success on fcd2dedf6ca61a23f4979e944c629dcdbdae5dca ==> c268f4a86b05ae687941cba677591dd03cbb1629

Compatibility test results for fcd2dedf6ca61a23f4979e944c629dcdbdae5dca ==> c268f4a86b05ae687941cba677591dd03cbb1629 (PR)
1. Check liveness of validators at old version: fcd2dedf6ca61a23f4979e944c629dcdbdae5dca
compatibility::simple-validator-upgrade::liveness-check : committed: 14838.84 txn/s, latency: 2307.60 ms, (p50: 1800 ms, p70: 1900, p90: 3300 ms, p99: 12100 ms), latency samples: 573600
2. Upgrading first Validator to new version: c268f4a86b05ae687941cba677591dd03cbb1629
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 7662.72 txn/s, latency: 3767.01 ms, (p50: 4200 ms, p70: 4400, p90: 4500 ms, p99: 4500 ms), latency samples: 143040
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 6926.15 txn/s, latency: 4613.84 ms, (p50: 4600 ms, p70: 4600, p90: 6900 ms, p99: 7100 ms), latency samples: 234340
3. Upgrading rest of first batch to new version: c268f4a86b05ae687941cba677591dd03cbb1629
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 7394.74 txn/s, latency: 3649.27 ms, (p50: 4000 ms, p70: 4500, p90: 5000 ms, p99: 5100 ms), latency samples: 132300
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 7592.18 txn/s, latency: 4200.39 ms, (p50: 4400 ms, p70: 4400, p90: 6200 ms, p99: 6500 ms), latency samples: 253100
4. upgrading second batch to new version: c268f4a86b05ae687941cba677591dd03cbb1629
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 12343.49 txn/s, latency: 2254.45 ms, (p50: 2400 ms, p70: 2500, p90: 2600 ms, p99: 2800 ms), latency samples: 214260
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 11687.58 txn/s, latency: 2676.50 ms, (p50: 2600 ms, p70: 2700, p90: 4500 ms, p99: 5500 ms), latency samples: 377940
5. check swarm health
Compatibility test for fcd2dedf6ca61a23f4979e944c629dcdbdae5dca ==> c268f4a86b05ae687941cba677591dd03cbb1629 passed
Test Ok

| MoveTypeLayout::U256
| MoveTypeLayout::U64
| MoveTypeLayout::Address
| MoveTypeLayout::Signer => 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we return None for signer as it shouldn't have been serialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for gas charging. below we do say signer doesn't have constant size.

| MoveTypeLayout::U128
| MoveTypeLayout::U256
| MoveTypeLayout::U64
| MoveTypeLayout::Address
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose the size should be different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is type_visit_count for constant_serialized_size - i.e. amount needed to charge gas.

constant_serialized_size below is the actual computation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CICD:run-e2e-tests when this label is present github actions will run all land-blocking e2e tests from the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants