summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-02-27 08:05:57 -0700
committerGitHub <noreply@github.com>2024-02-27 08:05:57 -0700
commit47c2a63d872886ae1d0576f3cbf630151c8ff129 (patch)
tree85ba7273598467de211fab37c4cb6dcbd87fc889 /cli
parentf1a691274e59d3f6a1aad19d1aec02a0ffaa51d2 (diff)
chore: bump deno_core (#22596)
Migrations: - snapshot code updated - runtime stats API tweaks
Diffstat (limited to 'cli')
-rw-r--r--cli/build.rs44
-rw-r--r--cli/js.rs5
-rw-r--r--cli/tools/test/fmt.rs20
-rw-r--r--cli/tools/test/mod.rs16
-rw-r--r--cli/tsc/mod.rs5
5 files changed, 41 insertions, 49 deletions
diff --git a/cli/build.rs b/cli/build.rs
index 1f941142c..0a599b03b 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -15,6 +15,7 @@ mod ts {
use deno_runtime::deno_node::SUPPORTED_BUILTIN_NODE_MODULES;
use serde::Serialize;
use std::collections::HashMap;
+ use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
@@ -266,10 +267,6 @@ mod ts {
)
.unwrap();
- let snapshot_to_file = SnapshotFileSerializer::new(
- std::fs::File::create(snapshot_path).unwrap(),
- );
-
let output = create_snapshot(
CreateSnapshotOptions {
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
@@ -279,33 +276,30 @@ mod ts {
build_libs,
path_dts,
)],
- // NOTE(bartlomieju): Compressing the TSC snapshot in debug build took
- // ~45s on M1 MacBook Pro; without compression it took ~1s.
- // Thus we're not not using compressed snapshot, trading off
- // a lot of build time for some startup time in debug build.
- #[cfg(debug_assertions)]
- serializer: Box::new(snapshot_to_file),
-
- #[cfg(not(debug_assertions))]
- serializer: Box::new(SnapshotBulkCompressingSerializer::new(
- snapshot_to_file,
- |snapshot| {
- eprintln!("Compressing TSC snapshot...");
- let mut vec = Vec::with_capacity(snapshot.len());
- vec.extend((snapshot.len() as u32).to_le_bytes());
- vec.extend_from_slice(
- &zstd::bulk::compress(&snapshot, 22)
- .expect("snapshot compression failed"),
- );
- Ok(vec)
- },
- )),
with_runtime_cb: None,
skip_op_registration: false,
},
None,
)
.unwrap();
+
+ // NOTE(bartlomieju): Compressing the TSC snapshot in debug build took
+ // ~45s on M1 MacBook Pro; without compression it took ~1s.
+ // Thus we're not not using compressed snapshot, trading off
+ // a lot of build time for some startup time in debug build.
+ let mut file = std::fs::File::create(snapshot_path).unwrap();
+ if cfg!(debug_assertions) {
+ file.write_all(&output.output).unwrap();
+ } else {
+ let mut vec = Vec::with_capacity(output.output.len());
+ vec.extend((output.output.len() as u32).to_le_bytes());
+ vec.extend_from_slice(
+ &zstd::bulk::compress(&output.output, 22)
+ .expect("snapshot compression failed"),
+ );
+ file.write_all(&vec).unwrap();
+ }
+
for path in output.files_loaded_during_snapshot {
println!("cargo:rerun-if-changed={}", path.display());
}
diff --git a/cli/js.rs b/cli/js.rs
index 4d75090d6..552f3842d 100644
--- a/cli/js.rs
+++ b/cli/js.rs
@@ -1,17 +1,16 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-use deno_core::Snapshot;
use log::debug;
#[cfg(not(feature = "__runtime_js_sources"))]
static CLI_SNAPSHOT: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
-pub fn deno_isolate_init() -> Option<Snapshot> {
+pub fn deno_isolate_init() -> Option<&'static [u8]> {
debug!("Deno isolate init with snapshots.");
#[cfg(not(feature = "__runtime_js_sources"))]
{
- Some(Snapshot::Static(CLI_SNAPSHOT))
+ Some(CLI_SNAPSHOT)
}
#[cfg(feature = "__runtime_js_sources")]
{
diff --git a/cli/tools/test/fmt.rs b/cli/tools/test/fmt.rs
index fa2362ea1..fe2007025 100644
--- a/cli/tools/test/fmt.rs
+++ b/cli/tools/test/fmt.rs
@@ -2,6 +2,7 @@
use deno_core::stats::RuntimeActivity;
use deno_core::stats::RuntimeActivityDiff;
+use deno_core::stats::RuntimeActivityTrace;
use deno_core::stats::RuntimeActivityType;
use phf::phf_map;
use std::borrow::Cow;
@@ -165,16 +166,19 @@ fn format_sanitizer_accum(
fn format_sanitizer_accum_item(
activity: RuntimeActivity,
-) -> (RuntimeActivityType, Cow<'static, str>, Option<String>) {
+) -> (
+ RuntimeActivityType,
+ Cow<'static, str>,
+ Option<RuntimeActivityTrace>,
+) {
let activity_type = activity.activity();
match activity {
- // TODO(mmastrac): OpCallTrace needs to be Eq
- RuntimeActivity::AsyncOp(_, name, trace) => {
- (activity_type, name.into(), trace.map(|x| x.to_string()))
+ RuntimeActivity::AsyncOp(_, trace, name) => {
+ (activity_type, name.into(), trace)
}
- RuntimeActivity::Interval(_) => (activity_type, "".into(), None),
- RuntimeActivity::Resource(_, name) => (activity_type, name.into(), None),
- RuntimeActivity::Timer(_) => (activity_type, "".into(), None),
+ RuntimeActivity::Interval(..) => (activity_type, "".into(), None),
+ RuntimeActivity::Resource(.., name) => (activity_type, name.into(), None),
+ RuntimeActivity::Timer(..) => (activity_type, "".into(), None),
}
}
@@ -354,7 +358,7 @@ mod tests {
// https://github.com/denoland/deno/issues/13729
// https://github.com/denoland/deno/issues/13938
- leak_format_test!(op_unknown, true, [RuntimeActivity::AsyncOp(0, "op_unknown", None)],
+ leak_format_test!(op_unknown, true, [RuntimeActivity::AsyncOp(0, None, "op_unknown")],
" - An async call to op_unknown was started in this test, but never completed.\n\
To get more details where ops were leaked, run again with --trace-ops flag.\n");
}
diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs
index e98df4671..f7a7aed06 100644
--- a/cli/tools/test/mod.rs
+++ b/cli/tools/test/mod.rs
@@ -518,7 +518,7 @@ async fn test_specifier_inner(
if options.trace_ops {
worker.execute_script_static(
located_script_name!(),
- "Deno[Deno.internal].core.setOpCallTracingEnabled(true);",
+ "Deno[Deno.internal].core.setLeakTracingEnabled(true);",
)?;
}
@@ -740,7 +740,7 @@ fn preprocess_timer_activity(activities: &mut Vec<RuntimeActivity>) {
// First, search for any timer resources which will indicate that we have an interval leak
activities.retain(|activity| {
- if let RuntimeActivity::Resource(_, name) = activity {
+ if let RuntimeActivity::Resource(.., name) = activity {
if name == "timer" {
timer_resource_leaked = true;
return false;
@@ -753,7 +753,7 @@ fn preprocess_timer_activity(activities: &mut Vec<RuntimeActivity>) {
// them.
if !timer_resource_leaked {
activities.retain(|activity| {
- if let RuntimeActivity::AsyncOp(_, op, _) = activity {
+ if let RuntimeActivity::AsyncOp(.., op) = activity {
*op != "op_sleep_interval"
} else {
true
@@ -775,7 +775,7 @@ async fn wait_for_activity_to_stabilize(
let mut diff = RuntimeActivityStats::diff(&before, &after);
preprocess_timer_activity(&mut diff.appeared);
preprocess_timer_activity(&mut diff.disappeared);
- if diff.appeared.is_empty() && diff.disappeared.is_empty() {
+ if diff.is_empty() {
// No activity, so we return early
return Ok(None);
}
@@ -792,7 +792,7 @@ async fn wait_for_activity_to_stabilize(
diff = RuntimeActivityStats::diff(&before, &after);
preprocess_timer_activity(&mut diff.appeared);
preprocess_timer_activity(&mut diff.disappeared);
- if diff.appeared.is_empty() && diff.disappeared.is_empty() {
+ if diff.is_empty() {
return Ok(None);
}
}
@@ -814,11 +814,7 @@ async fn wait_for_activity_to_stabilize(
.retain(|activity| !matches!(activity, RuntimeActivity::Resource(..)));
}
- Ok(if diff.appeared.is_empty() && diff.disappeared.is_empty() {
- None
- } else {
- Some(diff)
- })
+ Ok(if diff.is_empty() { None } else { Some(diff) })
}
fn extract_files_from_regex_blocks(
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs
index 56755b518..e2e11e440 100644
--- a/cli/tsc/mod.rs
+++ b/cli/tsc/mod.rs
@@ -26,7 +26,6 @@ use deno_core::JsRuntime;
use deno_core::ModuleSpecifier;
use deno_core::OpState;
use deno_core::RuntimeOptions;
-use deno_core::Snapshot;
use deno_graph::GraphKind;
use deno_graph::Module;
use deno_graph::ModuleGraph;
@@ -140,8 +139,8 @@ fn get_asset_texts_from_new_runtime() -> Result<Vec<AssetText>, AnyError> {
Ok(serde_v8::from_v8::<Vec<AssetText>>(scope, local)?)
}
-pub fn compiler_snapshot() -> Snapshot {
- Snapshot::Static(&COMPILER_SNAPSHOT)
+pub fn compiler_snapshot() -> &'static [u8] {
+ &COMPILER_SNAPSHOT
}
macro_rules! inc {