Skip to content

Commit

Permalink
shortcircuit when inlined (i.e. when root is leaf)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-aptos committed Nov 12, 2024
1 parent ad50fc9 commit 76262a8
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 620 deletions.
18 changes: 9 additions & 9 deletions aptos-move/e2e-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aptos_language_e2e_tests::{
};
use aptos_transaction_generator_lib::{
publishing::{
module_simple::{AutomaticArgs, LoopType, MultiSigConfig},
module_simple::{AutomaticArgs, LoopType, MapType, MultiSigConfig},
publish_util::{Package, PackageHandler},
},
EntryPoints,
Expand Down Expand Up @@ -177,42 +177,42 @@ LiquidityPoolSwap { is_stable: false } 6 0.925 1.001 535.3
(378, EntryPoints::MapInsertRemove {
len: 10,
repeats: 0,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
(8184, EntryPoints::MapInsertRemove {
len: 10,
repeats: 100,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
(6419, EntryPoints::MapInsertRemove {
len: 10,
repeats: 100,
use_simple_map: true,
map_type: MapType::SimpleMap,
}),
(5094, EntryPoints::MapInsertRemove {
len: 100,
repeats: 0,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
(15838, EntryPoints::MapInsertRemove {
len: 100,
repeats: 100,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
(30962, EntryPoints::MapInsertRemove {
len: 100,
repeats: 100,
use_simple_map: true,
map_type: MapType::SimpleMap,
}),
(66878, EntryPoints::MapInsertRemove {
len: 1000,
repeats: 0,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
(79826, EntryPoints::MapInsertRemove {
len: 1000,
repeats: 100,
use_simple_map: false,
map_type: MapType::OrderedMap,
}),
";

Expand Down
587 changes: 371 additions & 216 deletions aptos-move/framework/aptos-stdlib/doc/big_ordered_map.md

Large diffs are not rendered by default.

147 changes: 42 additions & 105 deletions aptos-move/framework/aptos-stdlib/doc/storage_slots_allocator.md

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions aptos-move/framework/aptos-stdlib/doc/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct itself, while the operations are implemented as native functions. No trav
- [Function `upsert`](#0x1_table_upsert)
- [Function `remove`](#0x1_table_remove)
- [Function `contains`](#0x1_table_contains)
- [Function `destroy`](#0x1_table_destroy)
- [Function `destroy_known_empty_unsafe`](#0x1_table_destroy_known_empty_unsafe)
- [Function `new_table_handle`](#0x1_table_new_table_handle)
- [Function `add_box`](#0x1_table_add_box)
- [Function `borrow_box`](#0x1_table_borrow_box)
Expand All @@ -41,7 +41,7 @@ struct itself, while the operations are implemented as native functions. No trav
- [Function `upsert`](#@Specification_0_upsert)
- [Function `remove`](#@Specification_0_remove)
- [Function `contains`](#@Specification_0_contains)
- [Function `destroy`](#@Specification_0_destroy)
- [Function `destroy_known_empty_unsafe`](#@Specification_0_destroy_known_empty_unsafe)


<pre><code></code></pre>
Expand Down Expand Up @@ -352,15 +352,15 @@ Returns true iff <code>self</code> contains an entry for <code>key</code>.

</details>

<a id="0x1_table_destroy"></a>
<a id="0x1_table_destroy_known_empty_unsafe"></a>

## Function `destroy`
## Function `destroy_known_empty_unsafe`

Table cannot know if it is empty or not, so this method is not public,
and can be used only in modules that know by themselves that table is empty.


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy">destroy</a>&lt;K: <b>copy</b>, drop, V&gt;(self: <a href="table.md#0x1_table_Table">table::Table</a>&lt;K, V&gt;)
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy_known_empty_unsafe">destroy_known_empty_unsafe</a>&lt;K: <b>copy</b>, drop, V&gt;(self: <a href="table.md#0x1_table_Table">table::Table</a>&lt;K, V&gt;)
</code></pre>


Expand All @@ -369,7 +369,7 @@ and can be used only in modules that know by themselves that table is empty.
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy">destroy</a>&lt;K: <b>copy</b> + drop, V&gt;(self: <a href="table.md#0x1_table_Table">Table</a>&lt;K, V&gt;) {
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy_known_empty_unsafe">destroy_known_empty_unsafe</a>&lt;K: <b>copy</b> + drop, V&gt;(self: <a href="table.md#0x1_table_Table">Table</a>&lt;K, V&gt;) {
<a href="table.md#0x1_table_destroy_empty_box">destroy_empty_box</a>&lt;K, V, <a href="table.md#0x1_table_Box">Box</a>&lt;V&gt;&gt;(&self);
<a href="table.md#0x1_table_drop_unchecked_box">drop_unchecked_box</a>&lt;K, V, <a href="table.md#0x1_table_Box">Box</a>&lt;V&gt;&gt;(self)
}
Expand Down Expand Up @@ -583,7 +583,7 @@ and can be used only in modules that know by themselves that table is empty.

<pre><code><b>pragma</b> intrinsic = map,
map_new = new,
map_destroy_empty = destroy,
map_destroy_empty = destroy_known_empty_unsafe,
map_has_key = contains,
map_add_no_override = add,
map_add_override_if_exists = upsert,
Expand Down Expand Up @@ -763,12 +763,12 @@ and can be used only in modules that know by themselves that table is empty.



<a id="@Specification_0_destroy"></a>
<a id="@Specification_0_destroy_known_empty_unsafe"></a>

### Function `destroy`
### Function `destroy_known_empty_unsafe`


<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy">destroy</a>&lt;K: <b>copy</b>, drop, V&gt;(self: <a href="table.md#0x1_table_Table">table::Table</a>&lt;K, V&gt;)
<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="table.md#0x1_table_destroy_known_empty_unsafe">destroy_known_empty_unsafe</a>&lt;K: <b>copy</b>, drop, V&gt;(self: <a href="table.md#0x1_table_Table">table::Table</a>&lt;K, V&gt;)
</code></pre>


Expand Down
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-stdlib/doc/table_with_length.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Destroy a table. The table must be empty to succeed.
<pre><code><b>public</b> <b>fun</b> <a href="table_with_length.md#0x1_table_with_length_destroy_empty">destroy_empty</a>&lt;K: <b>copy</b> + drop, V&gt;(self: <a href="table_with_length.md#0x1_table_with_length_TableWithLength">TableWithLength</a>&lt;K, V&gt;) {
<b>assert</b>!(self.length == 0, <a href="../../move-stdlib/doc/error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="table_with_length.md#0x1_table_with_length_ENOT_EMPTY">ENOT_EMPTY</a>));
<b>let</b> <a href="table_with_length.md#0x1_table_with_length_TableWithLength">TableWithLength</a> { inner, length: _ } = self;
<a href="table.md#0x1_table_destroy">table::destroy</a>(inner)
<a href="table.md#0x1_table_destroy_known_empty_unsafe">table::destroy_known_empty_unsafe</a>(inner)
}
</code></pre>

Expand Down
Loading

0 comments on commit 76262a8

Please sign in to comment.