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

[framework] Adding utilities to OrderedMap / BigOrderedMap #15810

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

igor-aptos
Copy link
Contributor

making traversal APIs complete and public
adding ordering-based utilities, without iterator functionality

Description

How Has This Been Tested?

Key Areas to Review

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

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 Jan 24, 2025

⏱️ 10m total CI duration on this PR
Job Cumulative Duration Recent Runs
check-dynamic-deps 4m 🟩🟩
rust-cargo-deny 4m 🟩🟩
general-lints 1m 🟩🟩
semgrep/ci 1m 🟩🟩
file_change_determinator 20s 🟩🟩
permission-check 4s 🟩🟩
permission-check 4s 🟩🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

Comment on lines +152 to 155
// Use new_with_type_size_hints or new_with_config if your types have variable sizes.
assert!(
bcs::constant_serialized_size<K>().is_some() && bcs::constant_serialized_size<V>().is_some(),
error::invalid_argument(EINVALID_CONFIG_PARAMETER)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if it is better to allow new() for all types - and then if first values inserted are not representative - by a factor of 100x+ - not being able to insert bigger values later.
or as implemented here - be conservative - and ask people to intentionally provide or not provide size hints.


/// Returns the number of elements in the BigOrderedMap.
/// This is an expensive function, as it goes through all the leaves to compute it.
public fun compute_length<K: store, V: store>(self: &BigOrderedMap<K, V>): u64 {
Copy link
Contributor Author

@igor-aptos igor-aptos Jan 24, 2025

Choose a reason for hiding this comment

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

intentionally not calling length() because it is expensive to call. Is that reasonable?

@igor-aptos igor-aptos force-pushed the igor/adding_utilities_to_maps branch from b12b063 to 9dbe637 Compare January 27, 2025 16:58
@@ -349,7 +397,7 @@ module aptos_std::ordered_map {
}

/// Returns whether the iterator is a begin iterator.
public fun iter_is_begin<K, V>(self: &IteratorPtr, map: &OrderedMap<K, V>): bool {
public(friend) fun iter_is_begin<K, V>(self: &IteratorPtr, map: &OrderedMap<K, V>): bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intentional?

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! I've patched this in 1.26 already. iter* should all be public friend, until references are available in move

Copy link
Contributor

@runtian-zhou runtian-zhou left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@igor-aptos igor-aptos force-pushed the igor/adding_utilities_to_maps branch from 9dbe637 to 8b276ea Compare January 31, 2025 21:57
@igor-aptos igor-aptos force-pushed the igor/adding_utilities_to_maps branch from 8b276ea to 9372017 Compare February 3, 2025 06:38
making traversal APIs complete and public
adding ordering-based utilities, without iterator functionality
@igor-aptos igor-aptos force-pushed the igor/adding_utilities_to_maps branch from 9372017 to 53c9d4e Compare February 3, 2025 21:59
@igor-aptos igor-aptos enabled auto-merge (squash) February 3, 2025 22:46

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Feb 3, 2025

✅ Forge suite compat success on 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11

Compatibility test results for 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11 (PR)
1. Check liveness of validators at old version: 60f7ca8827f5d64a148c3b163dc4126b0879279b
compatibility::simple-validator-upgrade::liveness-check : committed: 6371.69 txn/s, submitted: 6371.86 txn/s, expired: 0.17 txn/s, latency: 2490.89 ms, (p50: 2500 ms, p70: 2700, p90: 2900 ms, p99: 3200 ms), latency samples: 410589
2. Upgrading first Validator to new version: 53c9d4e84587f8f794124e104cf24aa082dbea11
compatibility::simple-validator-upgrade::single-validator-upgrading : committed: 3342.89 txn/s, latency: 8833.59 ms, (p50: 9400 ms, p70: 10600, p90: 11300 ms, p99: 11500 ms), latency samples: 74280
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 3335.73 txn/s, latency: 10343.01 ms, (p50: 11300 ms, p70: 11600, p90: 11600 ms, p99: 11900 ms), latency samples: 127560
3. Upgrading rest of first batch to new version: 53c9d4e84587f8f794124e104cf24aa082dbea11
compatibility::simple-validator-upgrade::half-validator-upgrading : committed: 3344.56 txn/s, latency: 8828.83 ms, (p50: 9600 ms, p70: 10800, p90: 11600 ms, p99: 11700 ms), latency samples: 73540
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 3352.53 txn/s, latency: 10275.95 ms, (p50: 11300 ms, p70: 11600, p90: 11900 ms, p99: 11900 ms), latency samples: 127500
4. upgrading second batch to new version: 53c9d4e84587f8f794124e104cf24aa082dbea11
compatibility::simple-validator-upgrade::rest-validator-upgrading : committed: 6337.80 txn/s, latency: 4811.84 ms, (p50: 5600 ms, p70: 6000, p90: 6100 ms, p99: 6200 ms), latency samples: 117940
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 6223.03 txn/s, latency: 5542.85 ms, (p50: 6000 ms, p70: 6000, p90: 6100 ms, p99: 6300 ms), latency samples: 217040
5. check swarm health
Compatibility test for 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11 passed
Test Ok

Copy link
Contributor

github-actions bot commented Feb 3, 2025

✅ Forge suite framework_upgrade success on 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11

Compatibility test results for 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11 (PR)
Upgrade the nodes to version: 53c9d4e84587f8f794124e104cf24aa082dbea11
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1620.51 txn/s, submitted: 1625.80 txn/s, failed submission: 5.29 txn/s, expired: 5.29 txn/s, latency: 1779.38 ms, (p50: 1800 ms, p70: 2100, p90: 2500 ms, p99: 3700 ms), latency samples: 147020
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1552.42 txn/s, submitted: 1556.63 txn/s, failed submission: 4.21 txn/s, expired: 4.21 txn/s, latency: 1859.87 ms, (p50: 1600 ms, p70: 2000, p90: 3100 ms, p99: 4600 ms), latency samples: 140240
5. check swarm health
Compatibility test for 60f7ca8827f5d64a148c3b163dc4126b0879279b ==> 53c9d4e84587f8f794124e104cf24aa082dbea11 passed
Upgrade the remaining nodes to version: 53c9d4e84587f8f794124e104cf24aa082dbea11
framework_upgrade::framework-upgrade::full-framework-upgrade : committed: 1750.71 txn/s, submitted: 1754.74 txn/s, failed submission: 4.03 txn/s, expired: 4.03 txn/s, latency: 1751.43 ms, (p50: 1500 ms, p70: 1900, p90: 2800 ms, p99: 4500 ms), latency samples: 156360
Test Ok

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Feb 3, 2025

✅ Forge suite realistic_env_max_load success on 53c9d4e84587f8f794124e104cf24aa082dbea11

two traffics test: inner traffic : committed: 13106.47 txn/s, submitted: 13108.05 txn/s, expired: 1.58 txn/s, latency: 3020.74 ms, (p50: 3000 ms, p70: 3000, p90: 3300 ms, p99: 3900 ms), latency samples: 4983360
two traffics test : committed: 99.96 txn/s, latency: 2134.95 ms, (p50: 2100 ms, p70: 2500, p90: 2800 ms, p99: 3700 ms), latency samples: 1780
Latency breakdown for phase 0: ["MempoolToBlockCreation: max: 1.316, avg: 0.961", "ConsensusProposalToOrdered: max: 0.326, avg: 0.316", "ConsensusOrderedToCommit: max: 0.962, avg: 0.639", "ConsensusProposalToCommit: max: 1.277, avg: 0.955"]
Max non-epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 1.15s no progress at version 45190 (avg 0.22s) [limit 15].
Max epoch-change gap was: 0 rounds at version 0 (avg 0.00) [limit 4], 0.78s no progress at version 2437325 (avg 0.78s) [limit 16].
Test Ok

@igor-aptos igor-aptos merged commit 4eaf379 into main Feb 3, 2025
88 checks passed
@igor-aptos igor-aptos deleted the igor/adding_utilities_to_maps branch February 3, 2025 23:29
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.

3 participants