Skip to content

Commit

Permalink
[move][stdlib] Add vector::split_off and vector::remove library methods
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-aptos authored and rahxephon89 committed Dec 3, 2024
1 parent 47be7b1 commit 4cb6e24
Show file tree
Hide file tree
Showing 14 changed files with 823 additions and 44 deletions.
101 changes: 101 additions & 0 deletions aptos-move/e2e-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,47 @@ const ALLOWED_REGRESSION: f64 = 0.15;
const ALLOWED_IMPROVEMENT: f64 = 0.15;
const ABSOLUTE_BUFFER_US: f64 = 2.0;

<<<<<<< HEAD
=======
const CALIBRATION_VALUES: &str = "
Loop { loop_count: Some(100000), loop_type: NoOp } 60 0.955 1.074 41893.7
Loop { loop_count: Some(10000), loop_type: Arithmetic } 60 0.965 1.078 25915.0
CreateObjects { num_objects: 10, object_payload_size: 0 } 60 0.924 1.082 158.1
CreateObjects { num_objects: 10, object_payload_size: 10240 } 60 0.951 1.118 9356.2
CreateObjects { num_objects: 100, object_payload_size: 0 } 60 0.926 1.082 1574.2
CreateObjects { num_objects: 100, object_payload_size: 10240 } 60 0.952 1.092 11541.9
InitializeVectorPicture { length: 128 } 10 0.965 1.038 163.3
VectorPicture { length: 128 } 10 0.938 1.060 48.8
VectorPictureRead { length: 128 } 10 0.977 1.077 46.4
InitializeVectorPicture { length: 30720 } 60 0.948 1.123 27893.4
VectorPicture { length: 30720 } 60 0.931 1.125 6923.1
VectorPictureRead { length: 30720 } 60 0.934 1.102 6923.1
SmartTablePicture { length: 30720, num_points_per_txn: 200 } 60 0.952 1.109 43594.7
SmartTablePicture { length: 1048576, num_points_per_txn: 300 } 60 0.957 1.120 73865.4
ResourceGroupsSenderWriteTag { string_length: 1024 } 60 0.934 1.134 15.0
ResourceGroupsSenderMultiChange { string_length: 1024 } 60 0.929 1.122 32.3
TokenV1MintAndTransferFT 60 0.958 1.093 385.2
TokenV1MintAndTransferNFTSequential 60 0.973 1.139 588.1
TokenV2AmbassadorMint { numbered: true } 60 0.960 1.141 512.5
LiquidityPoolSwap { is_stable: true } 60 0.961 1.103 590.3
LiquidityPoolSwap { is_stable: false } 60 0.954 1.134 552.2
CoinInitAndMint 10 0.975 1.043 199.6
FungibleAssetMint 10 0.954 1.038 236.3
IncGlobalMilestoneAggV2 { milestone_every: 1 } 10 0.960 1.047 32.9
IncGlobalMilestoneAggV2 { milestone_every: 2 } 10 0.971 1.066 18.1
EmitEvents { count: 1000 } 10 0.969 1.052 8615.5
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 0, repeats: 0 } 6 0.925 1.001 22909
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 6 0.925 1.001 47073
VectorTrimAppend { vec_len: 3000, element_len: 1, index: 2990, repeats: 1000 } 6 0.925 1.001 34788
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 100, repeats: 1000 } 6 0.925 1.001 45273
VectorRemoveInsert { vec_len: 3000, element_len: 1, index: 2998, repeats: 1000 } 6 0.925 1.001 36859
VectorRangeMove { vec_len: 3000, element_len: 1, index: 1000, move_len: 500, repeats: 1000 } 6 0.925 1.001 65311
VectorTrimAppend { vec_len: 100, element_len: 100, index: 0, repeats: 0 } 6 0.925 1.001 875
VectorTrimAppend { vec_len: 100, element_len: 100, index: 10, repeats: 1000 } 6 0.925 1.001 13366
VectorRangeMove { vec_len: 100, element_len: 100, index: 50, move_len: 10, repeats: 1000 } 6 0.925 1.001 7098
";

>>>>>>> cb36071f2f ([move][stdlib] Add vector::split_off and vector::remove library methods)
struct CalibrationInfo {
// count: usize,
expected_time_micros: f64,
Expand Down Expand Up @@ -176,6 +217,66 @@ fn main() {
EntryPoints::IncGlobalMilestoneAggV2 { milestone_every: 1 },
EntryPoints::IncGlobalMilestoneAggV2 { milestone_every: 2 },
EntryPoints::EmitEvents { count: 1000 },
// long vectors with small elements
EntryPoints::VectorTrimAppend {
// baseline, only vector creation
vec_len: 3000,
element_len: 1,
index: 0,
repeats: 0,
},
EntryPoints::VectorTrimAppend {
vec_len: 3000,
element_len: 1,
index: 100,
repeats: 1000,
},
EntryPoints::VectorTrimAppend {
vec_len: 3000,
element_len: 1,
index: 2990,
repeats: 1000,
},
EntryPoints::VectorRemoveInsert {
vec_len: 3000,
element_len: 1,
index: 100,
repeats: 1000,
},
EntryPoints::VectorRemoveInsert {
vec_len: 3000,
element_len: 1,
index: 2998,
repeats: 1000,
},
EntryPoints::VectorRangeMove {
vec_len: 3000,
element_len: 1,
index: 1000,
move_len: 500,
repeats: 1000,
},
// vectors with large elements
EntryPoints::VectorTrimAppend {
// baseline, only vector creation
vec_len: 100,
element_len: 100,
index: 0,
repeats: 0,
},
EntryPoints::VectorTrimAppend {
vec_len: 100,
element_len: 100,
index: 10,
repeats: 1000,
},
EntryPoints::VectorRangeMove {
vec_len: 100,
element_len: 100,
index: 50,
move_len: 10,
repeats: 1000,
},
];

let mut failures = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-stdlib/doc/big_vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ Aborts if <code>i</code> is out of bounds.
<b>if</b> (self.end_index == i) {
<b>return</b> last_val
};
// because the lack of mem::swap, here we swap remove the requested value from the bucket
// because the lack of <a href="../../move-stdlib/doc/mem.md#0x1_mem_swap">mem::swap</a>, here we swap remove the requested value from the bucket
// and append the last_val <b>to</b> the bucket then swap the last bucket val back
<b>let</b> bucket = <a href="table_with_length.md#0x1_table_with_length_borrow_mut">table_with_length::borrow_mut</a>(&<b>mut</b> self.buckets, i / self.bucket_size);
<b>let</b> bucket_len = <a href="../../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(bucket);
Expand Down
57 changes: 57 additions & 0 deletions aptos-move/framework/move-stdlib/doc/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ return true.
- [Function `transaction_simulation_enhancement_enabled`](#0x1_features_transaction_simulation_enhancement_enabled)
- [Function `get_collection_owner_feature`](#0x1_features_get_collection_owner_feature)
- [Function `is_collection_owner_enabled`](#0x1_features_is_collection_owner_enabled)
- [Function `get_native_memory_operations_feature`](#0x1_features_get_native_memory_operations_feature)
- [Function `is_native_memory_operations_enabled`](#0x1_features_is_native_memory_operations_enabled)
- [Function `change_feature_flags`](#0x1_features_change_feature_flags)
- [Function `change_feature_flags_internal`](#0x1_features_change_feature_flags_internal)
- [Function `change_feature_flags_for_next_epoch`](#0x1_features_change_feature_flags_for_next_epoch)
Expand Down Expand Up @@ -671,6 +673,15 @@ Lifetime: transient



<a id="0x1_features_NATIVE_MEMORY_OPERATIONS"></a>



<pre><code><b>const</b> <a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a>: u64 = 80;
</code></pre>



<a id="0x1_features_NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE"></a>

Lifetime: transient
Expand Down Expand Up @@ -3274,6 +3285,52 @@ Deprecated feature



</details>

<a id="0x1_features_get_native_memory_operations_feature"></a>

## Function `get_native_memory_operations_feature`



<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_native_memory_operations_feature">get_native_memory_operations_feature</a>(): u64
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_get_native_memory_operations_feature">get_native_memory_operations_feature</a>(): u64 { <a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a> }
</code></pre>



</details>

<a id="0x1_features_is_native_memory_operations_enabled"></a>

## Function `is_native_memory_operations_enabled`



<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_is_native_memory_operations_enabled">is_native_memory_operations_enabled</a>(): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="features.md#0x1_features_is_native_memory_operations_enabled">is_native_memory_operations_enabled</a>(): bool <b>acquires</b> <a href="features.md#0x1_features_Features">Features</a> {
<a href="features.md#0x1_features_is_enabled">is_enabled</a>(<a href="features.md#0x1_features_NATIVE_MEMORY_OPERATIONS">NATIVE_MEMORY_OPERATIONS</a>)
}
</code></pre>



</details>

<a id="0x1_features_change_feature_flags"></a>
Expand Down
Loading

0 comments on commit 4cb6e24

Please sign in to comment.