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: reduce the number of debug impls in release builds #28417

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 17 additions & 5 deletions cli/args/deno_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,31 @@ fn check_warn_tsconfig(
}
}

#[derive(Debug)]
#[cfg_attr(any(test, debug_assertions), derive(Debug))]
pub struct TranspileAndEmitOptions {
pub transpile: deno_ast::TranspileOptions,
pub emit: deno_ast::EmitOptions,
// stored ahead of time so we don't have to recompute this a lot
pub pre_computed_hash: u64,
}

#[derive(Debug, Default)]
#[derive(Default)]
#[cfg_attr(any(test, debug_assertions), derive(Debug))]
struct LoggedWarnings {
experimental_decorators: AtomicFlag,
folders: dashmap::DashSet<Url>,
}

#[derive(Default, Debug)]
#[derive(Default)]
#[cfg_attr(any(test, debug_assertions), derive(Debug))]
struct MemoizedValues {
deno_window_check_tsconfig: OnceCell<Arc<TsConfig>>,
deno_worker_check_tsconfig: OnceCell<Arc<TsConfig>>,
emit_tsconfig: OnceCell<Arc<TsConfig>>,
transpile_options: OnceCell<Arc<TranspileAndEmitOptions>>,
}

#[derive(Debug)]
#[cfg_attr(any(test, debug_assertions), derive(Debug))]
pub struct TsConfigFolderInfo {
pub dir: WorkspaceDirectory,
logged_warnings: Arc<LoggedWarnings>,
Expand Down Expand Up @@ -228,11 +230,21 @@ impl TsConfigFolderInfo {
}
}

#[derive(Debug)]
pub struct TsConfigResolver {
map: FolderScopedMap<TsConfigFolderInfo>,
}

impl std::fmt::Debug for TsConfigResolver {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut f = f.debug_struct("TsConfigResolver");
#[cfg(any(test, debug_assertions))]
{
f.field("map", &self.map);
}
f.finish()
}
}

impl TsConfigResolver {
pub fn from_workspace(workspace: &Arc<Workspace>) -> Self {
// separate the workspace into directories that have a tsconfig
Expand Down
Loading