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

perf: static bootstrap options in snapshot #21213

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
stuff
  • Loading branch information
littledivy committed Nov 15, 2023
commit 01e269f7338e21e07af2382cfb30b75b9f5313a4
4 changes: 0 additions & 4 deletions cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ impl CliMainWorkerFactory {
location: shared.options.location.clone(),
no_color: !colors::use_color(),
is_tty: colors::is_tty(),
runtime_version: version::deno().to_string(),
ts_version: version::TYPESCRIPT.to_string(),
unstable: shared.options.unstable,
unstable_features,
user_agent: version::get_user_agent().to_string(),
Expand Down Expand Up @@ -755,8 +753,6 @@ fn create_web_worker_callback(
location: Some(args.main_module.clone()),
no_color: !colors::use_color(),
is_tty: colors::is_tty(),
runtime_version: version::deno().to_string(),
ts_version: version::TYPESCRIPT.to_string(),
unstable: shared.options.unstable,
unstable_features,
user_agent: version::get_user_agent().to_string(),
Expand Down
25 changes: 12 additions & 13 deletions runtime/js/99_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,13 @@ function bootstrapMainRuntime(runtimeOptions) {
}
const nodeBootstrap = globalThis.nodeBootstrap;

// location, unstable, node module dir
const {
1: location_,
3: unstableFlag,
4: unstableFeatures,
7: inspectFlag,
9: hasNodeModulesDir,
10: maybeBinaryNpmCommandName,
0: location_,
1: unstableFlag,
2: unstableFeatures,
3: inspectFlag,
5: hasNodeModulesDir,
6: maybeBinaryNpmCommandName,
} = runtimeOptions;

performance.setTimeOrigin(DateNow());
Expand Down Expand Up @@ -587,12 +586,12 @@ function bootstrapWorkerRuntime(
const nodeBootstrap = globalThis.nodeBootstrap;

const {
1: location_,
3: unstableFlag,
4: unstableFeatures,
8: enableTestingFeaturesFlag,
9: hasNodeModulesDir,
10: maybeBinaryNpmCommandName,
0: location_,
1: unstableFlag,
2: unstableFeatures,
4: enableTestingFeaturesFlag,
5: hasNodeModulesDir,
6: maybeBinaryNpmCommandName,
} = runtimeOptions;

performance.setTimeOrigin(DateNow());
Expand Down
20 changes: 1 addition & 19 deletions runtime/worker_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ pub struct BootstrapOptions {
/// Sets `Deno.noColor` in JS runtime.
pub no_color: bool,
pub is_tty: bool,
/// Sets `Deno.version.deno` in JS runtime.
pub runtime_version: String,
/// Sets `Deno.version.typescript` in JS runtime.
pub ts_version: String,
// --unstable flag, deprecated
pub unstable: bool,
// --unstable-* flags
Expand All @@ -71,19 +67,17 @@ impl Default for BootstrapOptions {
.map(|p| p.get())
.unwrap_or(1);

let runtime_version = env!("CARGO_PKG_VERSION").into();
let runtime_version = env!("CARGO_PKG_VERSION");
let user_agent = format!("Deno/{runtime_version}");

Self {
runtime_version,
user_agent,
cpu_count,
no_color: !colors::use_color(),
is_tty: colors::is_tty(),
enable_op_summary_metrics: Default::default(),
enable_testing_features: Default::default(),
log_level: Default::default(),
ts_version: Default::default(),
locale: "en".to_string(),
location: Default::default(),
unstable: Default::default(),
Expand All @@ -107,20 +101,12 @@ impl Default for BootstrapOptions {
/// Keep this in sync with `99_main.js`.
#[derive(Serialize)]
struct BootstrapV8<'a>(
// runtime_version
&'a str,
// location
Option<&'a str>,
// ts_version
&'a str,
// unstable
bool,
// granular unstable flags
&'a [i32],
// env!("TARGET")
&'a str,
// v8_version
&'a str,
// inspect
bool,
// enable_testing_features
Expand All @@ -141,13 +127,9 @@ impl BootstrapOptions {
let ser = deno_core::serde_v8::Serializer::new(&scope);

let bootstrap = BootstrapV8(
&self.runtime_version,
self.location.as_ref().map(|l| l.as_str()),
&self.ts_version,
self.unstable,
self.unstable_features.as_ref(),
env!("TARGET"),
deno_core::v8_version(),
self.inspect,
self.enable_testing_features,
self.has_node_modules_dir,
Expand Down