-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(core): optimize daemon output glob matching #27775
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit e70bbbd. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
@@ -13,6 +13,7 @@ import { | |||
} from '../../tasks-runner/utils'; | |||
import { updateJson } from '../../generators/utils/json'; | |||
import { PackageJson } from '../../utils/package-json'; | |||
import { getTransformableOutputs } from 'nx/src/native'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relative import
let root_path = directory.join(&root); | ||
let glob_set = build_glob_set(&patterns)?; | ||
trace!("walking directory: {:?}", root_path); | ||
println!("walking directory: {:?}", root_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
println!("file: {}", &file.normalized_path); | ||
println!("matches: {}", glob_set.is_match(&file.normalized_path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
|
||
files.extend(found_paths); | ||
files.extend(found_paths); | ||
} | ||
} | ||
|
||
if !directories.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the multi-threaded walker below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this some other time.
packages/nx/src/native/glob.rs
Outdated
pub(crate) use glob_transform::partition_glob; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never got used?
while let Some(group) = remove_first(&mut groups) { | ||
if group.is_empty() { | ||
continue; | ||
} | ||
match &group[0] { | ||
GlobGroup::NonSpecial(value) => { | ||
if !contains_glob_pattern(&value) && pattern_segments.is_empty() { | ||
leading_dir_segments.push(value.to_string()); | ||
} else { | ||
pattern_segments.push(group); | ||
} | ||
} | ||
_ => { | ||
pattern_segments.push(group); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is written weirdly... can we not go through it as an iter
?
} | ||
|
||
export function transformLegacyOutputs( | ||
projectRoot: string, | ||
error: InvalidOutputsError | ||
outputs: string[], | ||
transformableOutputs: Set<string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we determine what is transformable here in this function rather than passing it in?
632ad9a
to
1c3b07d
Compare
@@ -291,7 +291,7 @@ function normalizeOutputPath(projectRoot: string): string | undefined { | |||
if (projectRoot === '.') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this if
anymore?
@@ -107,6 +113,33 @@ fn build_segment( | |||
} | |||
} | |||
|
|||
pub fn partition_glob(glob: &str) -> (String, Vec<String>) { | |||
let (negated, groups) = parse_glob(glob).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a Result
and use ?
here.
let (negated, groups) = parse_glob(glob).unwrap(); | |
let (negated, groups) = parse_glob(glob)?; |
let mut leading_dir_segments: Vec<String> = vec![]; | ||
let mut pattern_segments = vec![]; | ||
groups | ||
.into_iter() | ||
.filter(|group| !group.is_empty()) | ||
.for_each(|group| match &group[0] { | ||
GlobGroup::NonSpecial(value) => { | ||
if !contains_glob_pattern(&value) && pattern_segments.is_empty() { | ||
leading_dir_segments.push(value.to_string()); | ||
} else { | ||
pattern_segments.push(group); | ||
} | ||
} | ||
_ => { | ||
pattern_segments.push(group); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use .partition_map
?
#[test] | ||
fn should_partition_glob_with_leading_dirs_and_no_patterns() { | ||
let (leading_dirs, globs) = super::partition_glob("dist/app/"); | ||
assert_eq!(leading_dirs, "dist/app"); | ||
assert_eq!(globs, [] as [String; 0]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test with something like... dist/app/**/something/**/*.js
This should be dist/app
| **/something/**/*.js
.
debda00
to
c453042
Compare
Failed to publish a PR release of this pull request, triggered by @FrozenPandaz. |
|
||
files.extend(found_paths); | ||
files.extend(found_paths); | ||
} | ||
} | ||
|
||
if !directories.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do this some other time.
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior - Nonexistant outputs are considered globs - Glob outputs are walked from workspace root, which is slow on large repos [NX Daemon Server] - 2024-09-06T19:44:39.674Z - Done responding to the client outputsHashesMatch [NX Daemon Server] - 2024-09-06T19:44:39.674Z - Handled OUTPUTS_HASHES_MATCH. Handling time: 94. Response time: 0. [NX Daemon Server] - 2024-09-06T19:44:39.775Z - [REQUEST]: Responding to the client. recordOutputsHash [NX Daemon Server] - 2024-09-06T19:44:39.775Z - Done responding to the client recordOutputsHash [NX Daemon Server] - 2024-09-06T19:44:39.775Z - Handled RECORD_OUTPUTS_HASH. Handling time: 100. Response time: 0. [NX Daemon Server] - 2024-09-06T19:44:39.818Z - [REQUEST]: Responding to the client. PROCESS_IN_BACKGROUND [NX Daemon Server] - 2024-09-06T19:44:39.818Z - Done responding to the client PROCESS_IN_BACKGROUND [NX Daemon Server] - 2024-09-06T19:44:39.818Z - Handled PROCESS_IN_BACKGROUND. Handling time: 14. Response time: 0. ## Expected Behavior - Nonexistant outputs are only globs if they should be - Globs are a bit faster [NX Daemon Server] - 2024-09-06T19:43:36.899Z - Handled OUTPUTS_HASHES_MATCH. Handling time: 0. Response time: 0. [NX Daemon Server] - 2024-09-06T19:43:36.900Z - [REQUEST]: Responding to the client. recordOutputsHash [NX Daemon Server] - 2024-09-06T19:43:36.900Z - Done responding to the client recordOutputsHash [NX Daemon Server] - 2024-09-06T19:43:36.900Z - Handled RECORD_OUTPUTS_HASH. Handling time: 0. Response time: 0. [NX Daemon Server] - 2024-09-06T19:43:36.944Z - [REQUEST]: Responding to the client. PROCESS_IN_BACKGROUND [NX Daemon Server] - 2024-09-06T19:43:36.944Z - Done responding to the client PROCESS_IN_BACKGROUND [NX Daemon Server] - 2024-09-06T19:43:36.944Z - Handled PROCESS_IN_BACKGROUND. Handling time: 13. Response time: 0. [NX Daemon Server] - 2024-09-06T19:43:36.949Z - Uploading file artifacts [NX Daemon Server] - 2024-09-06T19:43:36.949Z - Done uploading file artifacts > Note timings are from Nx repo, close enough to be comparable. No real improvement was expected here, mainly checking that things didn't get worse. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: FrozenPandaz <[email protected]> (cherry picked from commit ac9da41)
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
[NX Daemon Server] - 2024-09-06T19:44:39.674Z - Done responding to the client outputsHashesMatch
[NX Daemon Server] - 2024-09-06T19:44:39.674Z - Handled OUTPUTS_HASHES_MATCH. Handling time: 94. Response time: 0.
[NX Daemon Server] - 2024-09-06T19:44:39.775Z - [REQUEST]: Responding to the client. recordOutputsHash
[NX Daemon Server] - 2024-09-06T19:44:39.775Z - Done responding to the client recordOutputsHash
[NX Daemon Server] - 2024-09-06T19:44:39.775Z - Handled RECORD_OUTPUTS_HASH. Handling time: 100. Response time: 0.
[NX Daemon Server] - 2024-09-06T19:44:39.818Z - [REQUEST]: Responding to the client. PROCESS_IN_BACKGROUND
[NX Daemon Server] - 2024-09-06T19:44:39.818Z - Done responding to the client PROCESS_IN_BACKGROUND
[NX Daemon Server] - 2024-09-06T19:44:39.818Z - Handled PROCESS_IN_BACKGROUND. Handling time: 14. Response time: 0.
Expected Behavior
[NX Daemon Server] - 2024-09-06T19:43:36.899Z - Handled OUTPUTS_HASHES_MATCH. Handling time: 0. Response time: 0.
[NX Daemon Server] - 2024-09-06T19:43:36.900Z - [REQUEST]: Responding to the client. recordOutputsHash
[NX Daemon Server] - 2024-09-06T19:43:36.900Z - Done responding to the client recordOutputsHash
[NX Daemon Server] - 2024-09-06T19:43:36.900Z - Handled RECORD_OUTPUTS_HASH. Handling time: 0. Response time: 0.
[NX Daemon Server] - 2024-09-06T19:43:36.944Z - [REQUEST]: Responding to the client. PROCESS_IN_BACKGROUND
[NX Daemon Server] - 2024-09-06T19:43:36.944Z - Done responding to the client PROCESS_IN_BACKGROUND
[NX Daemon Server] - 2024-09-06T19:43:36.944Z - Handled PROCESS_IN_BACKGROUND. Handling time: 13. Response time: 0.
[NX Daemon Server] - 2024-09-06T19:43:36.949Z - Uploading file artifacts
[NX Daemon Server] - 2024-09-06T19:43:36.949Z - Done uploading file artifacts
Related Issue(s)
Fixes #