Skip to content

Commit

Permalink
[move-compiler] Support for skipping function bodies during compilati…
Browse files Browse the repository at this point in the history
…on (#20588)

## Description 

This PR adds the ability for the compiler to skip compiling function
bodies for some files. This is particularly useful in the IDE setting
where we can cache results of compilation of the entire package and
re-compile only files changed by the user.

The difference for larger codebases, for example Sui's Deepbook package,
is significant and directly affects user experience. Currently, it takes
over 1s to compile Deepbook package itself (dependencies are already
cached), which means that the user has to wait over 1s for
auto-completion request to provide completion hints:

![image](https://github.com/user-attachments/assets/c7de8950-ea11-48b1-b722-e3fce99bb5d0)

With this compiler change (and additional changes to `move-analyzer`
which will be landed in a separate PR), we get Deepbok's compilation
time down to less than 200ms:


![image](https://github.com/user-attachments/assets/e9f47e45-544d-4c54-9716-afd1ef85319c)


## Test plan 

All existing tests must pass
  • Loading branch information
awelc authored Dec 13, 2024
1 parent ee5e2f6 commit 1cff85a
Show file tree
Hide file tree
Showing 66 changed files with 1,281 additions and 1,309 deletions.
18 changes: 9 additions & 9 deletions crates/sui-framework/docs/bridge/bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,29 +458,29 @@ title: Module `0xb::bridge`



<a name="0xb_bridge_CURRENT_VERSION"></a>
<a name="0xb_bridge_EInvalidBridgeRoute"></a>



<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_CURRENT_VERSION">CURRENT_VERSION</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 1;
<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_EInvalidBridgeRoute">EInvalidBridgeRoute</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 16;
</code></pre>



<a name="0xb_bridge_EInvalidBridgeRoute"></a>
<a name="0xb_bridge_EMustBeTokenMessage"></a>



<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_EInvalidBridgeRoute">EInvalidBridgeRoute</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 16;
<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_EMustBeTokenMessage">EMustBeTokenMessage</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 17;
</code></pre>



<a name="0xb_bridge_EMustBeTokenMessage"></a>
<a name="0xb_bridge_CURRENT_VERSION"></a>



<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_EMustBeTokenMessage">EMustBeTokenMessage</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 17;
<pre><code><b>const</b> <a href="bridge.md#0xb_bridge_CURRENT_VERSION">CURRENT_VERSION</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 1;
</code></pre>


Expand Down Expand Up @@ -883,7 +883,7 @@ title: Module `0xb::bridge`
<b>let</b> <a href="message.md#0xb_message">message</a> = <a href="message.md#0xb_message_create_token_bridge_message">message::create_token_bridge_message</a>(
inner.chain_id,
bridge_seq_num,
address::to_bytes(ctx.sender()),
<a href="../sui-framework/address.md#0x2_address_to_bytes">address::to_bytes</a>(ctx.sender()),
target_chain,
target_address,
token_id,
Expand All @@ -908,7 +908,7 @@ title: Module `0xb::bridge`
<a href="bridge.md#0xb_bridge_TokenDepositedEvent">TokenDepositedEvent</a> {
seq_num: bridge_seq_num,
source_chain: inner.chain_id,
sender_address: address::to_bytes(ctx.sender()),
sender_address: <a href="../sui-framework/address.md#0x2_address_to_bytes">address::to_bytes</a>(ctx.sender()),
target_chain,
target_address,
token_type: token_id,
Expand Down Expand Up @@ -1323,7 +1323,7 @@ title: Module `0xb::bridge`
// extract token <a href="message.md#0xb_message">message</a>
<b>let</b> token_payload = record.<a href="message.md#0xb_message">message</a>.extract_token_bridge_payload();
// get owner <b>address</b>
<b>let</b> owner = address::from_bytes(token_payload.token_target_address());
<b>let</b> owner = <a href="../sui-framework/address.md#0x2_address_from_bytes">address::from_bytes</a>(token_payload.token_target_address());

// If already claimed, exit early
<b>if</b> (record.claimed) {
Expand Down
14 changes: 7 additions & 7 deletions crates/sui-framework/docs/bridge/committee.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ title: Module `0xb::committee`
The public key bytes of the bridge key
</dd>
<dt>
<code><a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a></code>
<code>voting_power: <a href="../move-stdlib/u64.md#0x1_u64">u64</a></code>
</dt>
<dd>
Voting power, values are voting power in the scale of 10000.
Expand Down Expand Up @@ -417,7 +417,7 @@ title: Module `0xb::committee`
// get <a href="committee.md#0xb_committee">committee</a> signature weight and check pubkey is part of the <a href="committee.md#0xb_committee">committee</a>
<b>let</b> member = &self.members[&pubkey];
<b>if</b> (!member.blocklisted) {
threshold = threshold + member.<a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>;
threshold = threshold + member.voting_power;
};
seen_pub_key.insert(pubkey);
i = i + 1;
Expand Down Expand Up @@ -554,15 +554,15 @@ title: Module `0xb::committee`
// Find <a href="../sui-system/validator.md#0x3_validator">validator</a> stake amount from system state

// Process registration <b>if</b> it's active <a href="../sui-system/validator.md#0x3_validator">validator</a>
<b>let</b> <a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a> = active_validator_voting_power.try_get(&registration.sui_address);
<b>if</b> (<a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>.is_some()) {
<b>let</b> <a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a> = <a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>.destroy_some();
stake_participation_percentage = stake_participation_percentage + <a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>;
<b>let</b> voting_power = active_validator_voting_power.try_get(&registration.sui_address);
<b>if</b> (voting_power.is_some()) {
<b>let</b> voting_power = voting_power.destroy_some();
stake_participation_percentage = stake_participation_percentage + voting_power;

<b>let</b> member = <a href="committee.md#0xb_committee_CommitteeMember">CommitteeMember</a> {
sui_address: registration.sui_address,
bridge_pubkey_bytes: registration.bridge_pubkey_bytes,
<a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a>: (<a href="../sui-system/voting_power.md#0x3_voting_power">voting_power</a> <b>as</b> <a href="../move-stdlib/u64.md#0x1_u64">u64</a>),
voting_power: (voting_power <b>as</b> <a href="../move-stdlib/u64.md#0x1_u64">u64</a>),
http_rest_url: registration.http_rest_url,
blocklisted: <b>false</b>,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework/docs/bridge/limiter.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ title: Module `0xb::limiter`


<pre><code><b>public</b>(<a href="../sui-framework/package.md#0x2_package">package</a>) <b>fun</b> <a href="limiter.md#0xb_limiter_new">new</a>(): <a href="limiter.md#0xb_limiter_TransferLimiter">TransferLimiter</a> {
// hardcoded limit for <a href="bridge.md#0xb_bridge">bridge</a> <a href="../sui-system/genesis.md#0x3_genesis">genesis</a>
// hardcoded limit for <a href="bridge.md#0xb_bridge">bridge</a> genesis
<a href="limiter.md#0xb_limiter_TransferLimiter">TransferLimiter</a> {
transfer_limits: <a href="limiter.md#0xb_limiter_initial_transfer_limits">initial_transfer_limits</a>(),
transfer_records: <a href="../sui-framework/vec_map.md#0x2_vec_map_empty">vec_map::empty</a>()
Expand Down
Loading

0 comments on commit 1cff85a

Please sign in to comment.