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

feat: emit files on demand and fix racy emit #15220

Merged
merged 32 commits into from
Jul 19, 2022

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jul 17, 2022

This is an alternative to #15198 (branched from it). Instead of using an sqlite database it keeps things pretty much the same, but adds an additional source hash to the "versions" file. So it's somewhat more non-breaking.

I feel a little bit better about this PR because it's non-breaking and we don't depend on sqlite as much.

Closes #13302
Closes #15124

.filter(|p| p.is_file());
Some(CacheInfo {
local: Some(local),
emit,
map,
map: None,
Copy link
Member Author

Choose a reason for hiding this comment

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

We haven't written out a map file for a while.

@dsherret dsherret changed the title feat: emit files on demand and fix racy emit (alternative) feat: emit files on demand and fix racy emit Jul 18, 2022
#[derive(Debug, Clone, PartialEq)]
pub struct SpecifierEmitCacheData {
#[derive(Debug, Deserialize, Serialize)]
struct EmitMetadata {
pub source_hash: String,
Copy link
Member Author

Choose a reason for hiding this comment

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

This changed from version_hash (diff is not clear because I moved this struct here). It's using a faster xxHash now so worth it to rename I think.

Also, if someone upgrades deno, uses it a bit, then downgrades, older versions of deno reading this file will re-emit.

Copy link
Member

Choose a reason for hiding this comment

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

Add as a docstring that Deno version mismatch will cause to skip the cache?

@@ -40,6 +56,65 @@ impl CliModuleLoader {
ps,
})
}

fn load_prepared_module(
Copy link
Member Author

Choose a reason for hiding this comment

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

I had initially moved this code from proc_state here in the previous PR because I couldn't store an sqlite connection in an Arc, but I kind of like it here better anyway, so I left this here for this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I agree it makes more sense to have this method on CliModuleLoader 👍

@dsherret dsherret requested a review from kitsonk July 18, 2022 15:30
@dsherret dsherret marked this pull request as ready for review July 18, 2022 15:30
@dsherret dsherret added this to the 1.24 milestone Jul 18, 2022
#[derive(Debug, Clone, PartialEq)]
pub struct SpecifierEmitCacheData {
#[derive(Debug, Deserialize, Serialize)]
struct EmitMetadata {
pub source_hash: String,
Copy link
Member

Choose a reason for hiding this comment

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

Add as a docstring that Deno version mismatch will cause to skip the cache?

cli/cache/emit.rs Outdated Show resolved Hide resolved
@@ -40,6 +56,65 @@ impl CliModuleLoader {
ps,
})
}

fn load_prepared_module(
Copy link
Member

Choose a reason for hiding this comment

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

I agree it makes more sense to have this method on CliModuleLoader 👍

cli/module_loader.rs Outdated Show resolved Hide resolved
Comment on lines +151 to +158
// we need the code with the source map in order for
// it to work with --inspect or --inspect-brk
code_source.code
} else {
// reduce memory and throw away the source map
// because we don't need it
code_without_source_map(code_source.code)
};
Copy link
Member

Choose a reason for hiding this comment

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

Clever 👍

Ok(ProcState(Arc::new(Inner {
dir,
coverage_dir,
options: cli_options,
emit_cache,
emit_options_hash: FastInsecureHasher::new()
// todo(dsherret): use hash of emit options instead as it's more specific
Copy link
Member

Choose a reason for hiding this comment

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

Can you address this TODO before landing?

Copy link
Member Author

Choose a reason for hiding this comment

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

It needs to be addressed in deno_ast I think. I opened denoland/deno_ast#105

cli/tests/integration/info_tests.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM

@dsherret dsherret merged commit 0ab262b into denoland:main Jul 19, 2022
@dsherret dsherret deleted the alternative_lazy_emit branch July 19, 2022 15:58
@dsherret
Copy link
Member Author

Ehh... I just realized I categorized this as a feat when it's not really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants