Skip to content

Commit

Permalink
[move-ide] Use pre-compiled dependencies to speed up compilation in t…
Browse files Browse the repository at this point in the history
…he IDE (MystenLabs#16580)

## Description 

This PR adds support for using pre-compiled dependencies in the IDE to
cut down compilation time.

## Test Plan 

Verified that it indeed speeds up compilation.
  • Loading branch information
awelc authored Mar 13, 2024
1 parent 020ef08 commit f0240a5
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 177 deletions.
4 changes: 2 additions & 2 deletions crates/sui-graphql-e2e-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(unused_imports)]
#![allow(unused_variables)]
use std::path::Path;
use std::{path::Path, sync::Arc};
use sui_transactional_test_runner::{
run_test_impl,
test_adapter::{SuiTestAdapter, PRE_COMPILED},
Expand All @@ -16,7 +16,7 @@ datatest_stable::harness!(run_test, TEST_DIR, r".*\.(mvir|move)$");
#[cfg_attr(msim, msim::main)]
async fn run_test(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
if cfg!(feature = "pg_integration") {
run_test_impl::<SuiTestAdapter>(path, Some(&*PRE_COMPILED)).await?;
run_test_impl::<SuiTestAdapter>(path, Some(Arc::new(PRE_COMPILED.clone()))).await?;
}
Ok(())
}
2 changes: 1 addition & 1 deletion crates/sui-transactional-test-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub async fn run_test(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
let (_guard, _filter_handle) = telemetry_subscribers::TelemetryConfig::new()
.with_env()
.init();
run_test_impl::<SuiTestAdapter>(path, Some(&*PRE_COMPILED)).await?;
run_test_impl::<SuiTestAdapter>(path, Some(std::sync::Arc::new(PRE_COMPILED.clone()))).await?;
Ok(())
}

Expand Down
18 changes: 9 additions & 9 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ const GAS_FOR_TESTING: u64 = GAS_VALUE_FOR_TESTING;

const DEFAULT_CHAIN_START_TIMESTAMP: u64 = 0;

pub struct SuiTestAdapter<'a> {
pub(crate) compiled_state: CompiledState<'a>,
pub struct SuiTestAdapter {
pub(crate) compiled_state: CompiledState,
/// For upgrades: maps an upgraded package name to the original package name.
package_upgrade_mapping: BTreeMap<Symbol, Symbol>,
accounts: BTreeMap<String, TestAccount>,
Expand Down Expand Up @@ -168,14 +168,14 @@ struct TxnSummary {
}

#[async_trait]
impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
impl<'a> MoveTestAdapter<'a> for SuiTestAdapter {
type ExtraPublishArgs = SuiPublishArgs;
type ExtraRunArgs = SuiRunArgs;
type ExtraInitArgs = SuiInitArgs;
type ExtraValueArgs = SuiExtraValueArgs;
type Subcommand = SuiSubcommand<Self::ExtraValueArgs, Self::ExtraRunArgs>;

fn compiled_state(&mut self) -> &mut CompiledState<'a> {
fn compiled_state(&mut self) -> &mut CompiledState {
&mut self.compiled_state
}

Expand All @@ -190,7 +190,7 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
}
async fn init(
default_syntax: SyntaxChoice,
pre_compiled_deps: Option<&'a FullyCompiledProgram>,
pre_compiled_deps: Option<Arc<FullyCompiledProgram>>,
task_opt: Option<
move_transactional_test_runner::tasks::TaskInput<(
move_transactional_test_runner::tasks::InitCommand,
Expand Down Expand Up @@ -1121,7 +1121,7 @@ fn merge_output(left: Option<String>, right: Option<String>) -> Option<String> {
}
}

impl<'a> SuiTestAdapter<'a> {
impl<'a> SuiTestAdapter {
pub fn is_simulator(&self) -> bool {
self.is_simulator
}
Expand Down Expand Up @@ -1783,7 +1783,7 @@ impl<'a> SuiTestAdapter<'a> {
}
}

impl<'a> GetModule for &'a SuiTestAdapter<'_> {
impl<'a> GetModule for &'a SuiTestAdapter {
type Error = anyhow::Error;

type Item = &'a CompiledModule;
Expand Down Expand Up @@ -2195,7 +2195,7 @@ async fn update_named_address_mapping(
}
}

impl ObjectStore for SuiTestAdapter<'_> {
impl ObjectStore for SuiTestAdapter {
fn get_object(
&self,
object_id: &ObjectID,
Expand All @@ -2212,7 +2212,7 @@ impl ObjectStore for SuiTestAdapter<'_> {
}
}

impl ReadStore for SuiTestAdapter<'_> {
impl ReadStore for SuiTestAdapter {
fn get_committee(
&self,
epoch: sui_types::committee::EpochId,
Expand Down
1 change: 1 addition & 0 deletions external-crates/move/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions external-crates/move/crates/move-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ codespan-reporting.workspace = true
derivative.workspace = true
dunce.workspace = true
im.workspace = true
itertools.workspace = true
lsp-server.workspace = true
lsp-types.workspace = true
serde_json.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ fn main() {
// to be available right after the client is initialized.
if let Some(uri) = initialize_params.root_uri {
if let Some(p) = symbols::SymbolicatorRunner::root_dir(&uri.to_file_path().unwrap()) {
if let Ok((Some(new_symbols), _)) =
symbols::get_symbols(ide_files_root.clone(), p.as_path(), lint)
{
if let Ok((Some(new_symbols), _)) = symbols::get_symbols(
&mut BTreeMap::new(),
ide_files_root.clone(),
p.as_path(),
lint,
) {
let mut old_symbols = symbols.lock().unwrap();
(*old_symbols).merge(new_symbols);
}
Expand Down
Loading

0 comments on commit f0240a5

Please sign in to comment.