mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
perf(compile): code cache (#26528)
Adds a lazily created code cache to `deno compile` by default. The code cache is created on first run to a single file in the temp directory and is only written once. After it's been written, the code cache becomes read only on subsequent runs. Only the modules loaded during startup are cached (dynamic imports are not code cached). The code cache can be disabled by compiling with `--no-code-cache`.
This commit is contained in:
parent
3ba464dbc4
commit
dd4570ed85
14 changed files with 703 additions and 20 deletions
|
@ -2,20 +2,12 @@
|
|||
|
||||
use deno_core::ModuleSpecifier;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum CodeCacheType {
|
||||
EsModule,
|
||||
Script,
|
||||
}
|
||||
|
||||
impl CodeCacheType {
|
||||
pub fn as_str(&self) -> &str {
|
||||
match self {
|
||||
Self::EsModule => "esmodule",
|
||||
Self::Script => "script",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CodeCache: Send + Sync {
|
||||
fn get_sync(
|
||||
&self,
|
||||
|
@ -23,6 +15,7 @@ pub trait CodeCache: Send + Sync {
|
|||
code_cache_type: CodeCacheType,
|
||||
source_hash: u64,
|
||||
) -> Option<Vec<u8>>;
|
||||
|
||||
fn set_sync(
|
||||
&self,
|
||||
specifier: ModuleSpecifier,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue