Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- **Perf** `vp run` starts faster in workspaces whose tasks share cache `input` and `output` patterns: each distinct pattern is now parsed once instead of once for every task that uses it. In a 138-package workspace, this saves about 2 seconds of CPU on every run ([#887](https://github.com/voidzero-dev/vite-task/pull/887)).
- **Perf** When tasks miss the cache, `vp run` no longer waits for the disk after saving each task's result, so the run finishes sooner. If the computer loses power or the operating system crashes during `vp run`, the cache entries that the run saved can be lost, and those tasks run again next time instead of hitting the cache ([#871](https://github.com/voidzero-dev/vite-task/pull/871)).
- **Fixed** Running `vp run` in a package that sits inside a workspace folder but isn't listed in its `pnpm-workspace.yaml` `packages` or `package.json` `workspaces` now runs that package's own tasks, instead of treating the enclosing workspace as its root. When both configurations exist, `pnpm-workspace.yaml` takes precedence ([#859](https://github.com/voidzero-dev/vite-task/pull/859)).
- **Fixed** A mistyped or misplaced setting in a task now gets an error that names it. For example, `cache: { outputs: [...] }` now fails with an `unknown field` error that names `outputs` and lists the accepted settings, instead of `data did not match any variant of untagged enum UserTaskDefinition` ([vite-plus#2635](https://github.com/voidzero-dev/vite-plus/issues/2635), [#815](https://github.com/voidzero-dev/vite-task/pull/815)).
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ futures = "0.3.31"
futures-util = "0.3.31"
globset = "0.4.18"
getrandom = "0.4.2"
hashbrown = { version = "0.16.1", default-features = false, features = ["inline-more"] }
itoa = "1.0.17"
jsonc-parser = "0.32.0"
libc = "0.2.185"
Expand Down
1 change: 1 addition & 0 deletions crates/vt_graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version.workspace = true
[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
hashbrown = { workspace = true }
wincode = { workspace = true, features = ["derive"] }
petgraph = { workspace = true }
rustc-hash = { workspace = true }
Expand Down
234 changes: 168 additions & 66 deletions crates/vt_graph/src/config/mod.rs

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion crates/vt_graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod specifier;
use std::{convert::Infallible, sync::Arc};

use config::{
ResolvedGlobalCacheConfig, ResolvedTaskConfig, UserRunConfig, UserTaskConfig,
GlobResolver, ResolvedGlobalCacheConfig, ResolvedTaskConfig, UserRunConfig, UserTaskConfig,
UserTaskDefinition, user::TopLevelCacheFieldsCollector,
};
use petgraph::{
Expand Down Expand Up @@ -319,6 +319,7 @@ impl IndexedTaskGraph {
let resolved_global_cache = ResolvedGlobalCacheConfig::resolve_from(root_cache.as_ref());

let mut top_level_cache_fields = TopLevelCacheFieldsCollector::default();
let glob_resolver = GlobResolver::default();

// Second pass: create task nodes (cache is NOT applied here; it's applied at plan time)
for (package_index, package_dir, user_config) in package_configs {
Expand Down Expand Up @@ -369,6 +370,7 @@ impl IndexedTaskGraph {
task_user_config,
&package_dir,
&workspace_root.path,
&glob_resolver,
)
.map_err(|err| TaskGraphLoadError::ResolveConfigError {
error: err,
Expand Down Expand Up @@ -402,6 +404,7 @@ impl IndexedTaskGraph {
&package_dir,
package_json_script,
&workspace_root.path,
&glob_resolver,
)
.map_err(|err| TaskGraphLoadError::ResolveConfigError {
error: err,
Expand Down
16 changes: 14 additions & 2 deletions crates/vt_plan/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::{env::JoinPathsError, ffi::OsStr, ops::Range, sync::Arc};
use std::{env::JoinPathsError, ffi::OsStr, ops::Range, rc::Rc, sync::Arc};

use rustc_hash::FxHashMap;
use vt_casefold::EnvName;
use vt_graph::{
IndexedTaskGraph, TaskNodeIndex, config::ResolvedGlobalCacheConfig, query::TaskQuery,
IndexedTaskGraph, TaskNodeIndex,
config::{GlobResolver, ResolvedGlobalCacheConfig},
query::TaskQuery,
};
use vt_path::AbsolutePath;
use vt_str::Str;
Expand Down Expand Up @@ -51,6 +53,10 @@ pub struct PlanContext<'a> {

indexed_task_graph: &'a IndexedTaskGraph,

/// Shared with every nested context, so each glob in synthetic commands' cache configs is
/// parsed once per plan.
glob_resolver: Rc<GlobResolver>,

/// Final resolved global cache config, combining the graph's config with any CLI override.
resolved_global_cache: ResolvedGlobalCacheConfig,

Expand Down Expand Up @@ -91,6 +97,7 @@ impl<'a> PlanContext<'a> {
callbacks,
task_call_stack: Vec::new(),
indexed_task_graph,
glob_resolver: Rc::default(),
extra_args: Arc::default(),
resolved_global_cache,
resolved_remote_cache: None,
Expand Down Expand Up @@ -123,6 +130,10 @@ impl<'a> PlanContext<'a> {
self.workspace_path
}

pub fn glob_resolver(&self) -> &GlobResolver {
&self.glob_resolver
}

/// Push a new frame onto the task call stack.
pub fn push_stack_frame(&mut self, task_node_index: TaskNodeIndex, command_span: Range<usize>) {
self.task_call_stack.push((task_node_index, command_span));
Expand Down Expand Up @@ -198,6 +209,7 @@ impl<'a> PlanContext<'a> {
callbacks: self.callbacks,
task_call_stack: self.task_call_stack.clone(),
indexed_task_graph: self.indexed_task_graph,
glob_resolver: Rc::clone(&self.glob_resolver),
extra_args: Arc::clone(&self.extra_args),
resolved_global_cache: self.resolved_global_cache.clone(),
resolved_remote_cache: self.resolved_remote_cache.clone(),
Expand Down
3 changes: 2 additions & 1 deletion crates/vt_plan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use plan_request::{CacheOverride, PlanRequest, QueryPlanRequest, SyntheticPlanRe
use rustc_hash::FxHashMap;
use serde::{Serialize, ser::SerializeMap as _};
use vt_casefold::EnvName;
use vt_graph::{TaskGraphLoadError, display::TaskDisplay};
use vt_graph::{TaskGraphLoadError, config::GlobResolver, display::TaskDisplay};
use vt_path::AbsolutePath;
use vt_str::Str;

Expand Down Expand Up @@ -269,5 +269,6 @@ pub fn plan_synthetic(
cwd,
ParentCacheConfig::None,
None,
&GlobResolver::default(),
)
}
22 changes: 19 additions & 3 deletions crates/vt_plan/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use vt_casefold::EnvName;
use vt_graph::{
TaskNodeIndex, TaskSource,
config::{
CacheConfig, EnabledCacheConfig, ResolvedGlobConfig, ResolvedGlobalCacheConfig,
ResolvedTaskOptions,
CacheConfig, EnabledCacheConfig, GlobResolver, ResolvedGlobConfig,
ResolvedGlobalCacheConfig, ResolvedTaskOptions,
user::{UserCacheConfig, UserTaskOptions},
},
query::TaskQuery,
Expand Down Expand Up @@ -307,6 +307,7 @@ async fn plan_task_as_execution_node(
package_path,
parent_cache_config,
context.resolved_remote_cache(),
context.glob_resolver(),
)?;
ExecutionItemKind::Leaf(LeafExecutionKind::Spawn(spawn_execution))
}
Expand Down Expand Up @@ -471,6 +472,7 @@ fn resolve_synthetic_cache_config(
synthetic_cache_config: UserCacheConfig,
package_dir: &AbsolutePath,
workspace_path: &AbsolutePath,
glob_resolver: &GlobResolver,
) -> Result<Option<CacheConfig>, Error> {
match parent {
ParentCacheConfig::None => {
Expand All @@ -483,6 +485,7 @@ fn resolve_synthetic_cache_config(
},
&package_dir.into(),
workspace_path,
glob_resolver,
)
.map_err(Error::ResolveTaskConfig)?
.cache_config)
Expand All @@ -508,6 +511,7 @@ fn resolve_synthetic_cache_config(
Some(&input),
package_dir,
workspace_path,
glob_resolver,
)
.map_err(Error::ResolveTaskConfig)?;
// Merge globs but preserve the parent's includes_auto —
Expand All @@ -528,6 +532,7 @@ fn resolve_synthetic_cache_config(
Some(&output),
package_dir,
workspace_path,
glob_resolver,
)
.map_err(Error::ResolveTaskConfig)?;
parent_config
Expand Down Expand Up @@ -560,6 +565,7 @@ pub fn plan_synthetic_request(
package_dir: &AbsolutePath,
parent_cache_config: ParentCacheConfig,
resolved_remote_cache: Option<&ResolvedRemoteCacheConfig>,
glob_resolver: &GlobResolver,
) -> Result<SpawnExecution, Error> {
let SyntheticPlanRequest { program, args, cache_config, envs } = synthetic_plan_request;

Expand All @@ -571,6 +577,7 @@ pub fn plan_synthetic_request(
cache_config,
package_dir,
workspace_path,
glob_resolver,
)?;
let resolved_options =
ResolvedTaskOptions { cwd: Arc::clone(cwd), cache_config: resolved_cache_config };
Expand Down Expand Up @@ -955,7 +962,7 @@ mod tests {

use rustc_hash::FxHashSet;
use vt_graph::config::{
CacheConfig, EnabledCacheConfig, EnvConfig, ResolvedGlobConfig,
CacheConfig, EnabledCacheConfig, EnvConfig, GlobResolver, ResolvedGlobConfig,
user::{UserCacheConfig, UserInputEntry},
};
use vt_path::AbsolutePathBuf;
Expand Down Expand Up @@ -1016,6 +1023,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand All @@ -1039,6 +1047,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand All @@ -1062,6 +1071,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand Down Expand Up @@ -1091,6 +1101,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand Down Expand Up @@ -1118,6 +1129,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand All @@ -1143,6 +1155,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap();
assert!(result.is_none());
Expand All @@ -1157,6 +1170,7 @@ mod tests {
UserCacheConfig::disabled(),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap();
assert!(result.is_none());
Expand All @@ -1177,6 +1191,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand All @@ -1198,6 +1213,7 @@ mod tests {
}),
&pkg,
&ws,
&GlobResolver::default(),
)
.unwrap()
.unwrap();
Expand Down
Loading